isnan() — Test for NaN

Standards

Standards / Extensions C or C++ Dependencies

XPG4
XPG4.2
Single UNIX Specification, Version 3
C/C++ DFP
C++ TR1 C99

both z/OS® V1R8

Format

#define  _XOPEN_SOURCE
#include <math.h>

int isnan(double x);

#define __STDC_WANT_DEC_FP__
#include <math.h>

int isnan(real-floating x);  /* C only */ 
int isnan(decimal-floating x);  /* C only */
bool isnan(real-floating x);  /* C++ only */ 
bool isnan(decimal-floating x);  /* C++ only */

#define _TR1_C99
#include <math.h>

bool isnan(double x);  /* C++ only */

General description

The isnan() function tests whether x is NaN (not a number).

isnan() is available as a macro. For better performance, the macro form is recommended over the functional form. For C compiles only, to use the functional form, do one of the following:
  • Do not include math.h.
  • Specify #undef isnan after the inclusion of math.h.
  • Enclose the call statement in parentheses.
Notes:
  1. To use IEEE decimal floating-point, the hardware must have the Decimal Floating-Point Facility installed.
  2. This function works in IEEE decimal floating-point format. See "IEEE Decimal Floating-Point" for more information.

Returned value

For IEEE Decimal Floating Point numbers and Binary Floating Point numbers, a non-zero value is returned if x is a NAN. The C++ function template returns true if x is a NAN.

Special behavior in Hex

The isnan() macro returns zero. The C++ function template returns false.

Related information