Go to the first, previous, next, last section, table of contents.


"Not a Number" Values

The IEEE floating point format used by most modern computers supports values that are "not a number". These values are called NaNs. "Not a number" values result from certain operations which have no meaningful numeric result, such as zero divided by zero or infinity divided by infinity.

One noteworthy property of NaNs is that they are not equal to themselves. Thus, x == x can be 0 if the value of x is a NaN. You can use this to test whether a value is a NaN or not: if it is not equal to itself, then it is a NaN. But the recommended way to test for a NaN is with the isnan function (see section Predicates on Floats).

Almost any arithmetic operation in which one argument is a NaN returns a NaN.

Macro: double NAN
An expression representing a value which is "not a number". This macro is a GNU extension, available only on machines that support "not a number" values--that is to say, on all machines that support IEEE floating point.

You can use `#ifdef NAN' to test whether the machine supports NaNs. (Of course, you must arrange for GNU extensions to be visible, such as by defining _GNU_SOURCE, and then you must include `math.h'.)


Go to the first, previous, next, last section, table of contents.