Skip to content

Machine epsilon

Understand binary64 spacing at one, the unit-roundoff convention, and why machine epsilon is not a universal price tolerance.

Machine epsilon is the gap between 11 and the next larger representable floating-point number, under the convention used by Python's sys.float_info.epsilon and NumPy's finfo(...).eps. It describes a format's precision near one. It helps explain why a tiny price bump can disappear, but it is not a universal dollar tolerance for a pricing calculation.
For IEEE 754 binary64, the usual format of Python's float,
ε=2−52≈2.220446049250313×10−16.\varepsilon=2^{-52}\approx2.220446049250313\times10^{-16}.
Binary64 has 53 bits of significand precision, including the implicit leading bit for normal numbers. In the interval [1,2)[1,2), its representable values are 1+k 2−521+k\,2^{-52} for integer 0≤k<2520\le k<2^{52}. The official Python definition fixes which convention is meant here.

A midpoint is not the next float

Assume round-to-nearest, ties-to-even arithmetic. Adding ε\varepsilon to 11 gives the next float. Adding ε/2\varepsilon/2 gives an exact mathematical midpoint, which rounds back to 11: its final significand bit is even. This does not make ε/2\varepsilon/2 zero; the addition cannot retain that increment at this scale.

import math import sys eps = sys.float_info.epsilon print(eps) # 2.220446049250313e-16 print(math.nextafter(1.0, math.inf)) # 1.0000000000000002 print(math.nextafter(1.0, math.inf) - 1.0 == eps) # True print(1.0 + eps / 2) # 1.0
This example was executed with Python 3.14.4 using binary64. The current Python documentation consulted is 3.15.2; the functions above are also available in 3.14. nextafter selects an adjacent representable value in a specified direction; see the math documentation.
Number line around one: the preceding float is one minus epsilon over two, the next float is one plus epsilon, and the midpoint one plus epsilon over two rounds to one. At a fictional USD 1 trillion valuation, upward spacing is USD 0.0001220703125.
Number line around one: the preceding float is one minus epsilon over two, the next float is one plus epsilon, and the midpoint one plus epsilon over two rounds to one. At a fictional USD 1 trillion valuation, upward spacing is USD 0.0001220703125.
Original binary64 diagram under nearest/ties-to-even rounding. Horizontal positions are offsets from one measured in epsilon units. The lower panel is a fictional valuation in USD.

Two related quantities need different names:

QuantityBinary64 valueMeaning
Spacing-based machine epsilonε=2−52\varepsilon=2^{-52}Gap immediately above 11
Unit roundoffu=ε/2=2−53u=\varepsilon/2=2^{-53}Usual relative bound for one correctly rounded result in the normal range
Smallest positive normal value2−10222^{-1022}Lower boundary of the normal range
Smallest positive representable value2−10742^{-1074}Smallest positive subnormal value
Some numerical-analysis sources call uu “machine epsilon.” Read the definition before comparing formulas: a factor of two may be a convention difference. The NumPy limits documentation also distinguishes eps, the gap below one (epsneg), and the smallest normal and subnormal values.

Precision follows the exponent

Within a normal binary64 interval [2e,2e+1)[2^e,2^{e+1}), consecutive representable values are spaced 2e−522^{e-52} apart. At a power-of-two boundary the gap below it is smaller than the gap above it. That is why the predecessor of 11 is 1−ε/21-\varepsilon/2, although its successor is 1+ε1+\varepsilon.

Consider a fictional portfolio valuation of exactly USD 101210^{12}. It lies in [239,240)[2^{39},2^{40}), so adjacent floats there differ by

239−52=2−13=0.0001220703125 USD.2^{39-52}=2^{-13}=0.0001220703125\ \text{USD}.

A USD 0.000010.00001 increment is less than half that spacing. Adding it to the stored valuation rounds back to the same valuation. An absolute acceptance threshold of 2.22×10−162.22\times10^{-16} USD would be far below the local representable step. Epsilon is dimensionless when describing relative precision; a price tolerance needs price units and a reason tied to the task.

What epsilon can and cannot guarantee

For a nonzero exact result zz in the normal range, a single correctly rounded binary64 operation under nearest rounding admits the model

fl⁡(z)=z(1+δ),∣δ∣≤u.\operatorname{fl}(z)=z(1+\delta),\qquad \lvert\delta\rvert\le u.
This describes one rounding step on the supplied operands. Subnormal results need separate treatment, and overflow is outside the model. It does not bound input uncertainty, accumulated error, catastrophic cancellation, or an entire algorithm's relative error. Goldberg's rounding-error discussion explains the relative-error convention and halfway rules.

For finite-difference Greeks, shrinking a bump indefinitely can erase the input change or amplify noise in the price difference. Inspect the input's local spacing, choose bumps in the input's units, and check results across sensible bump sizes. For comparisons, choose relative and absolute tolerances from scale and the required accuracy, including an absolute allowance near zero. Epsilon alone supplies neither a bump policy nor an error budget.

The SelfMadeQuant Numerical Conditioning and Stability lesson connects per-operation roundoff with sensitive hedge and covariance solves. A public preview is available; the full lesson requires membership.

Sources

Last updated
  • floating point
  • machine precision
  • numerical analysis
  • python
← Back to the glossaryBack to top ↑