Skip to content

Rounding error

Why finite-precision arithmetic can lose a small contribution, change a sum when its order changes, and require a numerical error budget.

Rounding error is the difference between an exact numerical value and the representable value selected by a rounding rule. In floating-point arithmetic, it can enter when an input is stored and when an arithmetic result is rounded back into the working format. The latter is often called roundoff error.

A risk calculation can contain millions of operations, yet its final answer may depend on a small residual. Tiny errors relative to the large intermediate values can matter relative to that residual. The useful question is therefore how rounding affects the quantity being reported, rather than how many digits the screen displays.

One addition can erase a contribution

Consider three synthetic, dimensionless inputs, all exactly representable in IEEE binary64:

a=1016,b=−1016,c=1.a=10^{16},\qquad b=-10^{16},\qquad c=1.

Their exact sum is 11. Suppose every addition rounds its result to binary64 using round to nearest, with halfway cases resolved by choosing the value whose significand has an even final bit. Changing the parentheses changes the answer:

EvaluationFirst computed additionFinal result
(a+b)+c(a+b)+ca+b=0a+b=0 exactly11
a+(b+c)a+(b+c)b+cb+c rounds back to bb00
Near bb, adjacent representable numbers are 22 units apart. The exact intermediate b+c=−9,999,999,999,999,999b+c=-9{,}999{,}999{,}999{,}999{,}999 is halfway between bb and b+2b+2. The ties-to-even rule selects bb. Adding aa then cancels bb exactly, but the contribution from cc has already disappeared. Floating-point addition is not associative.
At b equal to minus 10 to the power 16, binary64 floats are two units apart. The exact b plus 1 is halfway and rounds back to b. For a equal to 10 to the power 16, (a+b)+1 gives 1, but a+(b+1) gives 0.
At b equal to minus 10 to the power 16, binary64 floats are two units apart. The exact b plus 1 is halfway and rounds back to b. For a equal to 10 to the power 16, (a+b)+1 gives 1, but a+(b+1) gives 0.
Original synthetic, dimensionless binary64 example under round to nearest, ties to even. The axis uses offsets from bb; its spacing is 22. The exact integer sum is 11.
The second order has absolute error 11 and relative error 11, or 100%100\%, against the exact final sum. This does not mean that one addition incurred a 100%100\% relative error: rounding b+cb+c introduced an error of just −1-1 against a magnitude close to 101610^{16}. Subsequent cancellation exposed it. Catastrophic cancellation explains why errors on large operands can dominate their small difference.

These extreme offsets illustrate a mechanism; they are not portfolio values or market quotes. Real financial calculations need an error assessment at their actual scales.

A local bound is not a final-answer guarantee

For correctly rounded basic arithmetic on stored binary64 operands, with a nonzero normal exact result and no overflow or underflow, the standard model is

fl⁡(x∘y)=(x∘y)(1+δ),∣δ∣≤u,u=2−53≈1.11×10−16,\operatorname{fl}(x\circ y)=(x\circ y)(1+\delta), \qquad \lvert\delta\rvert\le u, \qquad u=2^{-53}\approx1.11\times10^{-16},
where ∘\circ is addition, subtraction, multiplication or division, with a valid divisor. Some operations are exact, so δ\delta can be zero. The model compares one computed operation with the exact operation on its stored operands, which may already carry errors. Zero results need separate interpretation, and the relative bound is not a blanket guarantee for subnormal results or exceptional operations.
Here uu is the unit roundoff. Using the spacing convention, machine epsilon is instead
ε=2−52≈2.22×10−16,\varepsilon=2^{-52}\approx2.22\times10^{-16},

the gap from 11 to the next larger binary64 number. Terminology varies between texts, so check which convention a bound uses. Neither number is a universal absolute tolerance: floating-point spacing changes with magnitude.

Keep the error sources separate

SourceWhat is being approximated?Would exact arithmetic remove it?
Input representation errorA supplied value, such as decimal 0.10.1, is stored as a nearby binary value.Yes, if the intended input can be represented exactly in the chosen arithmetic.
Arithmetic roundoffAn exact operation on stored inputs is rounded to the working format.Yes.
Truncation errorA derivative, infinite series or continuous problem is replaced by a finite approximation.No; the approximation remains.
Model errorThe financial model differs from the process or contract it is meant to describe.No.
Rounding an input is a rounding error too; the first two rows distinguish when it enters. In the three-number example the inputs are exact, isolating arithmetic roundoff. Increasing precision cannot repair a wrong payoff definition, and printing fewer decimal places cannot restore a contribution lost earlier.

Choose the remedy for the calculation

For summation, use an accurate accumulation method rather than assuming a particular order is harmless. In Python, math.fsum([1e16, -1e16, 1.0]) returns 1.0 in the checked binary64 environment. It tracks multiple partial sums to reduce lost information. This is an accuracy tool, not arbitrary exact arithmetic: the official documentation records platform and rounding assumptions, including a possible least-significant-bit discrepancy from double rounding.
For a fragile formula, a reformulation can help more than displaying extra digits; that is a question of numerical stability. For comparisons, select absolute and relative tolerances from the scale and purpose of the result, especially near zero. For a contract that specifies decimal amounts, use suitable decimal or integer-unit arithmetic and apply its explicit rounding rule at the specified stage; binary ties-to-even does not determine the contract's monetary convention.
To connect these choices to hedges and covariance calculations, the Numerical Conditioning and Stability lesson has a public preview, with the full lesson available through membership. It separates errors introduced by computation from the sensitivity of the problem itself.

Sources

Last updated
  • numerical methods
  • roundoff
  • floating point
  • summation
← Back to the glossaryBack to top ↑