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.float,A midpoint is not the next float
Assume round-to-nearest, ties-to-even arithmetic. Adding to gives the next float. Adding gives an exact mathematical midpoint, which rounds back to : its final significand bit is even. This does not make 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.0nextafter selects an adjacent representable value in a specified direction; see the math documentation.Two related quantities need different names:
| Quantity | Binary64 value | Meaning |
|---|---|---|
| Spacing-based machine epsilon | Gap immediately above | |
| Unit roundoff | Usual relative bound for one correctly rounded result in the normal range | |
| Smallest positive normal value | Lower boundary of the normal range | |
| Smallest positive representable value | Smallest positive subnormal value |
eps, the gap below one (epsneg), and the smallest normal and subnormal values.Precision follows the exponent
Within a normal binary64 interval , consecutive representable values are spaced apart. At a power-of-two boundary the gap below it is smaller than the gap above it. That is why the predecessor of is , although its successor is .
Consider a fictional portfolio valuation of exactly USD . It lies in , so adjacent floats there differ by
A USD increment is less than half that spacing. Adding it to the stored valuation rounds back to the same valuation. An absolute acceptance threshold of 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 in the normal range, a single correctly rounded binary64 operation under nearest rounding admits the model
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.
Sources
- Python Software Foundation. sys.float_info. Epsilon, significand precision, minimum normal value and rounding-mode information.
- Python Software Foundation. math.nextafter and math.ulp. Adjacent values and local spacing.
- NumPy. numpy.finfo, current 2.5 manual. Format limits and the
eps/epsnegdistinction. - Goldberg, D. What Every Computer Scientist Should Know About Floating-Point Arithmetic, Oracle Numerical Computation Guide. “Relative Error and Ulps” and “Exactly Rounded Operations”; the paper uses the unit-roundoff convention for epsilon.