|
In computing, NaN (Not a
Number) is a result typically indicating invalid input or output in floating-point calculations. For example, a typical floating-point unit is not able to calculate the square root of negative numbers, and will instead
indicate that the operation was invalid and return a NaN result.
In floating-point calculations, NaN is not the same as zero or infinity, although all three are typically handled as special
cases in binary floating-point representations of real numbers as well as in floating-point operations. It is also not the same
as an overflow (which might return an infinity) or an underflow (which would return the smallest normal number, a subnormal number, or zero).
A NaN does not compare equal to any floating-point number or NaN, even if the latter has an identical representation. One can
therefore test whether a variable is a NaN by comparing it to itself.
In the IEEE floating-point standard, arithmetic operations involving NaN always produce NaN, allowing the value to propagate
through a calculation.
See also: IEEE floating-point
standard.
|