Convert decimal numbers to and from single and double precision bit patterns, with sign, exponent and mantissa taken apart — and see what 0.1 is really stored as
Enter a decimal number to get the bit pattern, or paste a hex or binary pattern to get the value back, with the same breakdown either way
Sign, exponent and mantissa are shown in three separate blocks, so you can see at a glance which bits belong to which field
The full decimal expansion of what is really in memory: 0.1 comes out as 0.1000000000000000055511151231257827
Shows the spacing between representable numbers and the values immediately either side, so you can tell whether an operation rounded
Distinguishes normal, subnormal, positive and negative zero, the infinities and NaN, so special values never show up as nonsense numbers
Every conversion runs locally in JavaScript, no value is uploaded anywhere, and the tool works offline
To see how a number sits in memory use "Decimal → bits"; to decode a hex dump use "Bits → decimal". Pick the precision that matches your type: Java's float and C's float are 32-bit, double and JavaScript's Number are 64-bit.
Decimal mode accepts 0.1, -1.5e-8, and also Infinity and NaN. Bits mode accepts eight or sixteen hex digits such as 3DCCCCCD, or 32 or 64 binary digits, and switches precision automatically when the length matches.
The bit pattern line separates sign, exponent and mantissa with three background colours. A sign bit of 0 is positive and 1 is negative; the exponent needs the bias subtracted to become the true exponent; the mantissa is the field most often misread, because a normal number carries an implied leading 1.
The "exact stored value" row is the true decimal expansion of what is in memory. For money or any precision-sensitive calculation, compare it with the expected value to see exactly which rounding step introduced the error.
0.1+0.2 gives 0.30000000000000004 — convert all three and see which step the error creeps in
Sensors and PLCs often send floats as four IEEE 754 bytes; paste the hex to recover the real number
Deciding whether a chunk of bytes is an integer or a float, and single or double, comes down to the bit pattern
Put 1.0 and 1.0000000000000002 side by side: only the last bit differs, and it explains more than any formula
The ULP and neighbours show the smallest difference distinguishable at a given magnitude, which decides float versus double
When Infinity or NaN shows up in a log, the bit pattern tells you whether it was overflow, division by zero or 0/0
IEEE 754 slices a fixed-length binary word into three parts. The top bit is the sign, 0 for positive and 1 for negative. The middle field is the exponent, storing the true exponent plus a bias. The low bits are the mantissa, holding the fractional part of a normalised number. Take 0.1 in single precision: the pattern is 0 01111011 10011001100110011001101. The sign is 0, positive. The exponent field 01111011 is 123, minus the bias of 127 gives a true exponent of -4. The mantissa is 10011001100110011001101, so the value is 1.10011001100110011001101₂ × 2⁻⁴. Note the leading 1 is not stored at all — it is implied for normal numbers, which hands you one extra bit of precision for free.
Because binary can only represent fractions whose denominator is a power of two. 0.5, 0.25 and 0.125 are fine, but 0.1 is 1/10, whose denominator contains the prime factor 5, making it the repeating binary fraction 0.000110011001100…, exactly as 1/3 repeats in decimal. With only 23 or 52 mantissa bits the expansion has to be truncated and rounded, so the stored value differs slightly from 0.1. This is not insufficient precision but a base mismatch — a decimal float type such as Java's BigDecimal represents it exactly, at a large cost in speed.
The exponent field's value classifies the number. When it is neither all zeros nor all ones the number is normal, the mantissa carries an implied leading 1, precision is at its best, and almost every real value falls here. An all-zero exponent gives a subnormal (non-zero mantissa) or zero (zero mantissa), with the implied bit set to 0, used to approach zero smoothly. An all-ones exponent gives the special values: a zero mantissa means positive or negative infinity, a non-zero mantissa means NaN. This encoding lets every comparison and arithmetic operation run without extra branches, because the hardware classifies values from the exponent bits alone.
The ULP, unit in the last place, is the gap between adjacent representable floats — the resolution at that magnitude. It is not constant but scales with the value: in single precision the ULP near 1.0 is 2⁻²³, about 1.19e-7, while near 1024 it is 2⁻¹³, about 1.22e-4. Floats are therefore distributed logarithmically — dense near zero, sparse far from it. That explains why adding a small number to a large one "eats" the small one: once it falls below the ULP at that magnitude, the sum is simply the larger number.
IEEE 754 defines four rounding modes; the default is round-to-nearest, ties-to-even, which sends an exact tie toward the even last digit so that errors cancel statistically instead of drifting in one direction. Even with correct rounding every time, error accumulates across operations, and cancellation — adding a large and a small number then subtracting the large one — can wipe out all significant digits. The engineering answers are to sum in order of increasing absolute value, use Kahan compensated summation, or represent money as integer minor units.
| Value | float32 hex | float64 hex |
|---|---|---|
| 0 | 00000000 | 0000000000000000 |
| -0 | 80000000 | 8000000000000000 |
| 0.1 | 3DCCCCCD | 3FB999999999999A |
| 0.5 | 3F000000 | 3FE0000000000000 |
| 1 | 3F800000 | 3FF0000000000000 |
| 2 | 40000000 | 4000000000000000 |
| π (3.141592653589793) | 40490FDB | 400921FB54442D18 |
| 2²⁴ (16777216) | 4B800000 | 4170000000000000 |
| Smallest positive subnormal | 00000001 | 0000000000000001 |
| Largest finite float32 | 7F7FFFFF | — |
| Positive infinity | 7F800000 | 7FF0000000000000 |
| NaN (typical) | 7FC00000 | 7FF8000000000000 |