9618/32

Computer Science 9618/32October/November 2022

Cambridge A-Level · Advanced Theory · worked solutions for every part, with the mark scheme

11
questions
75
marks
90
minutes

Topics Data Representation · System Software · Hardware and Virtual Machines · Communication and Internet Technologies · Security · Artificial Intelligence (AI) · +2 more

Q1Data RepresentationFree sample

Normalised floating-point numbers are stored in a computer system using two’s complement for both the mantissa and the exponent with:

• 11 bits for the mantissa
• 5 bits for the exponent.

(a)

Write the largest positive two’s complement binary number that can be stored in this system.

1M
DifficultyEasy
Worked solution

Answer

Mantissa: 01111111111

Exponent: 01111

Final answer

Mantissa 01111111111, Exponent 01111

Detailed explanation

Background Concept

In this format, the floating-point number is split into two fields:

  • the mantissa, which stores the signed significant part of the number
  • the exponent, which stores the signed power of 2

Both fields use two's complement. For a positive two's complement value, the leftmost bit is 0. For a negative value, the leftmost bit is 1.

A normalised floating-point mantissa must use the available bits efficiently. In two's complement floating point, a positive normalised mantissa begins 01... and a negative normalised mantissa begins 10.... This ensures the value is stored in standard form and is not wasting leading bits.

To get the largest positive floating-point number, we need:

  • the largest possible positive normalised mantissa
  • the largest possible positive exponent

Understanding the Question

You are given:

  • an 11-bit mantissa
  • a 5-bit exponent
  • both stored in two's complement

The question asks for the largest positive number that can be stored in this floating-point system, so you are not just finding the largest two's complement integer. You must consider both fields.

That means:

  1. choose the greatest valid positive normalised mantissa
  2. choose the greatest positive exponent

Approach

For the mantissa:

  • because it must be positive, it starts with 0
  • because it must be normalised, the next bit must be 1
  • to make it as large as possible, every remaining mantissa bit should be 1

For the exponent:

  • use the largest positive 5-bit two's complement value
  • that is a leading 0 followed by as many 1s as possible

Step-by-Step Reasoning

The mantissa has 11 bits.

  • Bit 1 is the sign bit, so for a positive mantissa it is 0
  • For a positive normalised mantissa, bit 2 must be 1
  • To maximise the value, fill the remaining 9 bits with 1

So the mantissa is:

01111111111

Now the exponent has 5 bits and is also in two's complement.

The largest positive 5-bit two's complement value is:

01111

So the largest positive floating-point number that can be stored has:

  • mantissa 01111111111
  • exponent 01111

Key Takeaways

  • In two's complement floating point, a positive normalised mantissa starts 01.
  • The largest positive value uses the largest positive mantissa and the largest positive exponent.
  • For an nn-bit two's complement integer field, the largest positive value has the pattern 0 followed by 1s.

Common Mistakes

  • Writing an unnormalised positive mantissa such as 00111111111. This is positive, but not normalised.
  • Using 11111 for the exponent. In two's complement this is -1, not the largest positive value.
  • Treating the mantissa as an ordinary integer instead of a normalised floating-point field.

Things to Be Careful About

  • The question is about the largest positive number in the floating-point system, not just the largest mantissa.
  • The mantissa and exponent are stored separately, so each field must be maximised correctly.
  • Normalisation matters: the mantissa must follow the correct 01... pattern for a positive value.
Techniques used
identify the maximum positive two's complement exponentapply the normalised mantissa pattern for a positive valuefill remaining magnitude bits with 1s to maximise the value
(b)

Calculate the denary value of the given binary floating-point number.
Show your working.

MantissaExponent
1011001001101001

Working .....................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

Answer ......................................................................................................................................

3M
DifficultyMedium
Worked solution

Working

Exponent:

010012=91001001_2 = 9_{10}

Mantissa:

101100100112=1+22+23+26+29+210=0.606445312510110010011_2 = -1 + 2^{-2} + 2^{-3} + 2^{-6} + 2^{-9} + 2^{-10} = -0.6064453125

Value:

0.6064453125×29=310.5-0.6064453125 \times 2^9 = -310.5

Answer

-310.5

Final answer

-310.5

Detailed explanation

Background Concept

A binary floating-point number stores a value in the form:

mantissa×2exponent\text{mantissa} \times 2^{\text{exponent}}

In this question, both the mantissa and the exponent use two's complement.

For the exponent, this works in the usual way:

  • leading 0 means positive
  • leading 1 means negative

For the mantissa, the binary point is assumed to be immediately after the sign bit. So an 11-bit mantissa represents a signed fractional value in the range from 1-1 up to just less than +1+1.

In two's complement fractional form:

  • the sign bit has weight 1-1
  • the remaining bits have weights 12,14,18,\frac{1}{2}, \frac{1}{4}, \frac{1}{8}, \dots

So to convert the mantissa to denary, you add the weights of the 1 bits, remembering that the first bit contributes 1-1 if it is 1.

Understanding the Question

You are given one floating-point value split into:

  • mantissa: 10110010011
  • exponent: 01001

You must calculate the denary value and show working.

So there are two separate tasks:

  1. convert the exponent to denary
  2. convert the mantissa to denary as a two's complement fraction
  3. combine them using mantissa×2exponent\text{mantissa} \times 2^{\text{exponent}}

Approach

Start with the easier field: the exponent.

  • 01001 is a positive two's complement number, so convert it directly to denary

Then evaluate the mantissa.

  • because the first bit is 1, the mantissa is negative
  • use the fractional place values after the sign bit
  • add the place values for the bits that are 1

Finally, multiply the mantissa value by 292^9.

Step-by-Step Reasoning

First, convert the exponent 01001.

Because the first bit is 0, it is positive.

010012=8+1=901001_2 = 8 + 1 = 9

So the exponent is 99.

Now convert the mantissa 10110010011.

The first bit is 1, so this is a negative two's complement fraction. The weights are:

  • first bit: 1-1
  • then 12,14,18,116,132,164,1128,1256,1512,11024\frac{1}{2}, \frac{1}{4}, \frac{1}{8}, \frac{1}{16}, \frac{1}{32}, \frac{1}{64}, \frac{1}{128}, \frac{1}{256}, \frac{1}{512}, \frac{1}{1024}

Now match the 1 bits:

1 0 1 1 0 0 1 0 0 1 1

So the value is:

1+14+18+164+1512+11024-1 + \frac{1}{4} + \frac{1}{8} + \frac{1}{64} + \frac{1}{512} + \frac{1}{1024}

Now add those positive parts:

14=0.25,18=0.125,164=0.015625,1512=0.001953125,11024=0.0009765625\frac{1}{4} = 0.25, \quad \frac{1}{8} = 0.125, \quad \frac{1}{64} = 0.015625, \quad \frac{1}{512} = 0.001953125, \quad \frac{1}{1024} = 0.0009765625 0.25+0.125+0.015625+0.001953125+0.0009765625=0.39355468750.25 + 0.125 + 0.015625 + 0.001953125 + 0.0009765625 = 0.3935546875

Therefore:

1+0.3935546875=0.6064453125-1 + 0.3935546875 = -0.6064453125

Now apply the exponent:

0.6064453125×29=0.6064453125×512=310.5-0.6064453125 \times 2^9 = -0.6064453125 \times 512 = -310.5

So the denary value is:

-310.5

Key Takeaways

  • A floating-point value is found using mantissa×2exponent\text{mantissa} \times 2^{\text{exponent}}.
  • In a two's complement mantissa, the binary point is after the sign bit.
  • The sign bit of a fractional two's complement mantissa has weight 1-1.
  • Always convert the mantissa and exponent separately before combining them.

Common Mistakes

  • Treating the mantissa as an ordinary 11-bit integer. It is a fractional two's complement value here.
  • Forgetting that the first mantissa bit has weight 1-1, not +1+1.
  • Converting the exponent correctly but then shifting the mantissa the wrong number of places.
  • Ignoring the negative sign of the mantissa and giving a positive final answer.

Things to Be Careful About

  • The mantissa is not stored as a whole number; the binary point is immediately after the sign bit.
  • Do not use unsigned place values for a two's complement mantissa.
  • Keep enough accuracy during the conversion before multiplying by 292^9.
  • If you use an alternative valid method, such as converting the mantissa by two's complement then applying the fractional place values, the final value must still be -310.5.
Techniques used
decode the exponent from two's complementevaluate a fractional two's complement mantissamultiply the mantissa by a power of two
(c)

State when underflow occurs in a binary floating-point system.

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

.............................................................................................................................................

2M
DifficultyMedium-Easy
Worked solution

Answer

  • Underflow occurs when a value is too close to 0 to be represented in the available floating-point format.
  • This happens when the exponent needed is smaller than the minimum negative exponent that can be stored.
Final answer

A value is too small to be represented; the required exponent is below the minimum available.

Detailed explanation

Background Concept

A floating-point system can only represent numbers within a limited range.

There is:

  • a largest positive value it can store
  • a most negative value it can store
  • and also a smallest non-zero magnitude it can store

If a number is too large to fit, overflow occurs.
If a number is too small in magnitude to fit, underflow occurs.

Underflow is therefore about numbers that are very close to zero. In a binary floating-point system, this usually means the number would need an exponent smaller than the most negative exponent available in the exponent field.

Understanding the Question

The question asks you to state when underflow occurs.

So you do not need an example or a long description. You need a concise condition:

  • the value is too small to be represented
  • the required exponent is beyond the lower limit of the system

Approach

A good answer should include both ideas:

  1. the number's magnitude is smaller than the smallest representable non-zero value
  2. the exponent required would be less than the minimum exponent that can be stored

That covers both the practical effect and the reason it happens.

Step-by-Step Reasoning

In floating-point storage, the mantissa and exponent have fixed numbers of bits. Because of this, there is a minimum allowed exponent.

If a calculation produces a value such as:

very small mantissa×2very negative exponent\text{very small mantissa} \times 2^{\text{very negative exponent}}

and that exponent is more negative than the system can store, then the true value lies below the smallest non-zero number the format can represent.

That situation is called underflow.

So the correct statement is that underflow happens when the value is too close to zero to fit in the floating-point format, or equivalently when the exponent needed is smaller than the minimum exponent available.

Key Takeaways

  • Underflow means a non-zero result is too small in magnitude to be represented.
  • It is the opposite end of the range problem from overflow.
  • In floating point, underflow is usually caused by needing an exponent below the minimum allowed value.

Common Mistakes

  • Saying underflow means the number is too large. That describes overflow, not underflow.
  • Saying simply "the number cannot be stored" without explaining that it is because it is too small or too close to zero.
  • Confusing underflow with rounding error. Rounding error is loss of precision; underflow is failure to represent a very small value at all.

Things to Be Careful About

  • Use the idea of small magnitude or too close to zero, not just "small" in a vague sense.
  • Mention the exponent limit if you want the stronger answer.
  • Do not describe underflow as an error in arithmetic; it is a representational limit of the floating-point format.
Techniques used
relate underflow to representable rangeidentify when the required exponent is below the minimum availablestate the effect on very small values

The rest of this paper

10 more questions
  • Q2System Software4M
  • Q3Communication and Internet Technologies6M
  • Q4Data Representation10M
  • Q5Hardware and Virtual Machines6M
  • Q6Security6M
  • Q7Artificial Intelligence (AI)4M
  • Q8Hardware and Virtual Machines8M
  • Q9System Software9M
  • Q10Further Programming6M
  • Q11Computational Thinking and Problem-solving10M
Loading the full paper…