Floating-Point ULP & Next Value Calculator
Calculate the ULP and adjacent representable IEEE 754 floating-point values. Inspect the previous value, next value, upward and downward spacing, hexadecimal bit pattern, exponent and significand information for Float32 and Float64.
—
What Is a Floating-Point ULP?
ULP means unit in the last place. It describes the spacing associated with the least-significant representable bit of a floating-point number at a particular magnitude.
IEEE 754 floating-point numbers are not distributed uniformly across the real number line. Values close to zero have very fine spacing, while values with larger exponents have progressively larger gaps between adjacent representable numbers.
IEEE 754 Float32 and Float64 Precision
| Format | Total Bits | Exponent Bits | Fraction Bits | Precision |
|---|---|---|---|---|
| Float32 / Binary32 | 32 | 8 | 23 | 24 significant binary bits |
| Float64 / Binary64 | 64 | 11 | 52 | 53 significant binary bits |
The extra precision bit comes from the implicit leading bit used for normal binary floating-point values.
ULP Formula for Normal Floating-Point Numbers
For a positive normal binary floating-point value in a binade with unbiased exponent e, the spacing to the next larger value is:
ULP = 2^(e - fractionBits)
Binary32:
ULP = 2^(e - 23)
Binary64:
ULP = 2^(e - 52)This gives the spacing between adjacent values within the same exponent interval.
Float64 ULP at 1.0
For IEEE 754 Binary64, the value 1.0 has unbiased exponent zero and 52 stored fraction bits.
ULP(1.0)
= 2^(0 - 52)
= 2^-52
= 2.220446049250313e-16Therefore the next Binary64 value above 1 is:
1.0000000000000002Float32 ULP at 1.0
Binary32 fraction bits = 23
Exponent of 1.0 = 0
ULP
= 2^(0 - 23)
= 2^-23
= 1.1920928955078125e-7The next Float32 value greater than 1.0 is approximately:
1.0000001192092896Why Is the Previous Spacing Sometimes Different?
Floating-point spacing changes when an exponent boundary is crossed. The value 1.0 is an important example. The spacing immediately above 1.0 in Binary64 is 2-52, but the gap between 1.0 and the immediately previous representable value is 2-53.
Previous Float64 below 1:
0.9999999999999999
Gap below:
2^-53
Next Float64 above 1:
1.0000000000000002
Gap above:
2^-52For that reason this calculator does not assume that the upward and downward distances are always identical.
What Is the Next Representable Floating-Point Value?
The next representable value is the closest floating-point number in the selected format that is numerically greater than the current stored value. There is no representable value from the same format between the two.
This concept is useful for numerical analysis, boundary testing, floating-point comparison research, serialization testing and understanding precision loss.
Previous Representable Value
The previous value is the nearest representable floating-point number that is numerically smaller than the current value.
Current:
1.0
Float64 Previous:
0.9999999999999999
Float64 Next:
1.0000000000000002Float32 Precision Around 16,777,216
Binary32 has 24 bits of significand precision. The integer 16,777,216 equals 224, and at this magnitude the spacing between Float32 values becomes 2.
Current Float32:
16777216
Next Float32:
16777218
Upward spacing:
2This explains why not every consecutive integer can be represented by Float32 once values become sufficiently large.
Subnormal Floating-Point Values
Subnormal numbers fill the gap between zero and the smallest normal floating-point magnitude. Unlike normal values, they do not use an implicit leading one in the significand.
Within the subnormal range, adjacent positive values have constant spacing. For Binary32 that spacing is 2-149; for Binary64 it is 2-1074.
Smallest positive Float32:
2^-149
Smallest positive Float64:
2^-1074ULP Around Zero
The next positive representable value after positive zero is the smallest positive subnormal value. Similarly, the next numerical value below zero is the smallest negative subnormal.
Float32:
next above 0 = 2^-149
Float64:
next above 0 = 2^-1074IEEE 754 Bit Pattern
The calculator also exposes the underlying floating-point representation. A Binary32 value consists of one sign bit, eight exponent bits and 23 fraction bits. Binary64 uses one sign bit, 11 exponent bits and 52 fraction bits.
Binary32:
S EEEEEEEE FFFFFFFFFFFFFFFFFFFFFFF
Binary64:
S EEEEEEEEEEE FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFSpecial Floating-Point Values
IEEE 754 reserves exponent patterns for special values including positive infinity, negative infinity and NaN. These values do not behave like ordinary finite numbers when calculating adjacent values or conventional ULP spacing.
Why Floating-Point ULP Matters
ULP analysis helps show the actual resolution available at a given numerical magnitude. This can be useful when investigating rounding behavior, equality comparisons, iterative numerical algorithms, sensor calculations, simulation results and binary serialization.
A fixed decimal tolerance does not represent the same number of floating-point steps at every magnitude. ULP-based analysis instead relates the error to the spacing of the selected floating-point representation.
Floating-Point ULP Calculator FAQs
What does ULP mean?
What is the ULP of Float64 1.0?
What is the next Float64 value after 1?
What is the next Float32 value after 1?
Are previous and next spacing always equal?
What is a subnormal number?
What is the smallest positive Float32 value?
What is the smallest positive Float64 value?
Why can Float32 not represent every large integer?
Does ULP remain constant?
Does this calculator support negative values?
Does the calculator support Float32 and Float64?
Inspect Floating-Point Precision
Calculate adjacent IEEE 754 values, ULP spacing, bit patterns, exponent fields and floating-point classification for Binary32 and Binary64 numbers.