C examples for math.h:isnan
macro/function
<cmath> <ctgmath> <math.h>
Returns whether x is a NaN (Not-A-Number) value, such as the square root of negative numbers or the result of 0/0.
bool isnan (float x); bool isnan (double x); bool isnan (long double x); isnan(x)
Parameter | Description |
---|---|
x | A floating-point value. |
A non-zero value (true) ifx is a NaN value; and zero (false) otherwise.
#include <stdio.h> #include <math.h> /* isnan, sqrt */ int main()/*ww w . j av a 2 s. c o m*/ { int a = 0; printf ("%d\n",isnan(0.0)); printf ("%d\n",isnan(1.0/a)); printf ("%d\n",isnan(-1.0/a)); printf ("%d\n",isnan(sqrt(-1.0))); return 0; }