3 ms·
Not quite a+b, but a+b+c reordered may give different results[1]. Example from Python: >>> 0.1+0.2+0.3 0.6000000000000001 >>> 0.2+0.3+0.1 0.6 It's an
by rhymenoceros 8y ago
Not quite a+b, but a+b+c reordered may give different results[1]. Example from Python:
>>> 0.1+0.2+0.3
0.6000000000000001
>>> 0.2+0.3+0.1
0.6
It's an associativity problem and not a commutative one, however, that is relevant to the original point about folding floating point operations over lists.
[1] https://www.quora.com/Is-floating-point-addition-commutative-and-associative https://www.quora.com/Is-floating-point-addition-commutative...