Floating-Point Precision Calculator
Inputs
| Format | Double (64-bit) |
|---|---|
| Value | 1,000 |
Floating-Point Precision Calculator
Find the machine epsilon, significant decimal digits, and the spacing of representable values (ULP) for IEEE 754 half, single, double, and quadruple precision formats.
Inputs
Format and value
Results
Enter a value to see results.
Precision
Details
Floating-Point Precision
Computers store real numbers in a finite number of bits, so most values are kept only approximately. This calculator reports the precision of the IEEE 754 binary formats — half, single, double, and quadruple — by computing the machine epsilon, the number of reliable decimal digits, and the spacing between representable numbers (the ULP) at a value you choose. Together these explain why floating-point arithmetic is precise but not exact.
How a float stores a number
An IEEE 754 number is written as a sign, a significand (the significant digits), and an exponent that scales it by a power of two — much like scientific notation in base 2. Each format fixes how many bits the significand gets: half precision has 11 bits of significand, single has 24, double has 53, and quadruple has 113 (each count includes one implicit leading bit). The more significand bits, the finer the resolution.
Machine epsilon
The cleanest measure of resolution is machine epsilon, the gap between 1.0 and the next representable number above it:
where is the number of significand bits. For double precision, . This is a relative bound: any real number is stored with a relative error of at most . The reliable number of significant decimal digits follows directly, as — about 15.7 for double precision.
ULP: spacing that grows with magnitude
Machine epsilon describes the spacing near 1.0, but floating-point numbers are not evenly spaced. The gap between consecutive representable values, the unit in the last place (ULP), scales with magnitude:
Near 1 the spacing is machine epsilon; near 1,000 it is about a thousand times larger. This is why floating-point keeps constant relative precision but loses absolute precision as numbers grow.
Worked example
Take double precision and the value 1000. The exponent is , so:
ULP(1000)=29−52=2−43≈1.14×10−13The largest rounding error near 1000 is half of that, about . So a double can distinguish 1000 from 1000.0000000000001 but not from a value differing in the sixteenth significant digit.
Why 0.1 is not exact
Binary floating-point can only represent sums of powers of two, and 0.1 has no finite binary expansion — just as one third has none in decimal. It is therefore rounded to the nearest representable value, which is why 0.1 + 0.2 does not exactly equal 0.3 in most languages. The discrepancy is on the order of machine epsilon and usually harmless, but it accumulates over long computations and is the reason money is often stored as integers or in a decimal type rather than as a float. For how integers themselves are encoded in binary, see the Two's Complement Calculator.
Frequently Asked Questions (FAQ)
What is machine epsilon?
Machine epsilon is the gap between 1.0 and the next floating-point number larger than 1.0. It equals 2 raised to the power of minus the number of fractional significand bits — for double precision that is 2⁻⁵², about 2.22 × 10⁻¹⁶.
Machine epsilon measures the relative resolution of the format: any real number is stored with a relative error no larger than half of epsilon. It is the standard yardstick for how many digits a format can be trusted to carry.
What is a ULP?
ULP stands for "unit in the last place" — the distance between a floating-point number and the next representable number above it.
Unlike machine epsilon, which is fixed, the ULP grows with magnitude: near 1 the spacing is machine epsilon, near 1,000 it is about a thousand times larger, and near a billion larger still. Because the spacing scales with the value, floating-point numbers keep roughly constant relative precision across their range, while absolute precision degrades as numbers grow.
Why can't 0.1 be stored exactly?
Binary floating-point can only represent sums of powers of two. The decimal fraction 0.1 has no finite binary expansion — just as one third has no finite decimal expansion — so it is rounded to the nearest representable value, which is slightly more than 0.1.
This is why 0.1 + 0.2 does not exactly equal 0.3 in most languages. The error is tiny, on the order of machine epsilon, but it accumulates over many operations and is the reason monetary values are often stored as integers or in decimal types.
How many decimal digits does each format hold?
The reliable count of significant decimal digits is approximately the number of fractional significand bits times the logarithm of 2 (about 0.301). Half precision gives roughly 3 digits, single about 7, double about 15 to 16, and quadruple about 34. These are the digits you can round-trip safely; printing more digits than this exposes the rounding artifacts of the binary representation rather than meaningful precision.
Recommended Next
Two's Complement Calculator
Convert a signed integer to its two's complement binary and hexadecimal representation, or decode a binary string back to its signed decimal value. Choose 8, 16, 32, or 64 bits.