Floating-Point ULP Calculator

Estimate the unit in the last place near a value for a chosen precision. This educational calculator shows the formula, result, and step-by-step interpretation.

Computer ScienceNumerical Methods

Calculator

What this calculator teaches

ULP explains why floating-point numbers are denser near zero and farther apart at large magnitudes.

Use the result as a learning aid. For classwork, still show the formula and intermediate reasoning so the final answer is not just a black-box number.

ULP and the Spacing between Floating-Point Numbers

ULP, or unit in the last place, describes the local spacing between adjacent representable floating-point values. For a normalized binary format with p significand bits, numbers in the interval [2e, 2e+1) share spacing 2e−p+1. Here e = floor(log2|x|). The spacing stays constant within one exponent bin and doubles when x crosses the next power of two.

This explains why floating-point numbers are not equally spaced across the number line. Around 1, binary64 spacing is roughly 2.22 × 10−16; around 1024 it is about 2.27 × 10−13. The relative spacing remains of comparable size because floating-point precision is approximately relative rather than absolute.

QuantityExpressionMeaning
Exponent bine = floor(log2|x|)Places x between adjacent powers of two
Normalized ULP estimate2e−p+1Spacing near x for p significand bits
Binary64 p5352 stored fraction bits plus implicit leading bit
Binary32 p2423 stored fraction bits plus implicit leading bit

The formula is for normalized binary numbers. Subnormal numbers near zero use a fixed minimum spacing determined by the format's exponent range, so a generic p-only formula does not fully describe that region. Zero itself also needs separate treatment.

Formula & Symbols

ConceptFormula or rule
ULP estimate2^(floor(log₂|x|) - p + 1)

Worked example

Example: ULP grows as the magnitude of the number grows.
Example 2: For x = 1 with p = 53, e = 0 and ULP = 2−52 ≈ 2.220446 × 10−16.
Example 3: For x = 1000 with p = 53, e = 9 and ULP = 2−43 ≈ 1.136868 × 10−13.
Example 4: At x = 1024 with p = 53, e jumps to 10, so ULP becomes 2−42 ≈ 2.273737 × 10−13, twice the spacing in the previous bin.
Example 5: For a binary32-style p = 24 at x = 1, ULP = 2−23 ≈ 1.192093 × 10−7.

Common mistakes

⚠️
Using the wrong input format

Keep lists comma separated, matrices as rows separated by semicolons, and modular inputs as integers.

⚠️
Ignoring assumptions

Some methods require positive probabilities, valid moduli, independent trials, or small educational input sizes.

⚠️
Treating machine epsilon as the spacing everywhere

Machine epsilon describes spacing relative to 1 under a specified convention. ULP changes with the exponent, so absolute spacing grows as the magnitude of normalized numbers grows.

⚠️
Ignoring the implicit leading significand bit

Binary64 is commonly described as having 52 stored fraction bits but 53 bits of precision for normalized numbers. Using 52 for p shifts the spacing estimate by a factor of two.

FAQ

Can I use decimals?
Most numerical calculators allow decimals, but modular arithmetic and coding-theory tools usually require integers or binary strings.
Is this for homework checking?
Yes. The page is designed to show both the answer and the reasoning pattern.
Why does the result sometimes say approximate?
Some probability, floating-point, and numerical methods naturally produce approximations.
Why does ULP double at powers of two?
Crossing a power of two increases the floating-point exponent by one while the number of significand bits stays fixed. The step 2e−p+1 therefore doubles at the boundary.
Is one ULP the same size for every number?
No. For normalized floating-point values, spacing is constant only within one exponent bin. Larger-magnitude bins have larger absolute ULPs, while smaller-magnitude bins have smaller spacing until the subnormal region is reached.
What is the ULP near zero?
Near zero, IEEE-style formats enter the subnormal region where spacing becomes a fixed minimum value rather than continuing the normalized formula indefinitely. The exact spacing depends on both significand precision and the format's minimum exponent.
How is ULP useful in numerical testing?
ULP-based comparisons measure error relative to the representable spacing near the result. Saying two values differ by a small number of ULPs can be more informative than using one fixed absolute tolerance across very different magnitudes.

Related calculators

These links will work after the calculators are registered in the final Math layout update.

Formula Explorer connections

Interpretation: This relationship converts, summarizes or checks numerical quantities using standard arithmetic and measurement rules. Assumption: Use consistent units, preserve enough significant digits, and round only the final result unless the method states otherwise.

Fraction Calculator – Add, Subtract, Multiply and Divide →GPA Calculator – Grade Point Average →Half-Life Calculator – Radioactive Decay →Math Formula Explorer →