# NaN - Floating Point

Floating Point

Floating-point precisions
IEEE 754
• 16-bit: Half (binary16)
• 32-bit: Single (binary32), decimal32
• 64-bit: Double (binary64), decimal64
• Extended precision formats
Other
• Minifloat
• Arbitrary precision

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 arithmetic overflow (which might return an infinity) or an arithmetic underflow (which would return the smallest normal number, a denormal number, or zero).

IEEE 754 NaNs are represented with the exponential field filled with ones (like infinity values), and some non-zero number in the significand (to make them distinct from infinity values); this representation allows the definition of multiple distinct NaN values, depending on which bits are set in the significand, but also on the value of the leading sign bit (not all applications are required to provide distinct semantics for those distinct NaN values).

For example, a bit-wise example of a IEEE floating-point standard single precision (32-bit) NaN would be: s111 1111 1axx xxxx xxxx xxxx xxxx xxxx where s is the sign (most often ignored in applications), a determines the type of NaN, and x is an extra payload (most often ignored in applications). If a = 1, it is a quiet NaN; if a is zero and the payload is nonzero, then it is a signaling NaN.

Floating point operations other than ordered comparisons normally propagate a quiet NaN (qNaN). Floating point operations on a signaling NaN (sNaN) signal an invalid operation exception, the default exception action is then the same as for qNaN operands and they produce a qNaN if producing a floating point result.

A comparison with a NaN always returns an unordered result even when comparing with itself. The comparison predicates are either signaling or non-signaling, the signaling versions signal an invalid exception for such comparisons. The equality and inequality predicates are non-signaling so x = x returning false can be used to test if x is a quiet NaN. The other standard comparison predicates are all signaling if they receive a NaN operand, the standard also provides non-signaling versions of these other predicates. The predicate isNaN(x) determines if a value is a NaN and never signals an exception, even if x is a signaling NaN.

The propagation of quiet NaNs through arithmetic operations allows errors to be detected at the end of a sequence of operations without extensive testing during intermediate stages. However, note that depending on the language and the function, NaNs can silently be removed in expressions that would give a constant result for all other floating-point values e.g. NaN^0, which may be defined as 1, so in general a later test for a set INVALID flag is needed to detect all cases where NaNs are introduced (see section Function definition below for further details).

In section 6.2 of the revised IEEE 754-2008 standard there are two anomalous functions (the maxnum and minnum functions that return the maximum of two operands that are expected to be numbers) that favor numbers — if just one of the operands is a NaN then the value of the other operand is returned.

The NaN 'toolbox' for GNU Octave and MATLAB skips all NaNs when computing aggregates (like averages, standard deviations, etc.). NaNs are assumed to represent missing values and so the statistical functions ignore NaNs in the data instead of propagating them.

### Other articles related to "floating point, floating, point":

Comparison Of Programming Languages (basic Instructions) - Type Identifiers - Floating Point
... FLOAT-BINARY-16 and FLOAT-BINARY-34, specify IEEE-754 binary floating point variables, and FLOAT-DECIMAL-16 and FLOAT-DECIMAL-34 specify IEEE decimal floating point variables ...
SSE5 - 2009 Revision
... rotate instructions, byte permutation and conditional move instructions, floating point fraction extraction ... FMA4 Floating-point vector multiply–accumulate ... F16C Half-precision floating-point conversion ...
Binary Scaling
... mainly by embedded C, DSP and assembler programmers to perform a pseudo floating point using integer arithmetic ... It is both faster and more accurate than directly using floating point instructions, however care must be taken not to cause an arithmetic overflow ... A position for the virtual 'binary point' is taken, and then subsequent arithmetic operations determine the resultants 'binary point' ...
TRIPS Architecture - TRIPS
... designs there are a variety of different types of units, integer, floating point, etc ... is fed a math-heavy workload, it will bog as soon as all the floating point units are busy, with the integer units lying idle ... If it is fed a data intensive program like a database job, the floating point units will lie idle while the integer units bog ...
Little-endian - Endianness and Hardware - Floating-point and Endianness
... storage for all types of data (integer, floating point, BCD), there have been a few historical machines where floating point numbers were represented in big-endian form ... have half little-endian, half big-endian floating point representation ... Because there have been many floating point formats with no "network" standard representation for them, there is no formal standard for transferring floating point values between heterogeneous ...

### Famous quotes containing the words point and/or floating:

I am less disposed to think of a West Point education as requisite for this business than I was at first. Good sense and energy are the qualities required.
Rutherford Birchard Hayes (1822–1893)

I know, it must have been my imagination, but it makes me realize how desperately alone the Earth is. Hanging in space like a speck of food floating in the ocean. Sooner or later to be swallowed up by some creature floating by.... Time will tell, Dr. Mason. We can only wait and wonder. Wonder how, wonder when.
—Tom Graeff. Tom Graeff. Young astronomer, Teenagers from Outer Space, after just seeing the invading spaceship through his telescope, and dismissing it (1959)