**Double-precision floating-point format** (sometimes called **FP64** or **float64**) is a computer number format, usually occupying 64 bits in computer memory; it represents a wide dynamic range of numeric values by using a floating radix point.

- IEEE 754 double-precision binary floating-point format: binary64
- Exponent encoding
- Endianness
- Double-precision examples
- Execution speed with double-precision arithmetic
- Precision limitations on integer values
- Implementations
- C and C++
- Fortran
- Common Lisp
- Java
- JavaScript
- See also
- Notes and references

Floating point is used to represent fractional values, or when a wider range is needed than is provided by fixed point (of the same bit width), even if at the cost of precision. Double precision may be chosen when the range or precision of single precision would be insufficient.

In the IEEE 754-2008 standard, the 64-bit base-2 format is officially referred to as **binary64**; it was called **double** in IEEE 754-1985. IEEE 754 specifies additional floating-point formats, including 32-bit base-2 *single precision* and, more recently, base-10 representations.

One of the first programming languages to provide single- and double-precision floating-point data types was Fortran. Before the widespread adoption of IEEE 754-1985, the representation and properties of floating-point data types depended on the computer manufacturer and computer model, and upon decisions made by programming-language implementers. E.g., GW-BASIC's double-precision data type was the 64-bit MBF floating-point format.

Floating-point formats |
---|

IEEE 754 |

Other |

Double-precision binary floating-point is a commonly used format on PCs, due to its wider range over single-precision floating point, in spite of its performance and bandwidth cost. It is commonly known simply as *double*. The IEEE 754 standard specifies a **binary64** as having:

- Sign bit: 1 bit
- Exponent: 11 bits
- Significand precision: 53 bits (52 explicitly stored)

The sign bit determines the sign of the number (including when this number is zero, which is signed).

The exponent field is an 11-bit unsigned integer from 0 to 2047, in biased form: an exponent value of 1023 represents the actual zero. Exponents range from −1022 to +1023 because exponents of −1023 (all 0s) and +1024 (all 1s) are reserved for special numbers.

The 53-bit significand precision gives from 15 to 17 significant decimal digits precision (2^{−53} ≈ 1.11 × 10^{−16}). If a decimal string with at most 15 significant digits is converted to IEEE 754 double-precision representation, and then converted back to a decimal string with the same number of digits, the final result should match the original string. If an IEEE 754 double-precision number is converted to a decimal string with at least 17 significant digits, and then converted back to double-precision representation, the final result must match the original number.^{ [1] }

The format is written with the significand having an implicit integer bit of value 1 (except for special data, see the exponent encoding below). With the 52 bits of the fraction (F) significand appearing in the memory format, the total precision is therefore 53 bits (approximately 16 decimal digits, 53 log_{10}(2) ≈ 15.955). The bits are laid out as follows:

The real value assumed by a given 64-bit double-precision datum with a given biased exponent and a 52-bit fraction is

or

Between 2^{52}=4,503,599,627,370,496 and 2^{53}=9,007,199,254,740,992 the representable numbers are exactly the integers. For the next range, from 2^{53} to 2^{54}, everything is multiplied by 2, so the representable numbers are the even ones, etc. Conversely, for the previous range from 2^{51} to 2^{52}, the spacing is 0.5, etc.

The spacing as a fraction of the numbers in the range from 2^{n} to 2^{n+1} is 2^{n−52}. The maximum relative rounding error when rounding a number to the nearest representable one (the machine epsilon) is therefore 2^{−53}.

The 11 bit width of the exponent allows the representation of numbers between 10^{−308} and 10^{308}, with full 15–17 decimal digits precision. By compromising precision, the subnormal representation allows even smaller values up to about 5 × 10^{−324}.

The double-precision binary floating-point exponent is encoded using an offset-binary representation, with the zero offset being 1023; also known as exponent bias in the IEEE 754 standard. Examples of such representations would be:

e =`00000000001` =`001` =1: | (smallest exponent for normal numbers) | ||

e =`01111111111` =`3ff` =1023: | (zero offset) | ||

e =`10000000101` =`405` =1029: | |||

e =`11111111110` =`7fe` =2046: | (highest exponent) |

The exponents `000`

and _{16}`7ff`

have a special meaning:_{16}

`00000000000`

=_{2}`000`

is used to represent a signed zero (if_{16}*F*= 0) and subnormals (if*F*≠ 0); and`11111111111`

=_{2}`7ff`

is used to represent ∞ (if_{16}*F*= 0) and NaNs (if*F*≠ 0),

where *F* is the fractional part of the significand. All bit patterns are valid encoding.

Except for the above exceptions, the entire double-precision number is described by:

In the case of subnormals (*e* = 0) the double-precision number is described by:

Although the ubiquitous x86 processors of today use little-endian storage for all types of data (integer, floating point), there are a number of hardware architectures where floating-point numbers are represented in big-endian form while integers are represented in little-endian form.^{ [2] } There are ARM processors that have half little-endian, half big-endian floating-point representation for double-precision numbers: both 32-bit words are stored in little-endian like integer registers, but the most significant one first. Because there have been many floating-point formats with no "network" standard representation for them, the XDR standard uses big-endian IEEE 754 as its representation. It may therefore appear strange that the widespread IEEE 754 floating-point standard does not specify endianness.^{ [3] } Theoretically, this means that even standard IEEE floating-point data written by one machine might not be readable by another. However, on modern standard computers (i.e., implementing IEEE 754), one may in practice safely assume that the endianness is the same for floating-point numbers as for integers, making the conversion straightforward regardless of data type. (Small embedded systems using special floating-point formats may be another matter however.)

0 01111111111 0000000000000000000000000000000000000000000000000000_{2} ≙ 3FF0 0000 0000 0000_{16} ≙ +2^{0} × 1 = 1 |

0 01111111111 0000000000000000000000000000000000000000000000000001_{2} ≙ 3FF0 0000 0000 0001_{16} ≙ +2^{0} × (1 + 2^{−52}) ≈ 1.0000000000000002, the smallest number > 1 |

0 01111111111 0000000000000000000000000000000000000000000000000010_{2} ≙ 3FF0 0000 0000 0002_{16} ≙ +2^{0} × (1 + 2^{−51}) ≈ 1.0000000000000004 |

0 10000000000 0000000000000000000000000000000000000000000000000000_{2} ≙ 4000 0000 0000 0000_{16} ≙ +2^{1} × 1 = 2 |

1 10000000000 0000000000000000000000000000000000000000000000000000_{2} ≙ C000 0000 0000 0000_{16} ≙ −2^{1} × 1 = −2 |

0 10000000000 1000000000000000000000000000000000000000000000000000_{2} ≙ 4008 0000 0000 0000_{16} ≙ +2^{1} × 1.1_{2} = 11_{2} = 3 |

0 10000000001 0000000000000000000000000000000000000000000000000000_{2} ≙ 4010 0000 0000 0000_{16} ≙ +2^{2} × 1 = 100_{2} = 4 |

0 10000000001 0100000000000000000000000000000000000000000000000000_{2} ≙ 4014 0000 0000 0000_{16} ≙ +2^{2} × 1.01_{2} = 101_{2} = 5 |

0 10000000001 1000000000000000000000000000000000000000000000000000_{2} ≙ 4018 0000 0000 0000_{16} ≙ +2^{2} × 1.1_{2} = 110_{2} = 6 |

0 10000000011 0111000000000000000000000000000000000000000000000000_{2} ≙ 4037 0000 0000 0000_{16} ≙ +2^{4} × 1.0111_{2} = 10111_{2} = 23 |

0 01111111000 1000000000000000000000000000000000000000000000000000_{2} ≙ 3F88 0000 0000 0000_{16} ≙ +2^{−7} × 1.1_{2} = 0.00000011_{2} = 0.01171875 (3/256) |

0 00000000000 0000000000000000000000000000000000000000000000000001_{2} ≙ 0000 0000 0000 0001_{16} ≙ +2^{−1022} × 2^{−52} = 2^{−1074} ≈ 4.9406564584124654 × 10^{−324} (Min. subnormal positive double) |

0 00000000000 1111111111111111111111111111111111111111111111111111_{2} ≙ 000F FFFF FFFF FFFF_{16} ≙ +2^{−1022} × (1 − 2^{−52}) ≈ 2.2250738585072009 × 10^{−308} (Max. subnormal double) |

0 00000000001 0000000000000000000000000000000000000000000000000000_{2} ≙ 0010 0000 0000 0000_{16} ≙ +2^{−1022} × 1 ≈ 2.2250738585072014 × 10^{−308} (Min. normal positive double) |

0 11111111110 1111111111111111111111111111111111111111111111111111_{2} ≙ 7FEF FFFF FFFF FFFF_{16} ≙ +2^{1023} × (1 + (1 − 2^{−52})) ≈ 1.7976931348623157 × 10^{308} (Max. Double) |

0 00000000000 0000000000000000000000000000000000000000000000000000_{2} ≙ 0000 0000 0000 0000_{16} ≙ +0 |

1 00000000000 0000000000000000000000000000000000000000000000000000_{2} ≙ 8000 0000 0000 0000_{16} ≙ −0 |

0 11111111111 0000000000000000000000000000000000000000000000000000_{2} ≙ 7FF0 0000 0000 0000_{16} ≙ +∞ (positive infinity) |

1 11111111111 0000000000000000000000000000000000000000000000000000_{2} ≙ FFF0 0000 0000 0000_{16} ≙ −∞ (negative infinity) |

0 11111111111 0000000000000000000000000000000000000000000000000001_{2} ≙ 7FF0 0000 0000 0001_{16} ≙ NaN (sNaN on most processors, such as x86 and ARM) |

0 11111111111 1000000000000000000000000000000000000000000000000001_{2} ≙ 7FF8 0000 0000 0001_{16} ≙ NaN (qNaN on most processors, such as x86 and ARM) |

0 11111111111 1111111111111111111111111111111111111111111111111111_{2} ≙ 7FFF FFFF FFFF FFFF_{16} ≙ NaN (an alternative encoding of NaN) |

0 01111111101 0101010101010101010101010101010101010101010101010101_{2} = 3FD5 5555 5555 5555_{16} ≙ +2^{−2} × (1 + 2^{−2} + 2^{−4} + ... + 2^{−52}) ≈ ^{1}/_{3} |

0 10000000000 1001001000011111101101010100010001000010110100011000_{2} = 4009 21FB 5444 2D18_{16} ≈ pi |

Encodings of qNaN and sNaN are not completely specified in IEEE 754 and depend on the processor. Most processors, such as the x86 family and the ARM family processors, use the most significant bit of the significand field to indicate a quiet NaN; this is what is recommended by IEEE 754. The PA-RISC processors use the bit to indicate a signaling NaN.

By default, ^{1}/_{3} rounds down, instead of up like single precision, because of the odd number of bits in the significand.

In more detail:

Given the hexadecimal representation 3FD5 5555 5555 5555_{16}, Sign = 0 Exponent = 3FD_{16}= 1021 Exponent Bias = 1023 (constant value; see above) Fraction = 5 5555 5555 5555_{16}Value = 2^{(Exponent − Exponent Bias)}× 1.Fraction – Note that Fraction must not be converted to decimal here = 2^{−2}× (15 5555 5555 5555_{16}× 2^{−52}) = 2^{−54}× 15 5555 5555 5555_{16}= 0.333333333333333314829616256247390992939472198486328125 ≈ 1/3

Using double-precision floating-point variables and mathematical functions (e.g., sin, cos, atan2, log, exp and sqrt) are slower than working with their single precision counterparts. One area of computing where this is a particular issue is parallel code running on GPUs. For example, when using NVIDIA's CUDA platform, calculations with double precision take, depending on a hardware, approximately 2 to 32 times as long to complete compared to those done using single precision.^{ [4] }

- Integers from −2
^{53}to 2^{53}(−9,007,199,254,740,992 to 9,007,199,254,740,992) can be exactly represented - Integers between 2
^{53}and 2^{54}= 18,014,398,509,481,984 round to a multiple of 2 (even number) - Integers between 2
^{54}and 2^{55}= 36,028,797,018,963,968 round to a multiple of 4

Doubles are implemented in many programming languages in different ways such as the following. On processors with only dynamic precision, such as x86 without SSE2 (or when SSE2 is not used, for compatibility purpose) and with extended precision used by default, software may have difficulties to fulfill some requirements.

C and C++ offer a wide variety of arithmetic types. Double precision is not required by the standards (except by the optional annex F of C99, covering IEEE 754 arithmetic), but on most systems, the `double`

type corresponds to double precision. However, on 32-bit x86 with extended precision by default, some compilers may not conform to the C standard or the arithmetic may suffer from double rounding.^{ [5] }

Fortran provides several integer and real types, and the 64-bit type `real64`

, accessible via Fortran's intrinsic module `iso_fortran_env`

, corresponds to double precision.

Common Lisp provides the types SHORT-FLOAT, SINGLE-FLOAT, DOUBLE-FLOAT and LONG-FLOAT. Most implementations provide SINGLE-FLOATs and DOUBLE-FLOATs with the other types appropriate synonyms. Common Lisp provides exceptions for catching floating-point underflows and overflows, and the inexact floating-point exception, as per IEEE 754. No infinities and NaNs are described in the ANSI standard, however, several implementations do provide these as extensions.

On Java before version 1.2, every implementation had to be IEEE 754 compliant. Version 1.2 allowed implementations to bring extra precision in intermediate computations for platforms like x87. Thus a modifier strictfp was introduced to enforce strict IEEE 754 computations.

As specified by the ECMAScript standard, all arithmetic in JavaScript shall be done using double-precision floating-point arithmetic.^{ [6] }

- IEEE 754, IEEE standard for floating-point arithmetic

- ↑ William Kahan (1 October 1997). "Lecture Notes on the Status of IEEE Standard 754 for Binary Floating-Point Arithmetic" (PDF). Archived (PDF) from the original on 8 February 2012.
- ↑ Savard, John J. G. (2018) [2005], "Floating-Point Formats",
*quadibloc*, archived from the original on 2018-07-03, retrieved 2018-07-16 - ↑ "pack – convert a list into a binary representation".
- ↑ "Nvidia's New Titan V Pushes 110 Teraflops From A Single Chip".
*Tom's Hardware*. 2017-12-08. Retrieved 2018-11-05. - ↑ "Bug 323 – optimized code gives strange floating point results".
*gcc.gnu.org*. Archived from the original on 30 April 2018. Retrieved 30 April 2018. - ↑
*ECMA-262 ECMAScript Language Specification*(PDF) (5th ed.). Ecma International. p. 29, §8.5*The Number Type*. Archived (PDF) from the original on 2012-03-13.

In computing, **floating-point arithmetic** (**FP**) is arithmetic using formulaic representation of real numbers as an approximation to support a trade-off between range and precision. For this reason, floating-point computation is often used in systems with very small and very large real numbers that require fast processing times. In general, a floating-point number is represented approximately with a fixed number of significant digits and scaled using an exponent in some fixed base; the base for the scaling is normally two, ten, or sixteen. A number that can be represented exactly is of the following form:

**IEEE 754-1985** was an industry standard for representing floating-point numbers in computers, officially adopted in 1985 and superseded in 2008 by IEEE 754-2008, and then again in 2019 by minor revision IEEE 754-2019. During its 23 years, it was the most widely used format for floating-point computation. It was implemented in software, in the form of floating-point libraries, and in hardware, in the instructions of many CPUs and FPUs. The first integrated circuit to implement the draft of what was to become IEEE 754-1985 was the Intel 8087.

A **computer number format** is the internal representation of numeric values in digital device hardware and software, such as in programmable computers and calculators. Numerical values are stored as groupings of bits, such as bytes and words. The encoding between numerical values and bit patterns is chosen for convenience of the operation of the computer; the encoding used by the computer's instruction set generally requires conversion for external use, such as for printing and display. Different types of processors may have different internal representations of numerical values and different conventions are used for integer and real numbers. Most calculations are carried out with number formats that fit into a processor register, but some software systems allow representation of arbitrarily large numbers using multiple words of memory.

The **IEEE Standard for Floating-Point Arithmetic** is a technical standard for floating-point arithmetic established in 1985 by the Institute of Electrical and Electronics Engineers (IEEE). The standard addressed many problems found in the diverse floating-point implementations that made them difficult to use reliably and portably. Many hardware floating-point units use the IEEE 754 standard.

The **significand** is part of a number in scientific notation or a floating-point number, consisting of its significant digits. Depending on the interpretation of the exponent, the significand may represent an integer or a fraction.

**Hexadecimal floating point** is a format for encoding floating-point numbers first introduced on the IBM System/360 computers, and supported on subsequent machines based on that architecture, as well as machines which were intended to be application-compatible with System/360.

In computing, **minifloats** are floating-point values represented with very few bits. Predictably, they are not well suited for general-purpose numerical calculations. They are used for special purposes, most often in computer graphics, where iterations are small and precision has aesthetic effects. Machine learning also uses similar formats like bfloat16. Additionally, they are frequently encountered as a pedagogical tool in computer-science courses to demonstrate the properties and structures of floating-point arithmetic and IEEE 754 numbers.

**Extended precision** refers to floating-point number formats that provide greater precision than the basic floating-point formats. Extended precision formats support a basic format by minimizing roundoff and overflow errors in intermediate values of expressions on the base format. In contrast to *extended precision*, arbitrary-precision arithmetic refers to implementations of much larger numeric types using special software.

**Decimal floating-point** (**DFP**) arithmetic refers to both a representation and operations on decimal floating-point numbers. Working directly with decimal (base-10) fractions can avoid the rounding errors that otherwise typically occur when converting between decimal fractions and binary (base-2) fractions.

The IEEE 754-2008 standard includes decimal floating-point number formats in which the significand and the exponent can be encoded in two ways, referred to as **binary encoding** and *decimal encoding*.

**IEEE 754-2008** was published in August 2008 and is a significant revision to, and replaces, the IEEE 754-1985 floating-point standard, while in 2019 it was updated with a minor revision IEEE 754-2019. The 2008 revision extended the previous standard where it was necessary, added decimal arithmetic and formats, tightened up certain areas of the original standard which were left undefined, and merged in IEEE 854.

In computing, **half precision** is a binary floating-point computer number format that occupies 16 bits in computer memory.

In computing, **quadruple precision** is a binary floating point–based computer number format that occupies 16 bytes with precision at least twice the 53-bit double precision.

**Single-precision floating-point format** is a computer number format, usually occupying 32 bits in computer memory; it represents a wide dynamic range of numeric values by using a floating radix point.

In computing, **decimal32** is a decimal floating-point computer numbering format that occupies 4 bytes (32 bits) in computer memory. It is intended for applications where it is necessary to emulate decimal rounding exactly, such as financial and tax computations. Like the binary16 format, it is intended for memory saving storage.

In computing, **decimal64** is a decimal floating-point computer numbering format that occupies 8 bytes in computer memory. It is intended for applications where it is necessary to emulate decimal rounding exactly, such as financial and tax computations.

In computing, **decimal128** is a decimal floating-point computer numbering format that occupies 16 bytes (128 bits) in computer memory. It is intended for applications where it is necessary to emulate decimal rounding exactly, such as financial and tax computations.

**Unums** are a family of formats and arithmetic, similar to floating point, proposed by John L. Gustafson. They are designed as an alternative to the ubiquitous IEEE 754 floating-point standard and the latest version can be used as a drop-in replacement for programs which do not depend on specific features of IEEE 754.

In computing, **octuple precision** is a binary floating-point-based computer number format that occupies 32 bytes in computer memory. This 256-bit octuple precision is for applications requiring results in higher than quadruple precision. This format is rarely used and very few environments support it.

The **bfloat16** floating-point format is a computer number format occupying 16 bits in computer memory; it represents a wide dynamic range of numeric values by using a floating radix point. This format is a truncated (16-bit) version of the 32-bit IEEE 754 single-precision floating-point format (binary32) with the intent of accelerating machine learning and near-sensor computing. It preserves the approximate dynamic range of 32-bit floating-point numbers by retaining 8 exponent bits, but supports only an 8-bit precision rather than the 24-bit significand of the binary32 format. More so than single-precision 32-bit floating-point numbers, bfloat16 numbers are unsuitable for integer calculations, but this is not their intended use. Bfloat16 is used to reduce the storage requirements and increase the calculation speed of machine learning algorithms.

This page is based on this Wikipedia article

Text is available under the CC BY-SA 4.0 license; additional terms may apply.

Images, videos and audio are available under their respective licenses.

Text is available under the CC BY-SA 4.0 license; additional terms may apply.

Images, videos and audio are available under their respective licenses.