Cambridge A-Level Computer Science (9618) · lesson 3 of 15 · 35 min
Why Floating-Point?
Integers cannot represent fractions or very large/small numbers efficiently. Floating-point uses scientific notation in binary: a mantissa (significand) and an exponent.
Value = mantissa × 2^exponent
IEEE 754 Single Precision (32-bit)
The bias allows the exponent field to represent both positive and negative exponents using an unsigned integer. Bias = 127 for 32-bit; bias = 1023 for 64-bit.
Normalisation
A floating-point number is normalised when the mantissa is in the form 1.xxx (for positive) — the leading bit is always 1 (implicit). This maximises precision by using all mantissa bits for significant digits.
Denormalised numbers: Very small numbers close to zero where the leading bit is 0 — used to represent values smaller than the minimum normalised value.
Precision and Range Trade-off
More exponent bits → wider range. More mantissa bits → higher precision. With a fixed total bit count, there is always a trade-off.
Rounding errors: Not all decimal fractions can be represented exactly in binary floating-point (e.g. 0.1 in binary is a repeating fraction). This causes small rounding errors that accumulate in calculations.
In IEEE 754 single precision, how many bits are used for the mantissa?
- 8
- 16
- 23
- 24
Answer: 23
IEEE 754 single precision: 1 sign + 8 exponent + 23 mantissa = 32 bits.
What is the purpose of the exponent bias in floating-point?
- To increase precision
- To allow both positive and negative exponents using an unsigned field
- To store the sign of the number
- To normalise the mantissa
Answer: To allow both positive and negative exponents using an unsigned field
The bias (127 for 32-bit) allows the unsigned exponent field to represent negative exponents.
Increasing the number of mantissa bits in a floating-point format:
- Increases the range
- Increases the precision
- Decreases the precision
- Has no effect
- Answer: 1
More mantissa bits means more significant digits — higher precision.
Previous lesson: Signed integers: two’s complement and BCD
Back to Cambridge A-Level Computer Science (9618)
Next lesson: Error detection: parity, checksums, and CRC