Skip to content
Adrien Hubert

IEEE 754, one bit at a time.

A single-precision float fits in 32 bits: one for the sign, eight for the exponent, twenty-three for the mantissa. Click any cell to flip a bit. Type a number into the box and the bits rearrange to encode it. The decoded value updates with every change.

Sign · 1 bit
Exponent · 8 bits · bias 127
Mantissa · 23 bits · implicit leading 1 when normal
Value
0 zero
Hex
0x00000000
Binary
0 00000000 00000000000000000000000
Formula
(-1)^0 × 0

The format

IEEE 754 binary32, the single-precision float, packs a real number into 32 bits as (-1)s · m · 2e. The sign bit picks the side of zero. The 8 exponent bits hold an unsigned integer with 127 subtracted to get the actual power of two, so 127 itself encodes 20. The 23 mantissa bits are the fractional part of a binary number that starts with an implicit 1, giving 24 bits of precision in roughly seven decimal digits.

The corners

Two exponent values are reserved. All-zero exponent encodes either signed zero or a subnormal, where the implicit leading 1 is dropped and the smallest representable steps live. All-one exponent encodes either infinity (mantissa zero) or a NaN payload (mantissa non-zero). Everything in between is a normal number with the implicit leading 1 present.

Why 0.1 misses

The number 0.1 has no exact binary expansion: in base two it is the repeating fraction 0.0001100110011… Single precision rounds it to 0.100000001490116119384765625. Hit the 0.1 preset and read the mantissa as a fraction; the gap is already visible at the 24th bit. The same rounding error is why 0.1 + 0.2 lands at the value shown in the third preset rather than at 0.3.