The IEEE Standard for Floating-Point Arithmetic (IEEE 754) is a technical standard for floating-point arithmetic originally 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 standard defines: arithmetic formats: sets of binary and decimal floating-point data, which consist of finite numbers (including signed zeros and subnormal numbers), infinities, and special "not a number" values (NaNs) interchange formats: encodings (bit strings) that may be used to exchange floating-point data in an efficient and compact form rounding rules: properties to be satisfied when rounding numbers during arithmetic and conversions operations: arithmetic and other operations (such as trigonometric functions) on arithmetic formats exception handling: indications of exceptional conditions (such as division by zero, overflow, etc.)
IEEE 754-2008, published in August 2008, includes nearly all of the original IEEE 754-1985 standard, plus the IEEE 854-1987 (Radix-Independent Floating-Point Arithmetic) standard. The current version, IEEE 754-2019, was published in July 2019. It is a minor revision of the previous version, incorporating mainly clarifications, defect fixes and new recommended operations.
History +Timeline of Floating-Point Arithmetic Standard Year Official Standard 1982 IEC 559:1982 1985 IEEE 754-1985 1987 IEEE 854-1987 1989 IEC 559:1989 2008 IEEE 754-2008 2011 ISO/IEC/IEEE 60559:2011 2019 IEEE 754-2019 2020 ISO/IEC 60559:2020 2029
The need for a floating-point standard arose from chaos in the business and scientific computing industry in the 1960s and 1970s. IBM used a hexadecimal floating-point format with seven bits always used for the exponent regardless of precision. CDC and Cray computers used ones' complement representation, which admits a value of +0 and −0. CDC 60-bit computers did not have full 60-bit adders, so integer arithmetic was limited to 48 bits of precision from the floating-point unit. Exception processing from divide-by-zero was different on different computers. Moving data between systems and even repeating the same calculations on different systems was often difficult.
The first IEEE standard for floating-point arithmetic, IEEE 754-1985, was published in 1985. It covered only binary floating-point arithmetic.
A new version, IEEE 754-2008, was published in August 2008, following a seven-year revision process, chaired by Dan Zuras and edited by Mike Cowlishaw. It replaced both IEEE 754-1985 (Binary Floating-Point Arithmetic) and IEEE 854-1987 (Radix-Independent Floating-Point Arithmetic) standards. The binary formats in the original standard are included in this new standard along with three new basic formats, one binary and two decimal. To conform to the current standard, an implementation must implement at least one of the basic formats as both an arithmetic format and an interchange format.
The international standard ISO/IEC/IEEE 60559:2011 (with content identical to IEEE 754-2008) has been approved for adoption through ISO/IEC JTC 1/SC 25 under the ISO/IEEE PSDO Agreement and published.
The current version, IEEE 754-2019 published in July 2019, is derived from and replaces IEEE 754-2008, following a revision process started in September 2015, chaired by David G. Hough and edited by Mike Cowlishaw. It incorporates mainly clarifications (e.g. totalOrder) and defect fixes (e.g. minNum), but also includes some new recommended operations (e.g. augmentedAddition).
The international standard ISO/IEC 60559:2020 (with content identical to IEEE 754-2019) has been approved for adoption through ISO/IEC JTC 1/SC 25 and published.
The next projected revision of the standard is in 2029.
Formats IEEE 754 defines a format as "a set of representations of numerical values and symbols, perhaps accompanied by an encoding"..
A floating-point format is specified by a base (also called radix) b, which is either 2 (binary) or 10 (decimal) in IEEE 754; a precision p; an exponent range from emin to emax, with emin = 1 − emax, or equivalently emin = − (emax − 1), for all IEEE 754 formats.
A format comprises Finite numbers, which can be described by three integers: s = a sign (zero or one), c = a significand (also called a coefficient or mantissa) having no more than p digits when written in base b (i.e., an integer in the range through 0 to bp − 1), and q = an exponent such that emin ≤ q + p − 1 ≤ emax. The numerical value of such a finite number is . Moreover, there are two zero values, called signed zeros: the sign bit specifies whether a zero is +0 (positive zero) or −0 (negative zero). Two infinities: +∞ and −∞. Two kinds of NaN (not-a-number): a quiet NaN (qNaN) and a signaling NaN (sNaN).
For example, if b = 10, p = 7, and emax = 96, then emin = −95, the significand satisfies 0 ≤ c ≤ , and the exponent satisfies . Consequently, the smallest non-zero positive number that can be represented is 1×10−101, and the largest is 9999999×1090 (9.999999×1096), so the full range of numbers is −9.999999×1096 through 9.999999×1096. The numbers −b1−emax and b1−emax (here, −1×10−95 and 1×10−95) are the smallest (in magnitude) normal numbers; non-zero numbers between these smallest numbers are called subnormal numbers.
Representation and encoding in memory Some numbers may have several possible floating-point representations. For instance, if b = 10, and p = 7, then −12.345 can be represented by −12345×10−3, −123450×10−4, and −1234500×10−5. However, for most operations, such as arithmetic operations, the result (value) does not depend on the representation of the inputs.
For the decimal formats, any representation is valid, and the set of these representations is called a cohort. When a result can have several representations, the standard specifies which member of the cohort is chosen.
For the binary formats, the representation is made unique. Most floating point numbers, those with absolute value larger than 2, are called normal. They have a significand which is between 1 (included) and 2 (excluded), which thus always has a leading 1 bit; this bit is not explicitly stored in the representation, but is left implicit; this rule is called leading bit convention, implicit bit convention, or hidden bit convention, and it allows the format to have an extra bit of precision. A normal number's exponent has a "bias" added to it, and the resulting biased exponent is always a positive integer. Numbers smaller than 2 are called subnormal numbers. These numbers are represented by the biased exponent 0, which stands for emin. For subnormal numbers, there is no longer an implicit leading 1 bit, and the significand lies between 0 and 1.
Due to the possibility of multiple encodings (at least in formats called interchange formats), a NaN may carry other information: a sign bit (which has no meaning, but may be used by some operations) and a payload, which is intended for diagnostic information indicating the source of the NaN (but the payload may have other uses, such as NaN-boxing).
Basic and interchange formats
The standard defines five basic formats that are named for their numeric base and the number of bits used in their interchange encoding. There are three binary floating-point basic formats (encoded with 32, 64 or 128 bits) and two decimal floating-point basic formats (encoded with 64 or 128 bits). The binary32 and binary64 formats are the single and double formats of IEEE 754-1985 respectively. A conforming implementation must fully implement at least one of the basic formats.
The standard specifies interchange formats at a range of widths, including the basic formats, to support the exchange of floating-point data between implementations. The exponent and significand field sizes for each width are determined by defined rules based on width.. The following table summarizes some of the possible interchange formats (including the basic formats). Significand Exponent Properties Name Common name scope=col scope=col scope=col style=max-width:8em Min Max MAXVAL MINVAL>0(normal) MINVAL>0(subnormal) Notesbinary16 Half precision 2 11 3.31 −14 15 65504 6.10 5.96 Interchange binary32 Single precision 2 24 7.22 −126 127 3.40 1.18 1.40 Basic binary64 Double precision 2 53 15.95 −1022 1023 1.80 2.23 4.94 Basic binary128 Quadruple precision 2 113 34.02 −16382 16383 1.19 3.36 6.48 Basic binary256 Octuple precision 2 237 71.34 −262142 262143 1.61 2.48 2.25 Interchange decimal32 10 7 7 −95 96 1.0 1 1 Interchange decimal64 10 16 16 −383 384 1.0 1 1 Basic decimal128 10 34 34 −6143 6144 1.0 1 1 Basic
In the table above, integer values are exact, whereas values in decimal notation (e.g. 1.0) are rounded values. The minimum exponents listed are for normal numbers; the special subnormal number representation allows even smaller (in magnitude) numbers to be represented with some loss of precision. For example, the smallest positive number that can be represented in binary64 is 2−1074; contributions to the −1074 figure include the emin value −1022 and all but one of the 53 significand bits (2−1022 − (53 − 1) = 2−1074).
Decimal digits is the precision of the format expressed in terms of an equivalent number of decimal digits. It is computed as digits × log10 base. E.g. binary128 has approximately the same precision as a 34 digit decimal number.
log10 MAXVAL is a measure of the range of the encoding. Its integer part is the largest exponent shown on the output of a value in scientific notation with one leading digit in the significand before the decimal point (e.g. 1.698 is near the largest value in binary32, 9.999999 is the largest value in decimal32).
The binary32 (single) and binary64 (double) formats are two of the most common formats used today. The figure below shows the absolute precision for both formats over a range of values. This figure can be used to select an appropriate format given the expected value of a number and the required precision.
An example of a layout for 32-bit floating point is
and the 64 bit layout is similar.
Extended and extendable precision formats The standard specifies optional extended and extendable precision formats, which provide greater precision than the basic formats.. An extended precision format extends a basic format by using more precision and more exponent range. An extendable precision format allows the user to specify the precision and exponent range. An implementation may use whatever internal representation it chooses for such formats; all that needs to be defined are its parameters (b, p, and emax). These parameters uniquely describe the set of finite numbers (combinations of sign, significand, and exponent for the given radix) that it can represent.
The standard recommends that language standards provide a method of specifying p and emax for each supported base b. states: "Language standards should define mechanisms supporting extendable precision for each supported radix." The standard recommends that language standards and implementations support an extended format which has a greater precision than the largest basic format supported for each radix b. states: "Language standards or implementations should support an extended precision format that extends the widest basic format that is supported in that radix." For an extended format with a precision between two basic formats the exponent range must be as great as that of the next wider basic format. So for instance a 64-bit extended precision binary number must have an 'emax' of at least 16383. The x87 80-bit extended format meets this requirement.