[Issue 1756] comparing a constant to artihmetic expression with floating point types fails

d-bugmail at puremagic.com d-bugmail at puremagic.com
Mon Dec 31 11:11:50 PST 2007


http://d.puremagic.com/issues/show_bug.cgi?id=1756





------- Comment #4 from wbaxter at gmail.com  2007-12-31 13:11 -------
You should almost never rely on == to compare floating point numbers.  
The failure you're seeing is a perfect example of why not.
Here's the first thing I could google up about it:
http://www.cygnus-software.com/papers/comparingfloats/comparingfloats.htm
but if you'll look you should find dozens of references saying the same thing.

That said, I can see why you would expect those particular cases to work, but
in general you should never be surprised by equality failing in floating point
comparisons.  There are just too many things that can go wrong.


-- 



More information about the Digitalmars-d-bugs mailing list