IEEE 754 Converter

Input

Values accept scientific notation such as -1.5e-8, as well as Infinity, -Infinity and NaN. Bit patterns may be 8 or 16 hex digits (with an optional 0x) or 32 or 64 binary digits; the precision is detected automatically.
—
—
Sign bit—
Exponent (raw → true)—
Mantissa (fraction)—
Bit pattern (sign | exponent | mantissa)

IEEE 754 Converter features

Both directions

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

Colour-coded bit fields

Sign, exponent and mantissa are shown in three separate blocks, so you can see at a glance which bits belong to which field

The exact stored value

The full decimal expansion of what is really in memory: 0.1 comes out as 0.1000000000000000055511151231257827

ULP and neighbours

Shows the spacing between representable numbers and the values immediately either side, so you can tell whether an operation rounded

Automatic classification

Distinguishes normal, subnormal, positive and negative zero, the infinities and NaN, so special values never show up as nonsense numbers

Nothing leaves the browser

Every conversion runs locally in JavaScript, no value is uploaded anywhere, and the tool works offline

How to use the IEEE 754 Converter

1

Choose direction and precision

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.

2

Enter the value

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.

3

Read the three bit fields

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.

4

Check error against the exact value

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.

Common uses

Tracking down float error

0.1+0.2 gives 0.30000000000000004 — convert all three and see which step the error creeps in

Interfacing with hardware

Sensors and PLCs often send floats as four IEEE 754 bytes; paste the hex to recover the real number

Analysing binary files

Deciding whether a chunk of bytes is an integer or a float, and single or double, comes down to the bit pattern

Teaching how floats work

Put 1.0 and 1.0000000000000002 side by side: only the last bit differs, and it explains more than any formula

Judging whether precision suffices

The ULP and neighbours show the smallest difference distinguishable at a given magnitude, which decides float versus double

Confirming special values

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 explained

The three fields: sign, exponent, mantissa

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.

Why decimal fractions are inexact

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.

Normal, subnormal and special values

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.

ULP and the density of representable numbers

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.

Rounding modes and accumulated error

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.

Bit pattern cheat sheet

Value float32 hex float64 hex
0000000000000000000000000
-0800000008000000000000000
0.13DCCCCCD3FB999999999999A
0.53F0000003FE0000000000000
13F8000003FF0000000000000
2400000004000000000000000
π (3.141592653589793)40490FDB400921FB54442D18
2²⁴ (16777216)4B8000004170000000000000
Smallest positive subnormal000000010000000000000001
Largest finite float327F7FFFFF—
Positive infinity7F8000007FF0000000000000
NaN (typical)7FC000007FF8000000000000
Single precision: bias 127, 8 exponent bits, 23 mantissa bits. Double precision: bias 1023, 11 exponent bits, 52 mantissa bits. 0 and -0 compare equal but have different bit patterns — distinguish them with 1/x, which yields ±Infinity.

Frequently asked questions

Q: Why is 0.1 + 0.2 not equal to 0.3?
A: Because 0.1, 0.2 and 0.3 are all repeating fractions in binary, and a float only has 52 mantissa bits, so storing them requires rounding. The real value of 0.1 as a double is 0.1000000000000000055511151231257827, and 0.2 carries a similar positive error. Adding them and rounding once more gives a sum slightly larger than the true value of 0.3, so 0.1 + 0.2 === 0.3 evaluates to false. This is not a bug but inherent to binary floating point.
Q: What is the actual difference between single and double precision?
A: It comes down to how the bits are allocated. Single precision uses 32 bits: 1 sign, 8 exponent, 23 mantissa, giving about 7 significant decimal digits and a range of roughly ±38. Double precision uses 64 bits: 1 sign, 11 exponent, 52 mantissa, giving about 16 significant digits and a range of roughly ±308. More bits mean more precision and range at twice the memory and bandwidth.
Q: Why does 16777216 + 1 stay 16777216 in float32?
A: Because single precision has only 24 significant bits including the hidden leading one, and 2^24 = 16777216 is already the largest exactly representable consecutive integer. Beyond that the gap between neighbouring values becomes 2, so 16777217 must round to either 16777216 or 16777218. For doubles the corresponding limit is 2^53 = 9007199254740992, which is where JavaScript's Number.MAX_SAFE_INTEGER comes from.
Q: Why does the exponent have a bias added to it?
A: So that a single unsigned field can represent both positive and negative exponents, and so that floats can be compared as plain integers. Single precision stores the true exponent plus 127, double precision plus 1023. A true exponent of -126 is stored as 1, and 0 as 127. Comparing two positive floats then needs no special handling of sign and exponent — the bit patterns as unsigned integers give the right order.
Q: What is a subnormal number and why is it needed?
A: When the exponent field is all zeros the hidden leading bit becomes 0 and the mantissa is read as 0.xxx. Its job is to fill the gap between the smallest normal number and zero: the smallest normal float32 is about 1.18e-38, and without subnormals there would be a cliff between it and zero where results flush to zero. Subnormals let values decay smoothly, at the cost of losing significant digits. The smallest subnormal float32 is about 1.4e-45.
Q: Why does an all-ones exponent mean infinity or NaN?
A: Because an all-ones exponent corresponds to a true exponent of 128 in single precision or 1024 in double precision, and that value is reserved. All-ones exponent with a zero mantissa is positive or negative infinity, carrying overflow and division by zero. All-ones exponent with a non-zero mantissa is NaN, representing operations such as 0/0 or infinity minus infinity. Comparisons and arithmetic then need no extra branches.
Q: Why is the exact stored value so long?
A: Because a binary float is always an integer times a power of two, so its decimal expansion is finite — but it can have many digits. The exact value of 0.1 as a double is 0.1000000000000000055511151231257827021181583404541015625, fifty-five decimal places. The 0.1 normally printed is the shortest string that uniquely identifies that float, not the value stored. For rounding error or money, look at the exact value.