« Return to Thread: sorting floats by casting to integer

Re: sorting floats by casting to integer

by Thomas Klimpel :: Rate this Message:

Reply to Author | View in Thread

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.
_______________________________________________
Unsubscribe & other changes: http://lists.boost.org/mailman/listinfo.cgi/boost

 « Return to Thread: sorting floats by casting to integer