
4 Jul
2009
4 Jul
'09
1:40 p.m.
Simonson, Lucanus J wrote:
If you think about it, if casting to integer to compare floating point values is faster, why doesn't the processor do that itself? I have been told that some processors do.
Some floating point values that don't correspond to real numbers (like INF and NaN) have a very complicated behavior with respect to comparison. At least I remember that std::sort used to crash when trying to sort data containing NaNs. I think it has something to do with "a < b" being somehow related to "(a-b) < 0" or "0 < (b-a)" and a minus operation involving a NaN must yield a NaN.