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 its argument is NaN (not a number); false otherwise.

Example

#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