|
Boost : |
From: John Maddock (john_at_[hidden])
Date: 2006-07-26 13:17:57
Johan Råde wrote:
> Impressive. You seem to have thought of everything. I'm just a bit
> concerned about efficiency. For instance, if I call your isnan and I
> use VC++, then the following happens:
>
> 1. _fpclass is called
> 2. a switch statement is called to translate the result
> 3. the translated result is compared against FP_NAN
>
> Just doing x != x must be a lot faster, and works, at least on VC++
> 7.1,
> even with compiler optimizations turned on.
>
> I have situations where I want to check every element in an array with
> more than 100,000,000 elements, so I care about efficiency.
Understood, it's a question of getting a portable version - maybe an overly
pessimistic version - and then adding optimisations for specific compilers
where required. Actually MSVC has _isnan, so I really should be calling
that :-) Likewise platforms that have an isnan macro should use it etc...
John.
Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk