3 ms·
https://play.rust-lang.org/?version=stable&mode=debug&edition=2024&gist=1440b547fd063bab88a7f2c2a203c8f0 https://play.rust-lang.org/?version=stable&mode=debug&e
by imtringued 1y ago
https://play.rust-lang.org/?version=stable&mode=debug&edition=2024&gist=1440b547fd063bab88a7f2c2a203c8f0 https://play.rust-lang.org/?version=stable&mode=debug&editio...
You're supposed to do (a+b) to demonstrate the effect, because floating point subtraction that results in a number near zero is sensitive to rounding (worst case, a non-zero number gets you a zero number), which can introduce a huge error when a and b are very similar numbers.
- jcranmer 1y agoWhen you go from (a + b) + c to a + (b + c), you're invoking the associative property, not the commutative property. The confusion between associativity and commutativity is the entire point of this thread!