mirror of
https://github.com/fastfloat/fast_float.git
synced 2025-12-07 01:06:48 +08:00
Adding a guard.
This commit is contained in:
parent
1283ea199b
commit
8fde4bad4e
@ -101,9 +101,12 @@ 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
|
||||
// computation that what we can provide cheaply. This is very, very unlikely.
|
||||
//
|
||||
const bool inside_safe_exponent = (q >= 0) && (q <= 55); // always good because 5**q <2**128.
|
||||
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:
|
||||
// value128 product = compute_product(q, w);
|
||||
// but in practice, we can win big with the compute_product_approximation if its additional branch
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user