Subject: Re: [boost] sorting floats by casting to integer
From: Thomas Klimpel (Thomas.Klimpel_at_[hidden])
Date: 2009-07-04 09:40:03
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.
Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk