mirror of
https://github.com/fastfloat/fast_float.git
synced 2025-12-06 16:56:57 +08:00
Adding a guard.
This commit is contained in:
parent
1283ea199b
commit
8fde4bad4e
@ -101,8 +101,11 @@ adjusted_mantissa compute_float(int64_t q, uint64_t w) noexcept {
|
|||||||
// In some very rare cases, this could happen, in which case we might need a more accurate
|
// In some very rare cases, this could happen, in which case we might need a more accurate
|
||||||
// computation that what we can provide cheaply. This is very, very unlikely.
|
// computation that what we can provide cheaply. This is very, very unlikely.
|
||||||
//
|
//
|
||||||
answer.power2 = -1; // This (a negative value) indicates an error condition.
|
const bool inside_safe_exponent = (q >= 0) && (q <= 55); // always good because 5**q <2**128.
|
||||||
return answer;
|
if(!inside_safe_exponent) {
|
||||||
|
answer.power2 = -1; // This (a negative value) indicates an error condition.
|
||||||
|
return answer;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
// The "compute_product_approximation" function can be slightly slower than a branchless approach:
|
// The "compute_product_approximation" function can be slightly slower than a branchless approach:
|
||||||
// value128 product = compute_product(q, w);
|
// value128 product = compute_product(q, w);
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user