What are some good do-s and don’t-s for floating point arithmetic (IEEE754 in case there’s confusion) to ensure good numerical stability and high accuracy in your results?
I know a few like don’t subtract quantities of similar magnitude, but I’m curious what other good rules are out there.
First, enter with the notion that floating point numbers do NOT necessarily follow the same rules as real numbers… once you have accepted this, you will understand most of the pitfalls.
Here’s some rules/tips that I’ve always followed:
if (myFloat == 0)(a + b) + c != a + (b + c)