O.B. <fu******@bellsouth.netwrote:
In the following piece of code, the == operator is saying that the two
different float values are the same. What's going on here?
There aren't two different float values there. When you subtract one
from the largest possible float value, it's still closer to the largest
possible float value than to any other value, so testValueB is the same
as testValueA.
For a more concrete understanding of this - suppose you are writing
down numbers to three significant decimal digits. Now work out the
result of this calculation:
123000 - 0.0000987
The "perfct" result is 122999.9999013. However, we've got to represent
it to three significant figures - which is 123000 again.
--
Jon Skeet - <sk***@pobox.com>
http://www.pobox.com/~skeet Blog:
http://www.msmvps.com/jon.skeet
If replying to the group, please do not mail me too