If the value you are testing for equality to 1.00 (exactly) is the result of a computation then the approximation of the result may not be exactly 1.00. Some numbers cannot be exactly represented in a fixed length binary floating point form, and doing maths on them can lead to the situation where these approximation errors accumulate. You can end up with a floating point value that differs from the exact value at the 15 th decimal place and 1.0 != 1.00000000000001. This is why people keep telling you about qFuzzyCompare().
What Every Computer Scientist Should Know About Floating-Point Arithmetic
In your situation, where you seem to be working with money, you may well be better off working strictly with integer numbers of cents.




Reply With Quote
Bookmarks