# isnan Macro

Returns true if its argument is NaN.

Include

<math.h>

Prototype

int isnan(floating-point x);

Argument

 x any floating-point number

Return Value

Returns true if x is NaN (not a number); false otherwise.

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, y, z;

x = 0.0;
y = 0.0;
z = x / y;
if(isnan(z))
printf("NaN detected in division of %f by %f\n", x, y);
}

Example Output

NaN detected in division of 0.000000 by 0.000000