Home

notanumber

Notanumber, commonly written NaN, stands for Not a Number and is a value used to denote an undefined or unrepresentable result in floating-point arithmetic.

In IEEE 754 floating-point systems, NaN values are represented with all exponent bits set to 1 and

NaN has distinctive arithmetic behavior: any operation that involves NaN typically yields NaN, and NaN participates

NaN is generated by invalid or undefined operations, such as 0/0, the square root of a negative

Across programming languages and platforms, the exact handling and exposure of NaN can vary. Some environments

See also: IEEE 754, floating-point arithmetic, NaN payload.

a
nonzero
significand.
There
are
two
main
types:
quiet
NaN
(qNaN)
and
signaling
NaN
(sNaN).
The
bits
in
the
significand
can
carry
a
payload
that
some
implementations
use
to
encode
diagnostic
information
about
the
source
of
the
NaN.
in
comparisons
in
a
non-standard
way.
In
most
languages,
NaN
is
not
equal
to
any
value,
including
itself,
so
NaN
==
NaN
is
false
while
NaN
!=
NaN
is
true.
To
detect
NaN,
programs
usually
rely
on
language-specific
predicates
such
as
isnan
or
isNaN.
number
in
real
arithmetic,
or
applying
a
function
to
inappropriate
inputs.
It
is
distinct
from
infinity
and
is
used
to
signal
errors
without
interrupting
program
flow,
allowing
subsequent
computations
to
handle
or
propagate
the
issue.
offer
tools
to
inspect
or
manipulate
the
NaN
payload,
while
others
provide
standard
predicates
and
arithmetic
rules
consistent
with
the
IEEE
754
standard.