ULP Explorer
See how far apart floating-point numbers are at any value. Find the nearest float, its neighbours, the gap (ULP) on each side and the digits of precision, or count the ULPs between two numbers.
How to Use
- Choose around a number to explore the floats near one value, or ULPs between two to compare two numbers.
- Pick the precision: half, single (float) or double.
- Type the number, or the two numbers to compare.
- Read the nearest float, the gap to the next one (the ULP), the relative spacing and the decimal digits of precision there.
- The drawing shows the neighbouring floats and the gaps between them.
Worked Example
The doubles around 1.0. A double has 52 stored mantissa bits, so between 1 and 2 (exponent 0) the gap is 2⁰ × 2⁻⁵² = 2.22 × 10⁻¹⁶: the next double is 1.0000000000000002. Below 1 the exponent is −1, so the gap is half that, 1.11 × 10⁻¹⁶, and the double before 1 is 0.9999999999999999. A relative gap of 2.2 × 10⁻¹⁶ means about 15.7 decimal digits.
The doubles around 10¹⁶. 10¹⁶ lies between 2⁵³ and 2⁵⁴, so the gap is 2⁵³ × 2⁻⁵² = 2. The doubles there are 10,000,000,000,000,000, then 10,000,000,000,000,002: the odd number in between cannot be stored, and 10¹⁶ + 1 rounds back to 10¹⁶.
The common mistake: a fixed tolerance. Testing |a − b| < 1e-9 is far too loose for numbers near 10⁻¹² and impossibly tight for numbers near 10¹², where the gap between doubles is already 1.2 × 10⁻⁴. Scale the tolerance to the numbers, or count ULPs.
Show Work
Formulas
Measuring Error in ULPs
William Kahan, the architect of IEEE 754, popularised the ULP as the natural unit of floating-point error: a correctly rounded result is within half an ULP of the true answer, and library functions such as sin and exp are graded by how many ULPs they can be off. The C function nextafter, Java’s Math.ulp and Python’s math.ulp and math.nextafter all expose the idea directly.
Counting ULPs between two numbers works because IEEE 754 laid out the bits so that, for positive floats, the bit patterns read as integers are in the same order as the values. That was a deliberate design choice: it lets hardware compare floats almost as cheaply as integers.
About This Calculator
This explorer finds the half, single or double precision float nearest any number, its neighbours above and below, the gap on each side, the relative spacing and the decimal digits of precision there, and draws the neighbouring floats to scale by position. In the second mode it counts how many representable values lie between two numbers.
Everything runs in your browser; nothing is sent anywhere. Conversions are exact and correctly rounded, independent of the browser’s own arithmetic.
Related calculators: IEEE 754 Float Converter, FP16 and bfloat16 Converter, and Minifloat Converter.
Frequently Asked Questions
What is an ULP?
A unit in the last place: the gap between a floating-point number and the next one. It depends on the size of the number. For doubles, the ULP of 1.0 is 2⁻⁵² ≈ 2.22 × 10⁻¹⁶, the ULP of 1,000 is 2⁻⁴³ ≈ 1.14 × 10⁻¹³, and the ULP of 10¹⁶ is 2.
Why are the gaps different on each side of a power of two?
The spacing is set by the exponent, which changes at each power of two. Just above 1.0 the doubles are 2⁻⁵² apart; just below, they are 2⁻⁵³ apart, half as far. So 1.0 has a smaller gap below it than above it.
What is the difference between machine epsilon and an ULP?
Machine epsilon is one particular ULP: the gap between 1.0 and the next larger float, 2⁻⁵² for doubles and 2⁻²³ for single floats. The ULP at other values scales with the number, so the relative spacing, ULP ÷ x, stays between epsilon and half of it for every normal number.
How should floats be compared?
Not with ==. Either allow a relative tolerance, such as |a − b| ≤ 1e-9 × max(|a|, |b|), or count ULPs: 0.1 + 0.2 and 0.3 are 1 ULP apart as doubles, so a test that accepts a difference of a few ULPs treats them as equal. Counting ULPs works because the bit patterns of floats are in numeric order.
When do floats stop holding every integer?
When the ULP exceeds 1. Doubles hold every integer up to 2⁵³ = 9,007,199,254,740,992 exactly; above that the gap is 2, so 2⁵³ + 1 is not representable. Single floats stop at 2²⁴ = 16,777,216, which is why a float counter stops increasing there.
How do I use the ULP Explorer?
Simply type your numbers and read the result, which refreshes the instant you change something. There is nothing to submit and nothing to wait for.
Does it cost anything or need an account?
No. The tool is completely free, there is no account to create, and it keeps working offline after the page first loads.
Is anything I type uploaded?
No. The tool works entirely on your device, so the values you enter never leave your browser.
Common Use Cases
Testing
0.1 + 0.2 and 0.3 are 1 ULP apart as doubles: equal within a few ULPs.
Large values
At 10¹⁶ the gap between doubles is 2, so odd integers there do not exist.
Game coordinates
A single float at 100,000 m has a gap of about 7.8 mm, enough to make objects jitter.
Precision budgets
Half precision at 1.0 has a gap of 0.000977: about 3 decimal digits.
Last updated: