IEEE 754 Floating Point Binary Representation

Understand IEEE 754 floating-point format: sign bit, exponent, and mantissa. Learn how decimals like 3.14 are stored in 32-bit and 64-bit binary formats.

Decimal (Floating Point)Binary (IEEE 754)Hardware

Detailed Explanation

IEEE 754 is the universal standard for representing floating-point numbers in binary. Every modern CPU, GPU, and programming language uses this format. Understanding it explains why 0.1 + 0.2 !== 0.3 in JavaScript and other languages.

The three components of IEEE 754:

A 32-bit (single precision) float has:

  • 1 sign bit: 0 = positive, 1 = negative
  • 8 exponent bits: biased by 127 (stored value = actual exponent + 127)
  • 23 mantissa bits: the fractional part (with an implied leading 1)

Step-by-step example — converting -6.75 to IEEE 754 single precision:

  1. Sign: Negative, so sign bit = 1
  2. Convert magnitude to binary: 6.75 = 110.11₂
  3. Normalize: 1.1011 x 2² (move decimal point so there is one 1 before it)
  4. Exponent: 2 + 127 (bias) = 129 = 10000001₂
  5. Mantissa: 1011 (drop the leading 1, pad with zeros to 23 bits): 10110000000000000000000
  6. Assemble: 1 10000001 10110000000000000000000

In hex: 0xC0D80000.

Why floating point has precision issues:

Just as 1/3 cannot be exactly represented in decimal (0.333...), many decimal fractions like 0.1 cannot be exactly represented in binary. The decimal 0.1 in binary is 0.0001100110011... (repeating), which gets truncated to fit the 23-bit mantissa. This truncation causes the famous floating-point rounding errors.

Special values in IEEE 754:

  • Zero: exponent and mantissa all zeros (positive and negative zero exist)
  • Infinity: exponent all ones, mantissa all zeros
  • NaN: exponent all ones, mantissa non-zero
  • Denormalized: exponent all zeros, mantissa non-zero (numbers very close to zero)

Understanding IEEE 754 is essential for scientific computing, graphics programming, and any application where numerical precision matters.

Use Case

Game developers and graphics programmers analyze IEEE 754 representation to understand precision loss in physics simulations and optimize floating-point operations on GPU shaders.

Try It — Number Base Converter

Open full tool