Home : Technical Terms : NaN Definition

NaN

Stands for "Not a Number." NaN is a term used in mathematics and computer science to describe a non-numeric value. It may also be a placeholder for an expected numeric result that cannot be defined as a floating point number.

There are two primary types of ways in which NaN may be generated: 1) a mathematical calculation and 2) non-numeric input. The following mathematical calculations produce NaN because the result is undefined:

  • 0 ÷ 0
  • 0 x ∞
  • ∞ ÷ ∞

When a calculation involves a character, string, or other non-numeric value, the result may also be NaN. For example, 20 x "horse" does not produce a numeric result since 20 is an integer and "horse" is a string. A function may return NaN as a result of invalid input, which is a preferred alternative to a program crash.

Some spreadsheet and database programs display NaN or #NaN in a table cell when the cell formula has not received valid numeric input for the calculation.

Different programming languages handle NaN values in different ways. For example, in JavaScript, NaN is a property of a global object (i.e. Number.NaN). JavaScript provides an isNan() function to check if a value is NaN. PHP uses the function is_nan() for the same purpose. Both return a boolean value of true or false.

Updated: June 28, 2018

Cite this definition:

https://techterms.com/definition/nan

TechTerms - The Tech Terms Computer Dictionary

This page contains a technical definiton of NaN. It explains in computing terminology what NaN means and is one of many technical terms in the TechTerms dictionary.

All definitions on the TechTerms website are written to be technically accurate but also easy to understand. If you find this NaN definition to be helpful, you can reference it using the citation links above. If you think a term should be updated or added to the TechTerms dictionary, please email TechTerms!