Joel C. Salomon
5/13/2011 6:20:00 PM
On Friday, May 13, 2011 1:52:05 PM UTC-4, David Mathog wrote:
> How does one initialize a variable to NAN in compliance with the c99
> standard? This doesn't work:
<snip>
> double dnan=FP_NAN;
No, it wouldn't; see the definition of FP_NAN to understand why. (Hint: Check out the macro fpclassify(x) -- what does it return?)
What you're looking for is the macro NAN, defined in <math.h> "if and only if the implementation supports quiet NaNs for the float type" (C99 §7.12 ¶5).
--Joel