On 11/17/05, Robert Ramey <ramey@rrsd.com> wrote:
The problem is given something like +/inf how do I create a float with that value? 
 
Can I use something like this?
 
double x;
x = std::numeric_limits<T>::quiet_NaN();
 
assert(x == std::numeric_limits<T>::quiet_NaN());

Not sure why you'd need the check if you've just done the assignment, but I don't believe that NaN-ness and Inf-ness can be tested like that.  You'd can use isnan() (which is spelled _isnan on Windows) to test for NaN.  Not sure if there is any way to distinguish between signaling and non-signaling NaNs however.  BSD-derived systems provide an isinf() as well, but Windows seems to omit this one.  There is also the C99 fpclassify stuff others have alluded to.  Win32 has _fpclass it would seem.


--
Caleb Epstein
caleb dot epstein at gmail dot com