Skip to content

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.

No Tracking Runs in Browser Free
Everything runs locally in your browser — the values you type never leave this device.
Format
Special values
Bit layout — click any bit to flip it
Sign Exponent Mantissa
Field breakdown
Sign
Exponent
Mantissa
Stored value & rounding error
You entered
Actually stored
Rounding error
Neighboring representable values
Previous
Next
ULP (gap size)
IEEE 754 format parameters at a glance
Format Total bits Sign Exponent Mantissa Bias Max finite value Decimal digits
binary16 (FP16)1615101565504~3.3
bfloat1616187127≈3.39×10³⁸~2.3
binary32 (FP32)321823127≈3.40×10³⁸~7.2
binary64 (FP64)64111521023≈1.80×10³⁰⁸~15.9
Reviewed for numerical accuracy against IEEE 754-2019 format definitions; every example value verified with exact big-integer arithmetic — Go-Tools Engineering Team · Jul 16, 2026

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. 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. 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. 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. 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. 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.

✗ Wrong
print(0.1)  # 0.1 — looks exact, is not
✓ Correct
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.

✗ Wrong
if (0.1 + 0.2 === 0.3) { … }   // never runs
✓ Correct
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.

✗ Wrong
fp16(65520)   → Infinity (0x7C00) — silent overflow
✓ Correct
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.

✗ Wrong
if (x === NaN) { … }        // always false, even when x IS NaN
✓ Correct
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?
Because 0.1, 0.2 and 0.3 have no exact binary representation — a double stores the nearest representable value instead. 0.1 and 0.2 are each stored slightly high, so their sum lands one bit above the stored 0.3: bit pattern 0x3FD3333333333334 versus 0x3FD3333333333333, which is why 0.1 + 0.2 == 0.3 is false in JavaScript, Python, Java, C, Rust and Go. The double behind 0.1 is exactly 0.1000000000000000055511151231257827021181583404541015625, and the sum stored for 0.1 + 0.2 is 0.3000000000000000444089209850062616169452667236328125 — type 0.1 into this converter to read the stored value digit for digit.
What is IEEE 754?
IEEE 754 is the technical standard for binary floating-point arithmetic used by virtually every modern CPU, GPU, and programming language. It defines how a number is packed into bits — one sign bit, an exponent field, and a mantissa (significand) — plus the rounding rules and the special values Infinity, NaN, signed zero, and subnormals. The formats you will meet in practice are binary32 (float, FP32), binary64 (double, FP64), binary16 (half, FP16), and the related bfloat16 truncation used in machine learning. This converter shows all four at the bit level.
What is the difference between FP16 and bfloat16?
Both are 16-bit formats, but they split their bits differently. FP16 (IEEE binary16) uses 5 exponent bits and 10 mantissa bits: more precision, but a tiny range — the largest finite value is 65504, so overflow to Infinity is a constant hazard. bfloat16 keeps FP32's 8 exponent bits and only 7 mantissa bits: the full ±3.4 × 10³⁸ range of a float, with much coarser precision. That is why ML training, where gradients can spike far beyond 65504, standardized on bfloat16, while FP16 suits storage and inference where values are tamed. Compare them here: type 0.1 and switch formats — FP16 stores 0.0999755859375 (0x2E66), bfloat16 stores 0.10009765625 (0x3DCD).
What are subnormal (denormal) numbers?
When the exponent field is all zeros, IEEE 754 drops the implicit leading 1 and lets the mantissa shrink gradually toward zero — these are subnormal (older term: denormal) numbers. They fill the gap between zero and the smallest normal number, so the difference of two unequal floats can never round to zero (gradual underflow). The cost is reduced precision and, on many CPUs, slower arithmetic. In FP16 the smallest subnormal is 2⁻²⁴ = 0.000000059604644775390625; click the Min subnormal chip in any format to inspect its bit pattern — exponent bits all zero, mantissa 0…001.
Should I use float or double?
Default to double (FP64) unless you have a measured reason not to. A double carries about 15–16 significant decimal digits versus roughly 7 for a float, and most languages (JavaScript numbers, Python floats) are double-only anyway. Choose float (FP32) when memory bandwidth or storage dominates — large arrays, GPU pipelines, graphics — and you have confirmed 7 digits are enough. For money, use integers (cents) or a decimal type instead: no binary format stores 0.1 exactly, as the stored-value panel of this tool demonstrates. If you need to inspect integer bases instead, see the number base converter.
How do I convert a float to hex by hand?
Take the sign (0 for positive, 1 for negative). Write the absolute value in binary and normalize it to 1.xxx × 2ⁿ. Add the format's bias to n (127 for FP32, 1023 for FP64) and write that in the exponent bits. Drop the leading 1 and keep the next 23 (or 52) bits of the fraction as the mantissa, rounding to nearest even at the cut. Concatenate sign, exponent, mantissa and group each 4 bits into one hex digit. For 3.14159 in FP32 that yields 0 | 10000000 | 10010010000111111010000 → 0x40490FD0 — the same steps with bias 1023 and 52 mantissa bits turn a double to hex — or skip the arithmetic and let this converter do each step visibly.
Is my data uploaded when I use this converter?
No. Every conversion runs locally in your browser using plain JavaScript — DataView and BigInt arithmetic, no server round-trip, no third-party libraries. You can open your browser's developer tools, watch the network panel stay silent while you type, or disconnect from the internet entirely and keep converting. The Copy link button encodes the bit pattern into the URL fragment, which is likewise never sent to any server.

Related Tools

View all tools →