IEEE 754 Floating-Point Converter
Convert floats to IEEE 754 hex & binary — FP16, FP32, FP64 and bfloat16. See the exact stored value, rounding error and bit layout. 100% in your browser.
| Sign | |
| Exponent | |
| Mantissa |
- You entered
- Actually stored
- Rounding error
- Previous
- Next
- ULP (gap size)
| Format | Total bits | Sign | Exponent | Mantissa | Bias | Max finite value | Decimal digits |
|---|---|---|---|---|---|---|---|
| binary16 (FP16) | 16 | 1 | 5 | 10 | 15 | 65504 | ~3.3 |
| bfloat16 | 16 | 1 | 8 | 7 | 127 | ≈3.39×10³⁸ | ~2.3 |
| binary32 (FP32) | 32 | 1 | 8 | 23 | 127 | ≈3.40×10³⁸ | ~7.2 |
| binary64 (FP64) | 64 | 1 | 11 | 52 | 1023 | ≈1.80×10³⁰⁸ | ~15.9 |
What Is IEEE 754 Floating Point?
IEEE 754 is the standard that defines how computers store real numbers in binary. Every value is packed into three fields: a sign bit, an exponent (stored with a bias so it can represent both large and tiny magnitudes), and a mantissa holding the significant digits. Almost every CPU, GPU, and programming language uses it, which is why the same rounding surprises appear in JavaScript, Python, C, and SQL alike.
The key insight is that binary floating point can only represent numbers of the form m × 2ⁿ. Decimal fractions like 0.1 are infinite repeating fractions in base 2 — 0.000110011001100… — so the format stores the nearest representable neighbor instead. In single precision that neighbor is 0.100000001490116119384765625; in double precision it is 0.1000000000000000055511151231257827021181583404541015625. Neither is 0.1. Every downstream oddity — 0.1 + 0.2 ≠ 0.3, sums that drift, equality checks that fail — follows from this single fact, and this converter makes it visible by printing the exact stored value rather than a rounded-back approximation. The same drift shows up whenever floats round-trip through JSON — inspect the payload with the JSON formatter and the bits here.
The standard also reserves bit patterns for special values. An all-ones exponent encodes ±Infinity (mantissa zero) or NaN (mantissa non-zero); an all-zeros exponent encodes signed zero (mantissa zero) or subnormal numbers (mantissa non-zero), which fill the underflow gap next to zero at reduced precision. The four formats this tool covers — binary16/FP16, bfloat16, binary32/FP32, binary64/FP64 — differ only in how many bits they give each field: more exponent bits mean more range, more mantissa bits mean more precision. bfloat16, the machine-learning favorite, is simply FP32 with the bottom 16 mantissa bits cut off: same range, much coarser precision.
A useful mental model is that representable floats form a grid on the number line whose spacing — one unit in the last place, or ULP — doubles at every power of two. Near 1.0 a double's grid spacing is about 2.22 × 10⁻¹⁶; near 2⁵³ it is a whole integer, which is why doubles cannot count beyond 2⁵³ reliably. The neighbors panel in this tool shows that grid directly: the previous and next representable values around whatever you type, with the exact gap between them.
// Float ↔ hex through the raw IEEE 754 bits (works in any browser / Node.js)
const buf = new DataView(new ArrayBuffer(8));
function floatToHex32(value) {
buf.setFloat32(0, value); // rounds to nearest even
return '0x' + buf.getUint32(0).toString(16).toUpperCase().padStart(8, '0');
}
function hexToFloat32(hex) {
buf.setUint32(0, parseInt(hex, 16));
return buf.getFloat32(0);
}
floatToHex32(0.1); // '0x3DCCCCCD'
floatToHex32(3.14159); // '0x40490FD0'
hexToFloat32('3DCCCCCD'); // 0.10000000149011612 Key Features
Four formats, one view
Half (FP16), bfloat16, Single (FP32), and Double (FP64) — switch with one click and the whole page recomputes, so comparing how the same number lands in each format takes seconds.
Clickable bit grid
Every bit is a button. Flip the sign, nudge the exponent, or poke a mantissa bit and watch the decimal, hex, and binary views update instantly — the fastest way to build intuition for the encoding.
Exact stored value, not an approximation
The tool computes the full decimal expansion of the stored bits with exact big-integer arithmetic — all 55 digits for a double's 0.1 — plus the exact signed rounding error against what you typed.
Neighbors and ULP
See the previous and next representable values around the current number and the exact gap (ULP) between them — the grid spacing that determines how much precision you actually have at any magnitude.
Special values, one click away
Chips load ±0, ±Infinity, NaN, the smallest subnormal, and the largest finite value of the selected format, with the classification badge naming what the current bit pattern encodes.
Shareable permalinks, zero upload
Copy link encodes the format and exact bit pattern into the URL — ideal for bug reports, code reviews, and teaching. Everything runs in your browser; nothing you type leaves the page.
IEEE 754 Conversion Examples
0.1 in single precision — the classic rounding error
0.1
0x3DCCCCCD — actually stored as 0.100000001490116119384765625
Decimal 0.1 has no finite binary representation, so IEEE 754 stores the nearest representable value instead. In single precision (FP32) that is 0x3DCCCCCD, which is exactly 0.100000001490116119384765625 — about 1.49 × 10⁻⁹ too large. The tool shows this exact stored value and the exact error, digit for digit, rather than the rounded '0.1' your programming language prints back at you. This one example explains most floating-point surprises, including why 0.1 + 0.2 does not equal 0.3.
Float to hex and hex to float: 3.14159 ⇄ 0x40490FD0
3.14159
0x40490FD0
Type 3.14159 with Single (FP32) selected and the hex field reads 0x40490FD0 — sign 0, biased exponent 128 (so 2¹), mantissa 0x490FD0. The value actually stored is 3.141590118408203125, a hair above what you typed. Hex form is what you see in network dumps, GPU buffers, register views, and serialized binary files, and hex to float works the same way: paste 40490FD0 into the hex field to decode it back.
FP16 maximum: 65504 is where half precision ends
65504
0x7BFF — the largest finite FP16 value
Half precision has only 5 exponent bits and 10 mantissa bits, so its largest finite value is 65504 (0x7BFF). Type 65520 or anything larger and the result rounds to Infinity (0x7C00) — a real hazard when quantizing machine-learning models to FP16. Switch to bfloat16 and the same 65520 fits easily, because bfloat16 keeps FP32's 8 exponent bits (range) while giving up mantissa bits (precision). That trade-off is exactly why ML training favors bfloat16 and compact storage favors FP16.
−0 and +0: two different bit patterns, one value
-0
0x80000000 (FP32), while +0 is 0x00000000
IEEE 754 has a signed zero: −0 sets only the sign bit (0x80000000 in FP32), while +0 is all zeros. They compare equal in every language, yet 1/−0 is −Infinity and 1/+0 is +Infinity, so the difference is observable. Click the sign bit in the tool to flip between them and watch the classification badge stay on Zero while the hex changes — a one-click illustration of why bit-level equality and numeric equality are different things.
How to Convert IEEE 754 Floating-Point Numbers
- 1
Choose a floating-point format
Single (FP32) is preselected. Switch to Double (FP64) for JavaScript/Python-style numbers, or Half (FP16) and bfloat16 for the 16-bit formats used in machine learning and graphics.
- 2
Type a decimal number
Enter any value — 0.1, -2.5e3, 65504 — or use the special-value chips for ±0, ±Infinity, NaN, the smallest subnormal, and the largest finite value. Conversion happens as you type.
- 3
Read the color-coded bit layout
The sign bit, exponent field, and mantissa are highlighted in different colors — the complete float to binary conversion at a glance — with the field breakdown table showing the raw bits, the bias arithmetic, and the implicit leading bit.
- 4
Check the exact stored value and error
The accuracy panel prints the value actually stored — every digit, computed exactly — alongside the rounding error against what you typed, plus the previous and next representable neighbors and the ULP gap.
- 5
Flip bits, paste hex, copy results
Click any bit to flip it, or paste hex (3DCCCCCD) and binary strings to decode them back to decimal. Copy the hex, the binary, the exact value, or a shareable link that reproduces the exact bit pattern.
Common Floating-Point Mistakes
Trusting the printed value instead of the stored one
Languages print floats rounded to the shortest string that round-trips, so 0.1 looks clean while the stored value is not. Judge precision by the exact expansion, not by what print() shows.
print(0.1) # 0.1 — looks exact, is not
0.1 stored (FP64) = 0.1000000000000000055511151231257827021181583404541015625
Comparing floats for exact equality
0.1 + 0.2 lands on bit pattern 0x3FD3333333333334 while the literal 0.3 is 0x3FD3333333333333 — one ULP apart, so == is false even though both print as 0.3-ish values.
if (0.1 + 0.2 === 0.3) { … } // never runs if (Math.abs(a - b) < 1e-9) { … } // tolerance sized to your data Quantizing to FP16 without checking the range
FP16's largest finite value is 65504. Anything bigger becomes Infinity, and once an Infinity enters a computation it propagates. Check your maxima before casting down — or use bfloat16, which keeps FP32's range.
fp16(65520) → Infinity (0x7C00) — silent overflow
bf16(65520) → finite (bfloat16 keeps 8 exponent bits)
Testing NaN with equality
NaN is the only value that is not equal to itself — that is by design, so a failed computation cannot masquerade as a real number. Use the language's isNaN check instead of ==, and remember there are millions of distinct NaN bit patterns.
if (x === NaN) { … } // always false, even when x IS NaN if (Number.isNaN(x)) { … } // the correct test What You Can Do with the IEEE 754 Converter
- Debug serialized binary data
- Paste the hex you found in a network capture, GPU buffer, register dump, or file format and decode it to the exact decimal value — or go the other way to write test fixtures. Byte-order note: the hex shown is the big-endian bit pattern — if your dump is little-endian, reverse the byte order before pasting.
- Understand ML quantization
- Check whether your values survive FP16's 65504 ceiling, compare FP16 against bfloat16 precision loss digit by digit, and inspect the subnormal range where gradients underflow.
- Explain a floating-point bug
- When a colleague asks why two 'equal' numbers differ, send a permalink showing both bit patterns and the exact stored values — the argument settles itself. Pair it with the text diff tool for longer dumps.
- Learn or teach the encoding
- Computer-architecture coursework becomes concrete when students can click the exponent bits and watch the bias arithmetic update. The field breakdown table mirrors how textbooks draw the format.
- Decode embedded and industrial registers
- Modbus, CAN, and sensor payloads routinely carry FP32 values as raw hex words. Paste the word here to convert the IEEE 754 hex to decimal and read the physical value without writing a scratch script.
IEEE 754 Formats & Special Values
- The four binary formats at a glance
- binary16 (FP16): 1 sign + 5 exponent + 10 mantissa bits, bias 15, max 65504, ~3.3 decimal digits. bfloat16: 1 + 8 + 7, bias 127, max ≈ 3.39 × 10³⁸, ~2.3 digits. binary32 (FP32): 1 + 8 + 23, bias 127, max ≈ 3.40 × 10³⁸, ~7.2 digits. binary64 (FP64): 1 + 11 + 52, bias 1023, max ≈ 1.80 × 10³⁰⁸, ~15.9 digits. The pattern: exponent bits buy range, mantissa bits buy precision, and bfloat16 deliberately trades all its precision for FP32's range.
- How a value is assembled
- A normal number decodes as (−1)^sign × 1.mantissa × 2^(exponent − bias). The leading 1 is implicit — it is not stored, which is why a 23-bit mantissa field delivers 24 bits of precision. The stored exponent is the true exponent plus the bias (127 in FP32), so 2⁰ is stored as 01111111. The field breakdown table in this tool shows each step of that arithmetic for the current value.
- Special values: the reserved exponent patterns
- Exponent all ones with mantissa zero is ±Infinity; with any non-zero mantissa it is NaN (the canonical quiet NaN sets the mantissa's top bit). Exponent all zeros with mantissa zero is ±0; with a non-zero mantissa it is a subnormal, decoded as 0.mantissa × 2^(1 − bias) — no implicit leading 1. These rules are identical across all four formats, which is why the same chips work in each.
- Rounding: nearest, ties to even
- When a value falls between two representable numbers, IEEE 754's default mode rounds to the nearer one; on an exact tie it picks the one whose last mantissa bit is 0 (ties to even), which prevents systematic drift. This converter applies exactly that rule when narrowing your decimal input into the target format, and the error panel shows the resulting signed difference exactly.
- ULP: the grid spacing of floats
- Representable floats are not evenly spread — the gap between neighbors (one unit in the last place) doubles at each power of two. Near 1.0 a double's ULP is 2⁻⁵² ≈ 2.22 × 10⁻¹⁶; near 2⁵³ the ULP reaches 1.0 and integers start to skip. The neighbors panel prints the current ULP exactly, which is the honest answer to 'how precise is my number here?'.
Floating-Point Best Practices
- Never compare floats with ==
- After any arithmetic, two mathematically equal expressions can sit one ULP apart. Compare against a tolerance appropriate to your magnitudes — or count ULPs between the bit patterns, which this tool lets you inspect directly.
- Keep money out of binary floats
- No power-of-two grid contains 0.10 exactly, so currency in floats accumulates visible errors. Use integer cents or a decimal type; the exact stored-value panel here is the standing proof of why.
- Pick the 16-bit format by range, not habit
- If your values can exceed 65504 — losses, gradients, physics spikes — FP16 will overflow to Infinity where bfloat16 sails on. If everything is normalized into a narrow band, FP16's extra mantissa bits give visibly better precision.
- Mind the double-rounding trap when narrowing
- Converting decimal → double → half can land one ULP away from converting decimal → half directly in rare halfway cases. This tool rounds your decimal input to the target format in a single step, so what you see is the honest IEEE 754 answer.
- Expect integers to break above 2⁵³
- A double stores every integer up to 2⁵³ exactly, then starts skipping — 2⁵³ + 1 is unrepresentable. If you handle IDs or counters near that scale, use 64-bit integers or strings, and check suspicious values here at the bit level.
IEEE 754 Converter FAQ
Why is 0.1 + 0.2 not equal to 0.3?
What is IEEE 754?
What is the difference between FP16 and bfloat16?
What are subnormal (denormal) numbers?
Should I use float or double?
How do I convert a float to hex by hand?
Is my data uploaded when I use this converter?
Related Tools
View all tools →Number Base Converter — Binary, Hex, Decimal & Octal
Conversion Tools
Convert between binary, hex, decimal, octal and any base (2-36) instantly. Free, private — all processing in your browser.
Color Converter — HEX, RGB, HSL & OKLCH
Conversion Tools
Convert HEX to RGB, HSL, OKLCH, OKLAB and CMYK in your browser — copy any format with one click. Free, no signup, your colors never leave the page.
Hex to CMYK Converter
Conversion Tools
Convert HEX colors to CMYK in your browser. Naive sRGB-based approximation for print previews. Free, no signup, your colors stay local.
Hex to HSL Converter
Conversion Tools
Convert any hex color to HSL in your browser — 3-digit, 6-digit, 8-digit alpha all supported. Free, instant, no signup, your colors never leave the page.
Hex to OKLCH Converter
Conversion Tools
Convert HEX to OKLCH for Tailwind v4 design tokens. Live perceptually-uniform output with Display P3 gamut warnings. Free, browser-only.
Hex to RGB Converter
Conversion Tools
Convert any hex color code to RGB in your browser — 3-digit, 6-digit, and 8-digit alpha hex all supported. Free, instant, no signup, your colors never leave the page.