This commit is contained in:
carbotaniuman
2020-12-22 16:25:28 -06:00
parent d9b9aea9f5
commit 353f558f67

View File

@@ -453,11 +453,11 @@ fn math_fsum(iter: PyIterable<IntoPyFloat>, vm: &VirtualMachine) -> PyResult<f64
let y = lo + lo;
let x = hi + y;
/* Make half-even rounding work across multiple partials.
Needed so that sum([1e-16, 1, 1e16]) will round-up the last
digit to two instead of down to zero (the 1e-16 makes the 1
slightly closer to two). With a potential 1 ULP rounding
error fixed-up, math.fsum() can guarantee commutativity. */
// Make half-even rounding work across multiple partials.
// Needed so that sum([1e-16, 1, 1e16]) will round-up the last
// digit to two instead of down to zero (the 1e-16 makes the 1
// slightly closer to two). With a potential 1 ULP rounding
// error fixed-up, math.fsum() can guarantee commutativity.
#[allow(clippy::float_cmp)]
if y == x - hi {
hi = x;