Advanced Data Representation and File Organisation: Question 5

Syllabus 13.3

Structured A2 11 marks

Two floating-point systems each use a 12-bit word, split between the mantissa and the exponent (both held in two's complement form, with the mantissa's binary point immediately to the right of its sign bit):

  • System P: 8 bits for the mantissa, 4 bits for the exponent.
  • System Q: 6 bits for the mantissa, 6 bits for the exponent.

(a) State, with a reason, which system can represent a given real number to greater precision. [2]

(b) State, with a reason, which system can represent real numbers over a wider range of magnitudes. [2]

(c) Explain what is meant by overflow in a binary floating-point system, and describe the situation that causes it in System P. [2]

(d) Explain what is meant by underflow in a binary floating-point system, and describe the situation that causes it in System P. [2]

(e) The denary value 22.3 is stored in System P. Explain why this value cannot be represented exactly, and name the general type of error this produces. [3]

Show worked solution Hide worked solution

Worked solution

Part (a): Precision

Precision is about how finely a value can be approximated. How many significant bits are available to represent the fractional detail of the mantissa.

System P has 8 mantissa bits (7 fraction bits after the sign bit), compared with System Q’s 6 mantissa bits (5 fraction bits after the sign bit). More mantissa bits mean more binary places are available to approximate a value’s fractional part, so a given real number can be stored with a smaller rounding error.

System P gives greater precision, because it has more mantissa bits than System Q.

[2 marks]: [1] for identifying System P, [1] for the correct reason (more mantissa bits → more significant bits → finer approximation).

Part (b): Range

Range is about how large or how small (close to zero) a magnitude can be represented at all. This is controlled by the exponent, since the exponent scales the mantissa up or down by a power of 2.

System Q has 6 exponent bits, compared with System P’s 4 exponent bits. A 6-bit two’s complement exponent can range from -32 to +31, whereas a 4-bit two’s complement exponent can only range from -8 to +7. A larger maximum exponent lets Q represent much larger magnitudes, and a more negative minimum exponent lets Q represent much smaller (closer-to-zero) nonzero magnitudes.

System Q gives a wider range, because it has more exponent bits than System P.

[2 marks]: [1] for identifying System Q, [1] for the correct reason (more exponent bits → larger maximum and smaller minimum exponent → wider range of magnitudes).

Part (c): Overflow

Overflow occurs when a real number’s true magnitude is larger than the largest magnitude the system is able to represent, even using the largest available exponent together with the largest possible normalised mantissa, the value still cannot be reached.

In System P, the 4-bit two’s complement exponent has a maximum value of +7 (binary 0111). The largest normalised positive mantissa fraction (8 bits: sign 0 then 7 ones) is 0.1111111, worth 1 − 2⁻⁷ = 0.9921875. The largest magnitude System P can represent is therefore 0.9921875 × 2⁷ = 0.9921875 × 128 = 127 (just under 128). Any real number with a magnitude at or beyond this, for example 130, cannot be represented in System P at all: this is overflow.

[2 marks]: [1] for correctly explaining overflow (magnitude too large even at maximum exponent/mantissa), [1] for describing the System P situation (maximum exponent +7 and maximum mantissa still insufficient, e.g. around magnitude 127 and above).

Part (d): Underflow

Underflow occurs when a nonzero real number’s magnitude is smaller than the smallest magnitude the system is able to represent. Even using the smallest (most negative) available exponent together with the smallest possible normalised mantissa, the value is still too small to be distinguished from zero.

In System P, the 4-bit two’s complement exponent has a minimum value of −8 (binary 1000). The smallest normalised positive mantissa fraction is 0.1000000 (worth 0.5). It cannot be made smaller in fraction value and still be normalised, since a normalised positive mantissa must start with a 1 immediately after the sign bit. The smallest positive magnitude System P can represent is therefore 0.5 × 2⁻⁸ = 0.5 / 256 = 1/512 ≈ 0.00195. Any nonzero real number smaller than this in magnitude, for example 0.0005, cannot be represented in System P: this is underflow.

[2 marks]: [1] for correctly explaining underflow (nonzero magnitude too small even at minimum exponent/mantissa), [1] for describing the System P situation (minimum exponent −8 and smallest normalised mantissa still too large a scale, e.g. around magnitude 1/512 and below).

Part (e): Rounding error in 22.3

Denary 0.3 does not have a finite (terminating) binary representation. Converting it by repeatedly doubling the fractional part:

0.3 x 2 = 0.6  -> bit 0
0.6 x 2 = 1.2  -> bit 1
0.2 x 2 = 0.4  -> bit 0
0.4 x 2 = 0.8  -> bit 0
0.8 x 2 = 1.6  -> bit 1
0.6 x 2 = 1.2  -> bit 1   (0.6 has recurred, so the pattern now repeats)

So 0.3 = 0.0100110011...₂, a recurring binary fraction, just as 1/3 never terminates in decimal. Since 22.3 = 22 + 0.3, its binary expansion also recurs forever.

System P’s mantissa has only a fixed number of bits (7 fraction bits). A recurring binary expansion cannot fit into a fixed, finite number of bits, so it must be truncated or rounded to fit. The value actually stored is therefore only the closest value System P can represent, a very close approximation to 22.3, but not the exact value.

This general phenomenon. A binary floating-point representation only being an approximation to the true real number, because only a finite number of mantissa bits is available, is called a rounding error.

[3 marks]: [1] for identifying that 0.3’s binary expansion is recurring/non-terminating, [1] for linking this to the mantissa’s fixed, finite number of bits requiring truncation or rounding, [1] for correctly naming the resulting error as a rounding error.

Final answers

  • (a) System P, more mantissa bits give greater precision.
  • (b) System Q, more exponent bits give a wider range.
  • (c) Overflow: magnitude too large even at the maximum exponent (+7) and mantissa in System P (around 127 and above).
  • (d) Underflow: nonzero magnitude too small even at the minimum exponent (−8) and smallest normalised mantissa in System P (around 1/512 and below).
  • (e) 22.3’s fractional part (0.3) is a recurring binary fraction, so with only 7 mantissa fraction bits it must be rounded. This is a rounding error.