Boost logo

Boost :

From: Fernando Cacciola (fcacciola_at_[hidden])
Date: 2003-07-05 14:24:01

"Joel de Guzman" <djowel_at_[hidden]> escribió en el mensaje news:000801c342f1$9de5a3d0$0100a8c0_at_godzilla...
> Fernando Cacciola <fernando_cacciola_at_[hidden]> wrote:
> > Gabriel Dos Reis <gdr_at_[hidden]> wrote in
> >> Yes. It is an incorrect (unfortunately popular)
> >> implementation.
> >>
> > Right. We should say that more often. It is incorrect
> > however popular.
> >
> > Most compilers provide a non standard extension for this
> > purpose.
> > For instance, Borland uses _isnan.
> > In general, these extensions are found on <float>.
> > The best approach, IMO, is to have a boost::is_nan() with
> > compiler specific implementations.
> Hi,
> We have an is_nan(float) implementation (for quiet NaNs of course)
> that does just that. Right now, it supports most compilers on Win32 but it
> should be straight-forward to support others. Right now, it is tested on:
> g++2.95.3 (MinGW)
> g++3.1 (MinGW)
> Borland 5.5.1
> Comeau 4.24 (Win32)
> Microsoft Visual C++ 6
> Microsoft Visual C++ 7
> Microsoft Visual C++ 7.1
> Metrowerks CodeWarrior 7.2
> The default implementation assumes IEEE754 floating point. It takes advantage
> of the fact that IEEE754 has a well defined binary layout for quiet NaNs. Platform
> specific implementations forward the call to the correct platform header when
> available. The code does not rely on the availability of numeric_limits.
> I hope this can be used as the basis of a standardized boost::is_nan utility.
> Thoughts?
It works for me....
Checking directly for the bit patterns is the way it has been done for years in
the Windows platform.
As long as this implementation is correctly dispatched from the user function
I see no problem.

BTW, it just poped my mine: could SFINAE be arranged to detect the existence
of a global non-member function? We could write an implementation that dispatches
to _isnan(), __isnan(), an so on if available.
(though this would break the ODR on the other hand)

Fernando Cacciola

Boost list run by bdawes at, gregod at, cpdaniel at, john at