What is Machine epsilon?

The difference between 1 and the next larger representable floating-point number, a measure of relative precision: 2⁻²³ (about 1.19 × 10⁻⁷) in single precision and 2⁻⁵² (about 2.2 × 10⁻¹⁶) in double.

Field: Computer Arithmetic

Japanese name: マシンイプシロン

Definition and values

Machine epsilon is the difference between 1.0 and the next larger floating-point number. In an IEEE 754 binary format that stores p significand (fraction) bits, the number after 1.0 is 1+2−p1 + 2^−p, so machine epsilon is 2−p2^−p. It is 2⁻²³ ≈ 1.19 × 10⁻⁷ in single precision (23 bits), 2⁻⁵² ≈ 2.2 × 10⁻¹⁶ in double precision (52 bits), 2⁻¹⁰ ≈ 9.8 × 10⁻⁴ in FP16 half precision (10 bits) and 2⁻⁷ ≈ 7.8 × 10⁻³ in BF16 (7 bits). In decimal terms, single precision carries about 7 digits and double precision about 15–16.

Why it measures relative precision

The spacing between floating-point numbers widens as values grow. Between 1 and 2 the gap between neighbors is machine epsilon itself; between 2 and 4 it is twice that, and between 2⁸ and 2⁹ it is 2⁸ times that. What stays roughly constant is therefore the relative error, not the absolute error. A single round-to-nearest-even operation has a relative error of at most half of machine epsilon (the unit roundoff) within the normal range. For example, adding 1 to 100 million (10⁸) in single precision leaves the result unchanged, because the spacing there is 8.

Watch the convention

The value called "machine epsilon" can differ between references and libraries. Constants in many programming languages, such as C's FLT_EPSILON and DBL_EPSILON, Python's sys.float_info.epsilon and NumPy's finfo().eps, return the gap between 1 and the next number, 2⁻²³ or 2⁻⁵². Some numerical-analysis textbooks, however, use the name for the unit roundoff u, the bound on the relative rounding error (2⁻²⁴ in single precision, 2⁻⁵³ in double). Because the two differ by a factor of 2, check which definition is meant when estimating errors.

Uses and similar-looking values

Machine epsilon serves as a guide for setting tolerances when comparing floating-point numbers and thresholds for convergence in iterative calculations. Because it expresses relative precision, using it directly to compare values near zero makes the tolerance far too large. A similar-looking quantity, the smallest positive normal number (about 1.18 × 10⁻³⁸ in single precision), marks the lower end of the representable range and is unrelated to precision. The spacing between a value and its neighbor is called an ULP (unit in the last place), and machine epsilon is the ULP at 1.0.

Try it: questions about Machine epsilon

What is the machine epsilon (the gap between 1 and the next larger representable number) in IEEE 754 single precision?

  1. A2⁻²³ (about 1.19 × 10⁻⁷)
  2. B2⁻⁸ (about 3.9 × 10⁻³)
  3. C2⁻⁵² (about 2.2 × 10⁻¹⁶)
Show answer and explanation

Answer: A. 2⁻²³ (about 1.19 × 10⁻⁷)

1.0 is represented as 1.000…0 × 2⁰ with a 23-bit significand, so incrementing the last significand bit gives 1 + 2⁻²³. That gap, 2⁻²³ ≈ 1.19 × 10⁻⁷, is machine epsilon, indicating single precision's relative precision of about seven digits. 2⁻⁵² is the machine epsilon of double precision with its 52-bit significand. 2⁻⁸ confuses it with the exponent width. The value also guides tolerances for comparing floating-point numbers.

FAQ

What is machine epsilon, in simple terms?

The difference between 1.0 and the next larger representable floating-point number, a measure of the format's relative precision. It is 2⁻²³ (about 1.19 × 10⁻⁷) in single precision and 2⁻⁵² (about 2.2 × 10⁻¹⁶) in double, corresponding to about 7 and about 15–16 decimal digits.

Can numbers smaller than machine epsilon be represented?

Yes. Machine epsilon is the spacing of numbers near 1.0, not the smallest representable number. Even single precision reaches values around 10⁻³⁸ (smaller still with subnormals). However, adding a number no larger than half of machine epsilon to 1.0 rounds back to 1.0.

Can I use machine epsilon directly as a tolerance for floating-point comparisons?

Often not. Machine epsilon is the spacing near 1.0, so it is too small for large values and too large for values near zero. A common approach combines a relative tolerance scaled by the magnitude of the values, a margin for errors accumulated in the calculation, and an absolute tolerance for values near zero.

Books on Computer Arithmetic Ad

As an Amazon Associate I earn from qualifying purchases.

Semiconductor, Electronics and Computing Calculators

This page was drafted with AI and fact-checked by a separate AI review before publication. Our Editorial policy explains how we write and check content. If you spot an error, please tell us on our Contact page.

Back to the glossary