6.11.133 nan Function
Returns a quiet NaN double precision floating-point value.
Include
<math.h>
Prototype
double nan(const char * tagp);
Arguments
tagp
- an optional, implementation-defined string which might be used to represent extra information in the NaN’s significand
Return Value
The call nan("n-char-sequence")
is equivalent to
strtod("NAN(n-char- sequence)", (char**) NULL);
the call
nan("")
is equivalent to strtod("NAN()", (char**)
NULL)
. When tagp
does not point to an n-char sequence or
an empty string, the equivalent call to strtod
would have a first
argument of "NAN"
.
Example
See the notes at the beginning of this chapter or section for
information on using printf()
or scanf()
(and other functions reading and writing the stdin
or
stdout
streams) in the example code.
#include <math.h>
#include <stdio.h>
int main(void)
{
double x;
z = nan(NULL);
printf("Here is our not-a-number: %f\n", z);
}
Example Output
Here is our not-a-number: nan