IEEE 754 Converter: Float and Double Bits, Exact Values and Error
By FindMySum · Last reviewed
An IEEE 754 converter shows how a computer stores a decimal number as floating-point bits, and what value those bits really hold. Type a decimal such as 0.1 and choose a format: the converter rounds it the way the hardware does, prints the hexadecimal bits, splits them into sign, exponent and fraction, and gives the exact stored value and how far it is from what you typed. You can also paste bits in hex or binary to see the number they encode.
Three fields
Every IEEE 754 binary number is made of three fields:
| Format | Sign, exponent, fraction bits | Precision | Bias |
|---|---|---|---|
| binary16 (half) | 1, 5, 10 | 11 bits | 15 |
| binary32 (float) | 1, 8, 23 | 24 bits | 127 |
| binary64 (double) | 1, 11, 52 | 53 bits | 1023 |
For a normal number the value is:
value = (−1)^sign × 2^(exponent field − bias) × (1 + fraction ÷ 2^fraction bits)
The leading 1 before the binary point isn't stored. Every normal number has one, so leaving it out gains a bit of precision for free; that is why a float with 23 fraction bits has 24 bits of precision.
Worked example: 0.1 as a float
The converter opens with 0.1 in binary32. In binary, one tenth is 0.0001100110011…, repeating forever. Written as 1.10011001100… × 2^-4, the exponent is −4, so the exponent field is −4 + 127 = 123 (01111011 in binary). The fraction holds the first 23 bits after the leading 1, and the 24th and later bits decide the rounding: they are more than half of the last place, so the fraction rounds up to 0x4CCCCD.
Put together, the bits are 0 01111011 10011001100110011001101, or 0x3DCCCCCD in hexadecimal. Those bits stand for exactly 0.100000001490116119384765625. The rounding error is 0.000000001490116119384765625, about 1.5 × 10^-8 of the value, and the next float up is 2^-27 (0.0000000075) away. In double precision the same 0.1 is stored as 0x3FB999999999999A, which is off by only about 5.6 × 10^-18.
Round to nearest, ties to even
A decimal usually falls between two representable values. IEEE 754's default rule picks the nearer one; if the number is exactly halfway, it picks the one whose last bit is 0 (the "even" one). Ties to even avoids the upward drift that always rounding halves up would cause over many operations.
You can see a tie with 16777217 in binary32. With 24 bits of precision, floats above 2^24 = 16,777,216 are spaced 2 apart, so 16,777,217 lies exactly halfway between 16,777,216 and 16,777,218. The even one wins: it is stored as 16,777,216, an error of −1. Integers are exact in a float only up to 2^24, and in a double up to 2^53 (9,007,199,254,740,992), which is why JavaScript calls that limit Number.MAX_SAFE_INTEGER plus one.
Special values
Two exponent field values are reserved:
- All zeros. With a zero fraction, the value is zero; the sign bit gives +0 or −0. With a non-zero fraction it is a subnormal number: no hidden 1, and the exponent is fixed at its minimum (−126 for binary32). Subnormals let values fade gradually to zero instead of jumping from about 1.18 × 10^-38 straight to 0. The smallest positive float, 0x00000001, is 2^-149, about 1.4 × 10^-45.
- All ones. With a zero fraction, the value is infinity; with a non-zero fraction it is NaN (not a number), the result of operations such as 0 ÷ 0.
When a decimal is too large for the format, rounding produces infinity. The largest finite binary16 value is 65,504; 65,520 sits exactly halfway between 65,504 and 2^16, ties to even rounds it up, and since 2^16 doesn't fit, the result overflows to infinity (0x7C00).
Exact value versus shortest decimal
The converter shows two decimal forms of the same bits. The exact stored value is what the bits really mean: always a finite decimal, because every binary fraction has a terminating decimal expansion, though it can run to hundreds of digits for tiny numbers. The shortest decimal is the decimal with the fewest significant digits that converts back to the same bits. That is what most programming languages print, and it is why 0.1 looks like 0.1 when you print it even though it isn't stored exactly.
When the error matters
For most measurement and science work, double precision's 15 to 17 significant digits are far more than the data carry. Errors matter when they pile up or cancel:
- Sums of many small values collect rounding error; adding in a different order gives slightly different results. Compensated (Kahan) summation reduces it.
- Subtracting nearly equal numbers loses the leading digits they share, leaving mostly rounding error behind.
- Equality tests such as 0.1 + 0.2 == 0.3 fail; compare with a tolerance suited to the size of the numbers instead.
- Money should not be stored in binary floating point at all; use integer cents or a decimal type.
Half precision deserves care of its own. With 11 bits of precision and a maximum of 65,504, it is popular for graphics and machine learning because it halves memory, but it overflows and loses precision easily, which is why training often keeps a binary32 copy of the weights.
More questions
Is IEEE 754 the same on every computer?
The formats and the basic operations (add, subtract, multiply, divide, square root) are: an IEEE 754 binary64 addition gives the same bits on any conforming system. Differences come from elsewhere: compilers reordering operations, fused multiply-add, extended-precision intermediates on old x87 code, and math library functions such as sin and exp, which the standard only recommends to be correctly rounded.
What is machine epsilon?
The gap between 1 and the next larger representable number: 2^-23 (about 1.19 × 10^-7) for binary32 and 2^-52 (about 2.22 × 10^-16) for binary64. Half of it bounds the relative rounding error of a single correctly rounded operation on normal numbers.
Why are there two zeros?
The sign bit is separate from the magnitude, so +0 and −0 both exist. They compare equal, but they behave differently in a few places: 1/+0 is +∞ and 1/−0 is −∞, and −0 records that a tiny negative result underflowed. Type -0 into the converter to see 0x80000000.
What is the difference between a quiet NaN and a signalling NaN?
Both have an exponent field of all ones and a non-zero fraction. In the 2008 and 2019 editions, the first fraction bit tells them apart: set for a quiet NaN, which passes silently through arithmetic, and clear for a signalling NaN, which raises an invalid-operation exception when used. The remaining fraction bits are a payload that some systems use for diagnostics.
Should I store money in a float or a double?
No. Amounts like $0.10 cannot be represented exactly in binary, so sums drift by fractions of a cent. Store money as an integer number of cents, or use a decimal type (SQL DECIMAL, Java BigDecimal, Python decimal, or a library such as decimal.js), and round only when displaying.
Sources
This article explains how the calculator works and is general information, not financial, tax, legal or medical advice. Rules change; check the sources above or a qualified professional before you act.