_isnan, _isnanl
Go Up to float.h Index
Header File
float.h
Prototype
int _isnan(double d);
int _isnanl(long double ld);
Description
Tests whether a given double-precision floating-point value d is a NaN.
_isnanl is the long double version; it takes a long double argument.
Return Value
Returns a nonzero value (TRUE) if the value passed in is a NaN; otherwise it returns 0 (FALSE). The non-zero return value corresponds to either _FPCLASS_SNAN, if the NaN is of the signaling type, or _FPCLASS_QNAN, if the NaN is of the quiet type. The values for _FPCLASS_SNAN and _FPCLASS_QNAN are in float.h.
POSIX | ANSI C | ANSI C++ | Win32 | Win64 | macOS | |
---|---|---|---|---|---|---|
_isnan | + | |||||
_isnanl | + |
Example
#include <math.h>
int print_double(double value) {
/* print "Infinite" if value is NaN */
if (_isnan(value))
printf("Infinite");
else
printf("%f", value);
}