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
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.
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
Go to the first, previous, next, last section, table of contents.