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.
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.
| Quantity | Expression | Meaning |
|---|---|---|
| Exponent bin | e = floor(log2|x|) | Places x between adjacent powers of two |
| Normalized ULP estimate | 2e−p+1 | Spacing near x for p significand bits |
| Binary64 p | 53 | 52 stored fraction bits plus implicit leading bit |
| Binary32 p | 24 | 23 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
| Concept | Formula or rule |
|---|---|
| ULP estimate | 2^(floor(log₂|x|) - p + 1) |
Worked example
Common mistakes
Keep lists comma separated, matrices as rows separated by semicolons, and modular inputs as integers.
Some methods require positive probabilities, valid moduli, independent trials, or small educational input sizes.
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.
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
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.