The C99 prototype is listed as follows.
macro isnan(x)
The C++11 prototype is listed as follows.
bool isnan (float x); bool isnan (double x); bool isnan (long double x);
Returns whether x is a NaN ( Not-A-Number) value.
This function has the following parameter.
A non-zero value ( true) if x is a NaN value; and zero ( false) otherwise.
#include <stdio.h> /* printf */
#include <math.h> /* isnan, sqrt */
// w ww . j a va2s . c o m
int main()
{
printf ("isnan(0.0) : %d\n",isnan(0.0));
printf ("isnan(sqrt(-1.0)): %d\n",isnan(sqrt(-1.0)));
return 0;
}
The code above generates the following result.
#include <stdio.h>
#include <math.h>
#include <float.h>
/*w ww . j ava 2s .co m*/
int main(void)
{
printf("isnan(NAN) = %d\n", isnan(NAN));
printf("isnan(INFINITY) = %d\n", isnan(INFINITY));
printf("isnan(0.0) = %d\n", isnan(0.0));
printf("isnan(DBL_MIN/2.0) = %d\n", isnan(DBL_MIN/2.0));
printf("isnan(Inf - Inf) = %d\n", isnan(INFINITY - INFINITY));
}
The code above generates the following result.