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 by Per C.

quizTest Your Knowledge

The ACID acronym describes the four characteristics of what?

A computer
A database
A digital image
A network
Correct! Incorrect!     View the ACID definition.
More Quizzes →

The Tech Terms Computer Dictionary

The definition of NaN on this page is an original definition written by the team. If you would like to reference this page or cite this definition, please use the green citation links above.

The goal of is to explain computer terminology in a way that is easy to understand. We strive for simplicity and accuracy with every definition we publish. If you have feedback about this definition or would like to suggest a new technical term, please contact us.

Sign up for the free TechTerms Newsletter

How often would you like to receive an email?

You can unsubscribe or change your frequency setting at any time using the links available in each email.

Questions? Please contact us.