[lnkForumImage]
TotalShareware - Download Free Software

Confronta i prezzi di migliaia di prodotti.
Asp Forum
 Home | Login | Register | Search 


 

Forums >

comp.lang.c

Re: initialize a double with NAN?

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
1 Answer

David Mathog

5/13/2011 6:55:00 PM

0

On May 13, 11:20 am, "Joel C. Salomon" <joelcsalo...@gmail.com> wrote:

> What you're looking for is the macro NAN, defined in <math.h>

That worked. Thanks.

David Mathog