Search topics and sections

Floating-point arithmetic is by far the most common way computers calculate with real numbers, such as 3.14159 or 0.000002.[1] Each number is stored as a significand (a fixed number of digits) times a base raised to a power, much as scientific notation writes 6.02×10236.02 \times 10^{23}. The power can change, so the position of the point "floats" and one format can hold both very large and very small numbers.[1]

Only a limited set of numbers fits in a fixed number of bits, so most results must be rounded to a nearby number in that set. The rounded result is usually close to the true value but not exactly equal to it.[1] Since at least 2000, almost all computers have used the binary arithmetic of the IEEE 754 standard, which fixes exactly how the basic operations must round.[1][2]

Representing numbers

Significand, base, and exponent

A floating-point format is set by four integers:[3]

  • the base β\beta, almost always 2;
  • the precision pp, the number of digits in the significand;
  • the smallest exponent emin⁡e_{\min};
  • the largest exponent emax⁡e_{\max}.

A number in the format has the form

x=± d0.d1d2⋯dp−1×βex = \pm\, d_0.d_1 d_2 \cdots d_{p-1} \times \beta^{e}

Here each digit did_i is an integer with 0≤di<β0 \le d_i < \beta, the digit string d0.d1⋯dp−1d_0.d_1 \cdots d_{p-1} is the significand, and the exponent ee is an integer with emin⁡≤e≤emax⁡e_{\min} \le e \le e_{\max}.[1][4] IEEE 754 sets emin⁡=1−emax⁡e_{\min} = 1 - e_{\max} for all its formats.[4]

A number may fit exactly in one base but not in another. The number 0.1 is a good example, because 1/10 has an endless repeating expansion in binary:[1]

Base β\beta Precision pp 0.1 stored as Exact?
10 3 1.00×10−11.00 \times 10^{-1} Yes
2 24 1.100110011001100110011012×2−41.10011001100110011001101_2 \times 2^{-4} No, only approximate

Normalized numbers and the hidden bit

A number is normalized when its leading digit d0d_0 is not zero, which makes its representation unique.[1] In base 2 the leading digit of a normalized number is always 1, so formats leave it out of storage and gain one bit of precision. This implied digit is called the hidden bit, which is why single precision stores 23 significand bits but has p=24p = 24.[1]

Requiring normalization makes zero impossible to write, so zero gets a reserved encoding (see IEEE 754 formats).[1]

The hidden-bit idea appears to have been first published by I. Bennett Goldberg in 1967, although Donald Knuth credits it to Konrad Zuse.[1]

Spacing between numbers

Floating-point numbers are not evenly spaced. In binary, the gap between neighbors doubles at every power of 2, so the relative spacing stays roughly constant, varying by up to a factor of β\beta.[3]

Positive numbers of a toy binary floating-point format with precision 3 gap (no normalized numbers) 0 0.25 0.5 0.75 1 0 0.5 1 2 4 7 0.25 1/16 1/8 1/4 1/2 1
Every positive normalized number of a toy binary format with precision p=3p = 3 and exponents from −2-2 to 22, with an enlarged view of 00 to 11 above. Each group between consecutive powers of two holds 4 numbers, and the spacing doubles at each power of two, from 1/161/16 up to 11.

The effect is large in real formats. In IEEE single precision the next number after 1 is about 1.0000001, a gap of about 1.19×10−71.19 \times 10^{-7}. The next number after 102010^{20} is about 8.8×10128.8 \times 10^{12} away.[5]

Floating point versus fixed point

In fixed-point arithmetic, another form of computer arithmetic, the exponent never changes. The two approaches compare as follows:[3][1]

Fixed point Floating point
Spacing of numbers Equal everywhere Gap doubles at each power of 2
Range and accuracy Scale factors must be chosen by hand to cover the range of values Wide range at a roughly constant relative accuracy
Common uses Special-purpose devices such as FPGAs, and embedded systems By far the most widely used representation of real numbers

Rounding

Rounding modes

When the exact result of an operation is not in the format, it must be rounded to the next larger or next smaller floating-point number.[6] IEEE 754-1985 defined four rounding modes:[5]

  • Round to nearest, with ties going to the neighbor whose last bit is 0 ("ties to even"). This is the default.[1]
  • Round toward +∞+\infty (up).
  • Round toward −∞-\infty (down).
  • Round toward zero, also called truncation or chopping.

The 2008 revision added a fifth mode, round to nearest with ties away from zero. Implementations of the decimal formats must provide it, but binary implementations need not.[4][7]

IEEE rounding modes for positive and negative xpositive xnearesttoward +∞toward −∞toward 0axmidpointb0 this waynegative xnearesttoward +∞toward −∞toward 0−bxmidpoint−a0 this way
Four IEEE rounding modes applied to a value xx that lies between two adjacent floating-point numbers. Round to nearest picks the closer neighbor, and round toward zero matches rounding down when x>0x > 0 and rounding up when x<0x < 0.

The two modes toward infinity support interval arithmetic, which traps the exact result between a value rounded down and a value rounded up.[1][6]

Ties to even avoids slow drift. Goldberg's decimal example uses p=3p = 3 and starts from 1.00, then repeatedly adds 0.555 and subtracts it again. Round-half-up, which sends every halfway case up to the next value, behaves differently from ties to even:[1]

Rule for halfway cases Values after repeated round trips Keeps changing?
Round half up 1.00, 1.01, 1.02, and so on up to 9.45 Yes, until it reaches 9.45
Ties to even 1.00, 1.00, 1.00, ... No

Reiser and Knuth showed in 1975 that with ties to even such a sequence never changes after its first step.[1]

Measuring rounding error

Two measures of rounding error are common:

  • The unit in the last place (ulp) of a number is the value of its last significand bit, which is the gap to its neighbor.[5]
  • The relative error is the difference between the computed and exact values divided by the exact value.[1]

Round to nearest gives an error of at most half an ulp.[5] This bounds the relative error by the unit roundoff

u=2−pu = 2^{-p}

for binary formats, or u=12β1−pu = \tfrac{1}{2}\beta^{1-p} in base β\beta.[3][1] Suppose there is no overflow (a result too large for the format) and no underflow (a result too small to be stored as a normalized number). Then each correctly rounded basic operation satisfies

fl(xopy)=(xopy)(1+δ),∣δ∣≤u\mathrm{fl}(x \mathbin{\mathrm{op}} y) = (x \mathbin{\mathrm{op}} y)(1 + \delta), \qquad |\delta| \le u

Here fl\mathrm{fl} marks the computed result, op is ++, −-, ×\times or ÷\div, and the same bound holds for square root.[3][6] Results smaller than the smallest normalized number (see Subnormal numbers) do not satisfy this bound.[5] Most error analysis in numerical analysis is built from it.[1]

Machine epsilon, ε=21−p\varepsilon = 2^{1-p}, is the gap between 1 and the next larger number, so ε=2u\varepsilon = 2u.[3]

Machine epsilon is 2−23≈1.19×10−72^{-23} \approx 1.19 \times 10^{-7} in single precision and 2−52≈2.22×10−162^{-52} \approx 2.22 \times 10^{-16} in double precision.[5]

Usage of the term varies. Goldberg, for example, uses "machine epsilon" for the bound called uu here.[1]

How the basic operations work

Addition and subtraction

An operand is a number used as input to an operation. Adding two floating-point operands takes three steps:[1]

  1. Shift the significand of the smaller number right until both exponents match.
  2. Add (or subtract) the aligned significands exactly.
  3. Round the result back to pp digits, adjusting the exponent if the leading digit moved.
Floating-point addition with three significant digits Align exponents Add exactly Round to 3 digits 1.23 × 102 1.23 × 102 4.56 × 100 0.0456 × 102 Shift right 2 1.23 + 0.0456 = 1.2756 1.2756 × 102 1.28 × 102 = 128 exact sum 127.56
Floating-point addition in decimal with precision p=3p = 3. The smaller operand 4.56×1004.56 \times 10^0 is shifted right two places to 0.0456×1020.0456 \times 10^2, the significands are added exactly to give 1.2756×1021.2756 \times 10^2, and the result is rounded to 1.28×102=1281.28 \times 10^2 = 128.

Keeping every shifted-out digit is costly, but dropping them all can be disastrous. With p=3p = 3 and no extra digits, 10.1−9.9310.1 - 9.93 becomes 1.01×101−0.99×101=0.21.01 \times 10^1 - 0.99 \times 10^1 = 0.2 instead of 0.17, wrong in every digit.[1] One extra digit, called a guard digit, makes this result exact and keeps the relative error of any sum or difference below 2u2u.[1]

IBM thought guard digits important enough that in 1968 it added one to the double-precision format of the System/360 and updated the machines already in the field.[1]

Correct rounding

IEEE 754 requires addition, subtraction, multiplication, division, and square root to be correctly rounded. Each result must equal the exact answer rounded to the format, as if it had been computed to infinite precision first.[6] Two guard digits plus one extra bit are enough to get correctly rounded sums and differences at little extra cost, and a multiplier must form all 2p2p digits of the product before rounding.[1]

Correct rounding makes results predictable and provable. For the operations the standard specifies, numerical results and exceptions (special conditions an operation reports, such as an invalid operation or overflow) are fixed by the input values, the sequence of operations, and the output formats.[8] This precise definition also makes it possible to prove error bounds for floating-point programs.[1]

The exponential, logarithm, and sine functions are not required to be correctly rounded. The reason is the table maker's dilemma: no one can say in advance how many digits must be computed to decide which way a value rounds.[1] The current standard recommends correctly rounded versions of these functions but does not require them.[6]

Fused multiply-add

A fused multiply-add (FMA) computes x×y+zx \times y + z with one rounding instead of two. Its result therefore satisfies the same ∣δ∣≤u|\delta| \le u bound as a single operation.[6]

Hardware that has FMA usually runs it at the same speed as one addition or multiplication.[6]

A compiler may or may not use FMA, so the same program can give different results on different systems, or even on the same system.[1]

IEEE 754 formats

Bit layout

A binary IEEE 754 number is stored as three fields: a sign bit, an exponent field, and a fraction holding the significand bits after the hidden bit.[5] The exponent field stores the true exponent plus a fixed offset called the exponent bias, so the field is never negative.[1] The two most common formats use these field sizes:[5][1]

Format Sign bits Exponent bits Fraction bits Bias
Single precision 1 8 23 127
Double precision 1 11 52 1023

A normal single-precision number with sign bit ss, exponent field EE, and fraction ff has the value

x=(−1)s×2E−127×1.fx = (-1)^s \times 2^{E-127} \times 1.f

Here 1.f1.f is the binary significand formed by placing the hidden 1 before the fraction bits, and EE runs from 1 to 254.[5] For example, 1.0 is stored as hexadecimal 3F800000, which is sign 0, exponent field 127, and fraction 0.[5]

IEEE 754 binary32 encoding of -6.5 11000000110100000000000000000000 31 30 23 22 0 exponent (8 bits) fraction (23 bits) sign (1 bit) hex C0D00000 exponent field 10000001 = 129; 129 − 127 = 2 significand 1.101 (binary) = 1.625 (hidden 1 not stored) value = −1.625 × 2² = −6.5
The IEEE 754 single-precision (binary32) encoding of −6.5-6.5 is 1 sign bit, an 8-bit exponent field 10000001=12910000001 = 129 with bias 127, and a 23-bit fraction 101101 followed by zeros. Together they give −1.625×22=−6.5-1.625 \times 2^{2} = -6.5, or hex C0D00000.

Reserved exponent values

The smallest and largest exponent fields are kept for special values, including NaN ("not a number"), which marks an invalid or undefined result. For single precision the encodings are:[5][6]

Exponent field EE Fraction ff Value
1 to 254 any (−1)s×2E−127×1.f(-1)^s \times 2^{E-127} \times 1.f (normal number)
0 nonzero (−1)s×2−126×0.f(-1)^s \times 2^{-126} \times 0.f (subnormal number)
0 zero ±0\pm 0
255 zero ±∞\pm\infty
255 nonzero NaN

Double precision follows the same pattern, with bias 1023, exponent field 2047 for infinities and NaNs, and 2−1022×0.f2^{-1022} \times 0.f for subnormal numbers.[5]

Common binary formats

IEEE 754-2019 defines five basic formats: three binary formats of 32, 64, and 128 bits, and two decimal formats of 64 and 128 bits.[4] Single and double precision were in the 1985 standard. Half precision and quadruple precision were added in 2008, with half precision defined only as a storage format, though it is widely used for computation.[6]

The table also includes bfloat16, a 16-bit format outside IEEE 754 with 8 exponent bits.[9]

Format Bits (sign, exponent, fraction) Precision pp Largest finite value (about) Unit roundoff uu (about)
binary16 (half) 1, 5, 10 11 6.55×1046.55 \times 10^{4} 4.88×10−44.88 \times 10^{-4}
bfloat16 (not IEEE) 1, 8, 7 8 3.39×10383.39 \times 10^{38} 3.91×10−33.91 \times 10^{-3}
binary32 (single) 1, 8, 23 24 3.40×10383.40 \times 10^{38} 5.96×10−85.96 \times 10^{-8}
binary64 (double) 1, 11, 52 53 1.80×103081.80 \times 10^{308} 1.11×10−161.11 \times 10^{-16}
binary128 (quadruple) 1, 15, 112 113 1.19×1049321.19 \times 10^{4932} 9.63×10−359.63 \times 10^{-35}

The binary16, bfloat16, and binary32 rows come from Higham.[9] The binary64 and binary128 rows come from Sun's guide, with u=2−pu = 2^{-p}.[5]

Other formats

  • Extended precision formats give intermediate results extra bits. IEEE 754-1985 required a double extended format to have at least 64 significand bits and at least 79 bits in total, and x86 processors store theirs in 80 bits with an explicit leading bit.[5] According to William Kahan, the Intel 8087 used 64 significand bits because that was the widest carry it could pass along without lengthening its clock cycle.[1]
  • Decimal floating point uses β=10\beta = 10, which suits calculators that show every result in decimal.[1] It began as the separate IEEE 854 standard in 1987 and joined IEEE 754 in 2008.[6] Decimal arithmetic in software, such as the decimal module of Python, is used for accounting.[2]
  • Bfloat16 keeps the 8 exponent bits of single precision but only an 8-bit significand. It was designed for neural networks, which are more sensitive to the size of the exponent than to the precision of the significand.[10]
  • TensorFloat-32 (TF32) is a mode of the tensor cores, specialized units that speed up matrix multiplications, in NVIDIA Ampere GPUs. It uses 1 sign bit, 8 exponent bits, and 10 fraction bits.[11] With the hidden bit its precision is p=11p = 11, the same as half precision, in a 19-bit format.[12]
Floating-point format bit layouts Sign Exponent Fraction binary16 (half) bfloat16 TensorFloat-32 binary32 (single) binary64 (double) 16 bits 16 bits 19 bits 32 bits 64 bits 1 5 10 1 8 7 1 8 10 1 8 23 1 11 52
Bit layouts of five floating-point formats, drawn to scale. bfloat16, TensorFloat-32 and binary32 all have 8 exponent bits, and TensorFloat-32 has the same 10 fraction bits as binary16.

Special values and exceptions

IEEE arithmetic is a closed system: thanks to infinities and NaN, every operation returns a value in the system.[6]

Infinity

Infinities and overflow behave as follows:[1]

  • Overflow under round to nearest: a result too large for the format becomes ±∞\pm\infty instead of the largest finite number.
  • Positive overflow under round toward zero or toward −∞-\infty: the result is the largest finite number instead.
  • A nonzero number divided by zero: the result is ±∞\pm\infty, with the sign set by the usual rules.

Arithmetic with infinity follows limits, so ∞+∞=∞\infty + \infty = \infty and a finite number divided by ∞\infty is 0.[6] For example, 1+1/x1 + 1/x evaluates to 1 when x=∞x = \infty.[6]

Signed zero

IEEE formats have both +0+0 and −0-0, called signed zero. The two compare as equal, but they behave differently in some operations: 1/(+0)=+∞1/(+0) = +\infty while 1/(−0)=−∞1/(-0) = -\infty, because the sign of the infinite result follows the signs of both operands in the usual way.[1]

Keeping the sign lets an underflowed negative number stay negative, so a function such as log can tell it apart from a true zero.[1]

NaN

A NaN is the result of invalid operations such as these:[6]

  • 0/00/0
  • 0×∞0 \times \infty
  • ∞/∞\infty/\infty
  • (+∞)+(−∞)(+\infty) + (-\infty)
  • −1\sqrt{-1}

Any arithmetic operation with a NaN operand returns a NaN.[6] This lets a calculation continue, for example when a root finder tries a point outside the function's domain.[1]

A NaN never compares equal to anything, including itself, so x≠xx \ne x is true only when xx is a NaN.[1]

Signaling NaNs, a second kind that raises the invalid-operation exception when used, entered the standard as a compromise during drafting.[13][1]

Subnormal numbers

Without special handling, there is a gap between 0 and the smallest normalized number, and results that fall into it are flushed to zero.[1] Subnormal numbers fill the gap. They have exponent emin⁡e_{\min} and leading digit 0, and they share the spacing of the smallest normalized numbers.[3][1]

Returning subnormal numbers instead of zero is called gradual underflow.[5]

Flush to zero versus gradual underflow Gap: tiny results become 0 Flush to zero 0 0.25 0.5 Spacing 1/16 Gradual underflow 0 Subnormal 0.25 0.5
A toy binary format with precision 3 and smallest normalized number 0.25. With flush to zero, nothing can be represented between 0 and 0.25. With gradual underflow, subnormal numbers fill that gap, so every value from 0 to 0.5 is spaced 1/16=0.06251/16 = 0.0625 apart.

Gradual underflow keeps useful guarantees:

  • If x≠yx \ne y, then the computed x−yx - y is not zero.[1][5]
  • An underflowed result never loses more accuracy than ordinary rounding error causes.[5]

Subnormal numbers also have costs:

  • They have fewer significant bits than normal numbers.[5]
  • Some hardware traps on them and handles them in software, so programs that underflow often can run noticeably slower.[1]

Before IEEE 754, flushing to zero was the default on most mainframes, the large central computers of that era.[5]

Exceptions and flags

IEEE 754 defines five exceptions. By default each one delivers a result and lets the program continue:[1][6]

Exception Typical cause Default result
Invalid operation 0/00/0, −1\sqrt{-1}, ∞−∞\infty - \infty NaN
Division by zero nonzero number divided by 0 ±∞\pm\infty
Overflow result too large for the format ±∞\pm\infty or the largest finite number, depending on rounding mode
Underflow result too small to be normal a subnormal number or 0
Inexact result not exactly representable, such as 1/31/3 the rounded result

Each exception also sets a status flag, a bit that records that the exception has occurred. Flags are "sticky": once set, they stay set until the program clears them.[1]

The 1985 standard also strongly recommended that systems let users install trap handlers that run when an exception occurs.[1]

Where floating point differs from real arithmetic

Decimal fractions are inexact

Most decimal fractions have no exact binary form.[2] In double precision, 0.1 is stored as 3602879701896397/2553602879701896397 / 2^{55}, which equals 0.1000000000000000055511151231257827021181583404541015625.[2] As a result, adding 0.1 ten times in Python does not give exactly 1.0:[2]

>>> 0.1 + 0.1 + 0.1 + 0.1 + 0.1 + 0.1 + 0.1 + 0.1 + 0.1 + 0.1 == 1.0
False

To print a binary number in decimal and read it back unchanged, 9 significant digits are enough for single precision and 17 for double.[1][4]

Order of operations matters

Floating-point addition is commutative, meaning x+y=y+xx + y = y + x always holds, but it is not associative.[1] With x=1030x = 10^{30}, y=−1030y = -10^{30}, and z=1z = 1, the sum (x+y)+z(x + y) + z is 1 but x+(y+z)x + (y + z) is 0.[1] Algorithms that depend on a fixed order break if a compiler regroups terms.[1]

Cancellation

Subtracting two nearly equal numbers cancels their matching leading digits. Catastrophic cancellation happens when the operands already carry rounding errors: the subtraction itself is exact, but it exposes the earlier errors.[1] With β=10\beta = 10, p=3p = 3, b=3.34b = 3.34, a=1.22a = 1.22, and c=2.28c = 2.28, the computed b2−4acb^2 - 4ac is 0.1, while the exact value is 0.0292.[1]

Catastrophic cancellation with 3-digit decimal arithmetic Inputs: b = 3.34, a = 1.22, c = 2.28 Exact Rounded b² 4ac 11.1556 11.1264 1 1 . 2 − 1 1 . 1 0 . 1 Cancelling digits Comes from rounding error Exact b² − 4ac = 0.0292
Catastrophic cancellation with 3-digit decimal precision, using b=3.34b = 3.34, a=1.22a = 1.22, c=2.28c = 2.28. Rounding b2=11.1556b^2 = 11.1556 to 11.211.2 and 4ac=11.12644ac = 11.1264 to 11.111.1 makes the leading digits 11.11. cancel. The computed 0.10.1 comes from rounding error, while the exact b2−4acb^2 - 4ac is 0.02920.0292.

Benign cancellation happens when the operands are exact, and then the subtraction is accurate.[1] The Sterbenz lemma makes this precise. If x≥0x \ge 0, y≥0y \ge 0, and x/2≤y≤2xx/2 \le y \le 2x, then fl(x−y)=x−y\mathrm{fl}(x - y) = x - y exactly.[14][1]

Testing for equality

Two expressions that are equal in algebra can produce different floating-point results, so exact equality tests often fail. Treating numbers as equal when they differ by less than a tolerance is not a full cure. It leaves open how to choose the tolerance, and the relation is not transitive: aa close to bb and bb close to cc does not make aa close to cc.[1]

Python provides math.isclose for such tolerance-based tests.[2]

Compilers and hidden precision

An optimizer, the part of a compiler that rewrites code to improve it, can break correct floating-point code if it applies the rules of real numbers. For example, it can simplify to zero the correction term of compensated summation, a method that tracks and corrects rounding errors in long sums.[1]

Languages such as C allow expressions to be evaluated in a format wider than their type. On x86 systems that compute in extended precision, q = 3.0/7.0 followed by the test q == 3.0/7.0 can come out false.[1]

A separate problem is double rounding. Rounding first to extended precision and then to double can give a different answer from a single rounding to double.[1]

Techniques for accurate results

Rewriting formulas

A formula with catastrophic cancellation can often be rearranged. For the quadratic formula with real roots (a≠0a \ne 0, b2≥4acb^2 \ge 4ac), the root

r1=−b+b2−4ac2a=2c−b−b2−4acr_1 = \frac{-b + \sqrt{b^2 - 4ac}}{2a} = \frac{2c}{-b - \sqrt{b^2 - 4ac}}

can be written either way whenever the denominator −b−b2−4ac-b - \sqrt{b^2 - 4ac} is not zero, which always holds when b>0b > 0. The first form suffers cancellation when b>0b > 0 and b2≫acb^2 \gg ac, so the second form should be used. The other root r2=(−b−b2−4ac)/(2a)r_2 = (-b - \sqrt{b^2 - 4ac})/(2a) has no such cancellation, and for b<0b < 0 the roles swap.[1]

Similarly, x2−y2x^2 - y^2 is more accurate when computed as (x−y)(x+y)(x - y)(x + y), which replaces a catastrophic cancellation with a benign one.[1]

Extra and mixed precision

A short burst of higher precision often protects a whole calculation. Computing b2−4acb^2 - 4ac in double precision when aa, bb, and cc are single precision keeps every single-precision bit of the roots.[1]

Iterative refinement improves a computed solution x(1)x^{(1)} of a linear system Ax=bAx = b by repeating three steps:[1]

  1. Compute the residual r=Ax(1)−br = Ax^{(1)} - b, the difference between the computed Ax(1)Ax^{(1)} and the target bb.
  2. Solve Ay=rAy = r.
  3. Update x(2)=x(1)−yx^{(2)} = x^{(1)} - y.

The residual is a difference of nearby inexact numbers, so the method helps little unless rr is computed in higher precision.[1] Mixing precisions in this way is called mixed-precision arithmetic.

Compensated summation

The Kahan summation algorithm tracks the low-order bits lost in each addition and feeds them back into the next one:[1]

def kahan_sum(xs):
    s = xs[0]
    c = 0.0
    for x in xs[1:]:
        y = x - c        # apply the correction from the last step
        t = s + y        # low-order bits of y are lost here
        c = (t - s) - y  # recover those lost bits
        s = t
    return s

The computed sum equals the exact sum of terms that are each changed by a relative amount of at most about 2u2u. Plain left-to-right addition of nn terms can change terms by up to about nunu.[1]

Error-free transformations

The rounding error of a single operation can often be computed exactly with a few more floating-point operations. In binary with correct rounding to nearest, if ∣x∣≥∣y∣|x| \ge |y| and no overflow occurs, then

s=fl(x+y),e=fl(fl(x−s)+y),x+y=s+e exactlys = \mathrm{fl}(x + y), \qquad e = \mathrm{fl}\big(\mathrm{fl}(x - s) + y\big), \qquad x + y = s + e \text{ exactly}

This formula is due to Dekker (1971).[1] Related algorithms such as 2Sum are called error-free transformations. IEEE 754-2019 added augmented operations that return both the rounded result of ++, −-, or ×\times and its exact error.[6]

Bounding or removing the error

  • Interval arithmetic uses the directed rounding modes to compute an interval certain to contain the exact result. Because such intervals often grow large, it works best together with multiple precision, redoing the calculation at higher precision until the interval is small enough.[1]
  • Arbitrary-precision arithmetic stores a very long significand in an array of words, or represents a number as a list of ordinary floating-point numbers whose sum, not yet added together, is the value.[1]

History

Early machines

Konrad Zuse's Z3, completed in 1941, used 2,300 relays, performed binary floating-point arithmetic, and had a 22-bit word length.[15]

For decades afterward, each manufacturer had its own floating-point arithmetic. Kahan analyzed these commercial arithmetics and estimated how much their unexpected behavior raised the cost of reliable, portable numerical software.[13] Examples of the differences:

  • IBM's System/370 used base 16, which can lose up to 3 bits of effective precision compared with base 2.[1]
  • Some machines, such as Cray systems, had no guard digit.[1]
  • Until the 1980s, almost all computers flushed underflows to zero.[13]

The IEEE 754 standard

The standard grew out of Intel's work on a floating-point coprocessor. Intel manager John Palmer persuaded the company it needed an arithmetic standard and brought in Kahan as a consultant.[13] The DEC VAX formats competed with Kahan's draft, and the main dispute was over gradual underflow.[13]

  • 1976: Intel begins designing a floating-point coprocessor for its 8086/8088 processors, which became the 8087.[13]
  • 1977: After an IEEE p754 meeting, Kahan, his student Jerome Coonen, and visiting professor Harold Stone write the "K-C-S" draft, which p754 later adopts.[13]
  • 1981: At a p754 meeting in Boston, G. W. Stewart, whom DEC had asked to assess gradual underflow, reports that it is the right choice.[13]
  • 1984: Intel, AMD, Apple, IBM, Motorola, and others have already implemented the draft.[13]
  • 1985: IEEE 754-1985 is published.[6]
  • 1987: The separate IEEE 854 standard for decimal arithmetic is published.[6]
  • 1989: Kahan receives the Turing Award, in particular for his work on IEEE 754 and 854.[6]
  • 2008: A revision merges decimal arithmetic into IEEE 754 and adds half and quadruple precision.[6]
  • 2019: A revision adds augmented arithmetic operations.[6]

References

  1. What Every Computer Scientist Should Know About Floating-Point Arithmetic, David Goldberg, ACM Computing Surveys (edited reprint by Sun Microsystems), 1991.
  2. Floating-Point Arithmetic: Issues and Limitations, Python Software Foundation, 2025.
  3. What Is Floating-Point Arithmetic?, Nick Higham, 2020.
  4. IEEE Std 754-2019, IEEE Standard for Floating-Point Arithmetic, IEEE, 2019.
  5. IEEE Arithmetic (Numerical Computation Guide, Chapter 2), Sun Microsystems, 2000.
  6. What Is IEEE Standard Arithmetic?, Nick Higham, 2020.
  7. Intel IEEE 754-2008 Binary Floating-Point Conformance Library, Intel, 2025.
  8. IEEE 754-2019: IEEE Standard for Floating-Point Arithmetic, IEEE Standards Association, 2019.
  9. Half Precision Arithmetic: fp16 Versus bfloat16, Nick Higham, 2018.
  10. What Is Bfloat16 Arithmetic?, Nick Higham, 2020.
  11. Accelerating AI Training with NVIDIA TF32 Tensor Cores, NVIDIA, 2020.
  12. Numerical Behavior of NVIDIA Tensor Cores, Massimiliano Fasi, Nicholas J. Higham, Mantas Mikaitis, and Srikara Pranesh, PeerJ Computer Science, 2021.
  13. An Interview with the Old Man of Floating-Point, Charles Severance, 1998.
  14. On Automatically Proving the Correctness of math.h Implementations, Proceedings of the ACM on Programming Languages (POPL), 2018.
  15. 1941: Timeline of Computer History, Computer History Museum.

Figure