Of course, this largely depends on how "YOLO" your compiler is. I believe GCC and Clang try reasonably hard to follow IEEE 754, which ICC is much more lax.
Of course, this largely depends on how "YOLO" your compiler is. I believe GCC and Clang try reasonably hard to follow IEEE 754, which ICC is much more lax.
Consider (a+b)+c vs a+(b+c). Now suppose a is 1, b is 2.0^60, c is -b. The first expression evaluates to 0, the second evaluates to 1.
Scientific and engineering code is carefully designed for numerical stability and compilers must not mess this up.
gcc has a "fast math" flag you can use if you don't care about the accuracy of your results.
(1 + 2.060) - 2.060 == 0
while
1 + (2.060 - 2.060) == 1?
Am I just misunderstanding what you wrote?
Most code survives being sloppy around this, some doesn't. We had some code which relied on the propagation of infinities, so had to fiddle with some compiler options for that file to ensure the compiler wasn't being too clever.