NaN is a term used in mathematics and computer science to describe a non-numeric value.
The full-form of NaN is ” Not a Number .” It can also be used on the basis of a placeholder for an expected numeric result that cannot be defined on the basis of a floating-point number.
There are two primary types of methods by which NaN can be generated:
1) एक mathematical calculation
2) non-numeric input.
Here the following mathematical calculations provide results that are undefined:
- 0 ÷ 0
- 0 x ∞
- ∞ ÷ ∞
When a calculation includes a character, string, or another non-numeric value, the result can also contain NaN. For example, 20 x ” horse ” does not provide any numeric result since 20 is an integer and “horse” is a string. A function can return NaN that too invalid input as a result, which is preferred for a program crash over alternative.
Some spreadsheet and database programs display NaN or #NaN in a table cell when the cell formula does not receive a valid numeric input for calculation.