A-level Computer Science revision · Data representation

Floating-point arithmetic and precision

The idea

Adding floating-point numbers requires their exponents to be equal: shift right the mantissa of the number with the smaller exponent, then add and normalise. Increasing mantissa bits raises precision; increasing exponent bits raises range. Rounding errors happen because many fractions, such as 0.1, cannot be represented exactly.

  1. Match exponents before adding or subtracting.
  2. Normalise the result.
  3. Trade-off: more mantissa bits = precision, more exponent bits = range.

Watch out 0.1 cannot be stored exactly in binary, so comparisons of floating-point values can fail.

See it worked

Worked example

A fixed number of bits is split between mantissa and exponent. What is the effect of giving more bits to the mantissa?

  1. More mantissa bits: more significant figures.
  2. Fewer exponent bits: smaller range.
  3. Higher precision, smaller range.

Answer Greater precision but a smaller range

Your turn

Question 11 mark

What must be done before adding two floating-point numbers?

Choose one
Question 21 mark

Why might 0.1 + 0.2 not equal 0.3 exactly in a program?

Choose one
Question 32 marks

Explain the trade-off between range and precision in floating-point representation.

Write your answer, then see a model answer
  1. Describe the exponent's role.
  2. Describe the mantissa's role.

Answer With a fixed number of bits, more for the exponent gives a wider range of magnitudes but fewer mantissa bits, so less precision; and vice versa.

A-level Computer Science Pro, OCR H446

A-level Computer Science Pro

£119 once

Price rises to £199 on 1 January. Save £80 by joining before then.

At least 12 months of access

By paying you agree to our Terms and get access straight away, which ends your 14-day cancellation right.

No VAT is charged.

Independent practice for OCR A-level Computer Science (H446), not endorsed by OCR.

Privacy · Terms