Recent Articles



































NaN



         



In computing, NaN (Not a Number) is a value or symbol that is usually produced as the result of an operation on invalid input operands, especially in floating-point calculations. For example, most floating-point units are unable 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 infinity, although both are typically handled as special cases in floating-point representations of real numbers as well as in floating-point operations. An invalid operation 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 has a NaN value 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. In the current (proposed) revision of that standard, there are two exceptions to this rule: the maxnum and minnum functions return the maximum and minimum of two operands, and will favour numbers (if just one of the operands is a NaN then the other operand is returned). This behaviour is useful in the statistical processing of sparse data.






  View Live Article   This article is from Wikipedia. All text is available under the terms of the GNU Free Documentation License