UNIHIVE

Study Hub UNIPORT IFT 211

IFT 211 · Digital Logic Design

Floating-point representation

Scientific notation in binary, normalisation, and the IEEE 754 single-precision format.

Our notes

1 min read

Why floating point?

Fixed point cannot hold both very large and very small numbers. Floating point stores a number like scientific notation: value = (−1)^sign × mantissa × 2^exponent.

Normalisation

Move the binary point until there is a single 1 in front of it. 1011.01₂ = 1.01101 × 2³. Because the leading bit of a normalised binary number is always 1, IEEE 754 does not store it (the hidden bit).

IEEE 754 single precision (32 bits)

  • Sign: 1 bit.
  • Exponent: 8 bits, stored with a bias of 127 (stored value = true exponent + 127).
  • Fraction (mantissa): 23 bits after the hidden 1.

Double precision uses 1 + 11 + 52 bits with a bias of 1,023.

Worked example: decimal to IEEE 754

Store −13.25.

  • 13.25 = 1101.01₂ = 1.10101 × 2³.
  • Sign = 1. Exponent = 3 + 127 = 130 = 1000 0010.
  • Fraction = 10101 followed by eighteen 0s.
  • Bits: 1 10000010 10101000000000000000000 = C1540000₁₆.

Worked example: IEEE 754 to decimal

Decode 0 01111110 10000000000000000000000.

  • Sign 0 (positive). Exponent 126 − 127 = −1. Mantissa 1.1₂ = 1.5.
  • Value = 1.5 × 2⁻¹ = 0.75.

Special values

  • Exponent all 0s and fraction 0: zero (+0 and −0 exist).
  • Exponent all 0s, fraction not 0: very small "denormal" numbers.
  • Exponent all 1s, fraction 0: ±infinity (from 1 ÷ 0).
  • Exponent all 1s, fraction not 0: NaN ("not a number", from 0 ÷ 0).

Precision and rounding

Single precision gives about 7 significant decimal digits; double gives about 15 to 16. Numbers like 0.1 are stored rounded, so comparing floats for exact equality is risky: test whether the difference is very small instead.

Range

The largest single-precision number is about 3.4 × 10³⁸; the smallest normalised positive one is about 1.18 × 10⁻³⁸.

Fixed against floating point

Floating point gives range at the cost of more complex hardware and rounding error; fixed point is exact within its small range and simpler.

Exams usually ask

  • Convert a decimal number to IEEE 754 single precision and back.
  • Explain bias, normalisation and the hidden bit.

Common mistake

Storing the true exponent instead of exponent + 127, or including the hidden 1 in the 23 fraction bits.

Written by the UniHive team in our own words. Spotted a mistake? Tell us on WhatsApp.

Read

Watch

We link to free material and never copy it. Every link was opened by our team before it went up; video data is a rough guide at 360p.

All IFT 211 topics

Report

Sign in to report this. It is free.

Is this your work (a lecturer, author or publisher)? Ask us to take it down.