News for hackers. Stuff that matters.
Re:Beware of Fast-Math by eddd-ddde on Saturday May 31, 2025 @11:42AM (#44144992)
How do you handle the lack of commutativity? I've always wondered about the practical implications.
Re:Beware of Fast-Math by BeetleB on Saturday May 31, 2025 @12:12PM (#44145225)
Nitpick: FP arithmetic is commutative. It's not associative.
Re:Beware of Fast-Math by jcranmer on Saturday May 31, 2025 @11:49AM (#44145041)
Floating-point is completely commutative (ignoring NaN payloads).

It's the associativity law that it fails to uphold.

Re:Beware of Fast-Math by jakevoytko on Saturday May 31, 2025 @11:51AM (#44145053)
I asked an ex-Bloomberg coder this question once after he told me he used floating points to represent currency all the time, and his response was along the lines of “unless you have blindingly-obvious problems like doing operations on near-zero numbers against very large numbers, these calculations are off by small amounts on their least-significant digits. Why would you waste the time or the electricity dealing with a discrepancy that’s not even worth the money to fix?”