Skip to content
K Knidox Search…
Computer Science · Number Systems

IEEE 754 Float Converter

See the sign, exponent, and mantissa bits behind any 32-bit float.

The number to encode as a 32-bit single-precision float.
Try a value
32-bit pattern (sign · exponent · mantissa)
0 01111111 00000000000000000000000

Stored value: 1.

Sign
0positive
Exponent
127 (unbiased +0)
Hex word
0x3F800000
0
sign
01111111
exponent (8)
00000000000000000000000
mantissa (23)

32-bit layout: sign · exponent · mantissa

A 32-bit IEEE 754 float packs a number into 1 sign bit, 8 exponent bits (stored with a bias of 127), and 23 mantissa bits. For example, 1.0 becomes 0 01111111 00000000000000000000000: sign 0 (positive), exponent 127 which unbiases to 0, and a mantissa of all zeros representing the implied 1.0.

How a float is laid out

Single-precision floating point stores a real number in 32 bits split into three fields. The sign is one bit: 0 for positive, 1 for negative. The exponent is 8 bits holding a power of two, but offset by a bias of 127 so it can represent both large and tiny magnitudes without a separate sign — the stored value 127 means an actual exponent of 0. The mantissa (also called the fraction or significand) is 23 bits giving the digits after an implicit leading 1. Because that leading 1 is assumed, you effectively get 24 bits of precision — about 7 decimal digits.

value = (−1)sign × 1.mantissa × 2(exponent − 127)

Single precision: 1 sign bit · 8 exponent bits (bias 127) · 23 mantissa bits

Worked example: 0.15625

This value encodes exactly, which makes it a clean walkthrough of the three fields.

  1. 1
    Read the sign bit. 0.15625 is positive, so the sign bit is 0, giving (−1)⁰ = +1.
  2. 2
    Read the 8 exponent bits. The exponent field is 01111100 = 124. Subtract the bias: 124 − 127 = −3, so the power of two is 2⁻³.
  3. 3
    Read the 23 mantissa bits. The mantissa is 01000000000000000000000, and with the implicit leading 1 the significand is 1.01₂ = 1.25.
  4. 4
    Combine the fields. value = +1 × 1.25 × 2⁻³ = 1.25 ÷ 8 = 0.15625, matching the input exactly.

Single-precision field layout

The 32 bits, read left to right, split into three fixed-width fields.

FieldBitsMeaning
Sign10 = positive, 1 = negative
Exponent8Power of two, stored with a bias of 127 (range 0–255)
Mantissa23Fraction after the implicit leading 1 (the significand)

Why 0.1 is not exact, and the special values

Binary floating point can only represent sums of powers of two, so any value whose exact form needs an infinite binary expansion gets rounded to the nearest representable number. 0.1 is such a value: in binary it repeats forever (0.0001100110011…₂), so float32 stores roughly 0.10000000149, not 0.1 exactly. That tiny error is why 0.1 + 0.2 famously does not equal 0.3 on a computer. The tool shows the actual stored value, so you can see the rounding whenever it happens.

Two exponent patterns are reserved. An all-zero exponent marks zero (mantissa all zeros) or a subnormal number that fills the gap just above zero. An all-ones exponent (255) marks Infinity when the mantissa is zero and NaN — Not a Number — when it is not. Double precision (64-bit) uses the same scheme with an 11-bit exponent (bias 1023) and a 52-bit mantissa, giving about 15–16 decimal digits instead of 7, which is why most languages default to it.

Why isn’t 0.1 exact in a float?
0.1 has no finite representation in base 2 — it repeats as 0.0001100110011…₂. Float32 rounds it to the nearest representable value, about 0.10000000149, which is why sums like 0.1 + 0.2 land slightly off 0.3.
What is the exponent bias and why 127?
The 8-bit exponent is stored as an unsigned number, so a bias of 127 is subtracted when reading it. This lets a single field cover exponents from −126 to +127 without a separate sign bit. Storing 127 means an actual exponent of 0.
What is the implicit leading 1 in the mantissa?
Normalised floats always start with a 1 before the binary point, so that bit is not stored — it is assumed. The 23 stored mantissa bits are the digits after it, giving 24 bits of effective precision from only 23 bits of storage.
How does the tool get the exact bits?
It writes your number into a Float32Array (a real 32-bit float) and reads the same memory back as a 32-bit unsigned integer via a DataView. That reproduces the hardware’s own rounding, so the bit pattern and stored value match what a C or Java float would hold.
How are Infinity and NaN represented?
Both use an all-ones exponent (255). If every mantissa bit is 0 the value is Infinity (positive or negative by the sign bit); if any mantissa bit is 1 it is NaN, produced by operations like 0 ÷ 0 or the square root of a negative number.
What is the difference between single and double precision?
Single precision (float32) uses 8 exponent bits and 23 mantissa bits for about 7 decimal digits. Double precision (float64) uses 11 exponent bits and 52 mantissa bits for about 15–16 digits, at the cost of twice the storage.