Floating point less-than-equal comparisons after addition and substraction

No, there is no best practice. Unfortunately, there cannot be, because almost all floating-point calculations introduce some rounding error, and the consequences of the errors are different for different applications. Typically, software will perform some calculations that ideally would yield some exact mathematical result x but, due to rounding errors (or other issues), produce an … Read more

Double.Epsilon for equality, greater than, less than, less than or equal to, greater than or equal to

I don’t know what they were smoking when they wrote that. Double.Epsilon is the smallest representable non-denormal floating point value that isn’t 0. All you know is that, if there’s a truncation error, it will always be larger than this value. Much larger. The System.Double type can represent values accurate to up to 15 digits. … Read more