Comparing floating point: == vs is

Jonathan M Davis jmdavisProg at gmx.com
Sat Jul 16 01:35:19 PDT 2011


Under what circumstances would a comparison of floating point values return 
true for is but not ==? If I understand corcectly, is does a bit-by-bit 
comparison. So, I would expect that if is returns true, == would return true. 
However, that does not seem to always be the case. Does anyone know why that 
would be?

In particular, I'm trying to write a function for swapping the endianness of 
floating point values, and while it seems to be generally be returning true for 
is, == keeps failing. So, it sounds like I have two floating point values which 
have the exact same bits (since is succeeds) but which aren't equal according 
to ==. I don't understand what's going on at all. Does anyone have a clue what 
might be happening?

- Jonathan M Davis


More information about the Digitalmars-d-learn mailing list