9618/32

Computer Science 9618/32May/June 2021

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

9
questions
75
marks
90
minutes

Topics Data Representation · System Software · Computational Thinking and Problem-solving · Artificial Intelligence (AI) · Communication and Internet Technologies · Hardware and Virtual Machines · +1 more

Q1Data RepresentationFree sample

Real numbers are stored in a computer system using floating-point representation with:

• 10 bits for the mantissa
• 6 bits for the exponent
• Two’s complement form for both the mantissa and the exponent.

(a)

Calculate the normalised floating-point representation of –7.25 in this system.
Show your working.

MantissaExponent
3M
DifficultyMedium
Worked solution

Working

7.25=111.012-7.25 = -111.01_2

Normalised form:

111.012=0.111012×23-111.01_2 = -0.11101_2 \times 2^3

Positive mantissa would be 0111010000, so in two’s complement the mantissa is 1000110000.

Exponent 3 in 6-bit two’s complement is 000011.

Answer

MantissaExponent
1 0 0 0 1 1 0 0 0 00 0 0 0 1 1
Final answer

Mantissa 1000110000, Exponent 000011

Detailed explanation

Background Concept

In this floating-point system, a number is stored as:

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

Both the mantissa and exponent use two’s complement.

For Cambridge-style binary floating-point questions, the binary point in the mantissa is taken to be immediately after the sign bit. So a 10-bit mantissa like 0111010000 represents the binary fraction 0.111010000.

A normalised mantissa must start with different first two bits:

  • positive normalised numbers start 01...
  • negative normalised numbers start 10...

This ensures the value is shifted as far left as possible without changing its sign.

Understanding the Question

You are given the format:

  • 10 bits for the mantissa
  • 6 bits for the exponent
  • two’s complement for both

The task is to store -7.25 in this format and show the working. That means you must:

  1. convert -7.25 to binary
  2. write it in normalised form
  3. store the mantissa in 10-bit two’s complement
  4. store the exponent in 6-bit two’s complement

Approach

Start by converting the denary number to binary. Then rewrite it so that the mantissa is a binary fraction with the point immediately after the sign bit. Once it is in the form mantissa × 2^exponent, encode each field with the required number of bits.

For a negative mantissa, it is usually easiest to:

  • write the positive normalised mantissa first
  • then take its two’s complement

Step-by-Step Reasoning

First convert 7.25 to binary:

  • 7 is 111₂
  • 0.25 is 0.01₂

So:

7.25=111.0127.25 = 111.01_2

Because the number is negative:

7.25=111.012-7.25 = -111.01_2

Now normalise it. We want a mantissa with the binary point after the sign bit:

111.012=0.111012×23-111.01_2 = -0.11101_2 \times 2^3

So the exponent is 3.

Now write the positive version of the mantissa in 10 bits. Since the sign bit is included, the positive mantissa is:

0111010000

This represents 0.111010000.

But the number is negative, so convert this mantissa to two’s complement:

  1. invert bits: 1000101111
  2. add 1: 1000110000

So the 10-bit mantissa is:

1000110000

Now encode the exponent. The exponent is +3, and in 6-bit two’s complement that is simply:

000011

So the final stored floating-point number is:

  • Mantissa: 1000110000
  • Exponent: 000011

Key Takeaways

  • In this syllabus, the mantissa is a signed binary fraction with the binary point after the sign bit.
  • A normalised positive mantissa starts 01; a normalised negative mantissa starts 10.
  • For negative mantissas, write the positive mantissa first, then convert it to two’s complement.
  • The exponent is stored separately and also needs the correct bit width.

Common Mistakes

  • Writing 111.01 × 2^0 and calling it normalised. That is not normalised in this format.
  • Forgetting that the mantissa is stored as a fraction, not as an integer.
  • Using sign-magnitude instead of two’s complement for the negative mantissa.
  • Giving the exponent as 11 or 00011 instead of the full 6-bit 000011.

Things to Be Careful About

  • Count the mantissa bits carefully: there are 10 in total, including the sign bit.
  • Count the exponent bits carefully: there are 6 in total.
  • Normalisation must preserve the value, so every left shift in the mantissa changes the exponent accordingly.
  • Do not forget trailing zeros when padding to the required field width.
Techniques used
convert denary to binarywrite the value in normalised floating-point formencode the mantissa in two's complementencode the exponent in two's complement
(b)

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

MantissaExponent
1 0 1 1 0 0 0 1 1 10 0 0 1 1 1
3M
DifficultyMedium
Worked solution

Working

Mantissa 1011000111 is negative.

Two’s complement of 1011000111:

  • invert: 0100111000
  • add 1: 0100111001

So mantissa = -0.100111001_2.

Exponent 000111 = 7.

0.1001110012×27=1001110.012-0.100111001_2 \times 2^7 = -1001110.01_2 1001110.012=78.25-1001110.01_2 = -78.25

Answer

Denary value = -78.25

Final answer

-78.25

Detailed explanation

Background Concept

To find the denary value of a floating-point number, decode each field separately:

  1. decode the mantissa as a two’s complement binary fraction
  2. decode the exponent as a two’s complement integer
  3. calculate
mantissa×2exponent\text{mantissa} \times 2^{\text{exponent}}

A mantissa in two’s complement with leading 1 is negative. The usual method is to take its two’s complement to find the positive magnitude, then attach the negative sign.

Understanding the Question

You are given:

  • Mantissa = 1 0 1 1 0 0 0 1 1 1
  • Exponent = 0 0 0 1 1 1

You must convert that stored floating-point number into its denary value. Since the mantissa begins with 1, the key issue is recognising that it is negative and decoding it properly.

Approach

First decode the exponent, because that is usually quick. Then decode the mantissa. After that, apply the power of 2 indicated by the exponent. A good way to show working is to convert the negative mantissa into its positive magnitude using two’s complement, then multiply by 2^7 by shifting the binary point.

Step-by-Step Reasoning

The exponent is 000111.

Because the leading bit is 0, it is positive, so:

0001112=7000111_2 = 7

Now decode the mantissa 1011000111.

Because the leading bit is 1, it is negative.

Take two’s complement to find the magnitude:

  • original: 1011000111
  • invert: 0100111000
  • add 1: 0100111001

So the magnitude is 0.100111001₂, meaning the mantissa is:

0.1001110012-0.100111001_2

Now apply the exponent:

0.1001110012×27-0.100111001_2 \times 2^7

Multiplying by 2^7 moves the binary point 7 places to the right:

1001110.012-1001110.01_2

Now convert that binary number to denary.

Integer part 1001110₂:

64+8+4+2=7864 + 8 + 4 + 2 = 78

Fractional part .01₂:

0.250.25

So the total is:

(78+0.25)=78.25-(78 + 0.25) = -78.25

Key Takeaways

  • A leading 1 in a two’s complement mantissa means the mantissa is negative.
  • Decode the negative mantissa by taking its two’s complement.
  • The exponent tells you how far to shift the binary point.
  • After shifting, convert the resulting binary number to denary normally.

Common Mistakes

  • Treating the mantissa as an unsigned or sign-magnitude value instead of two’s complement.
  • Forgetting that the mantissa is a fraction, so the binary point is after the sign bit.
  • Decoding the exponent wrongly because of confusion about two’s complement.
  • Shifting the binary point the wrong number of places.

Things to Be Careful About

  • When taking two’s complement, do both steps: invert and add 1.
  • Keep the negative sign with the mantissa after decoding it.
  • Do not convert 1011000111 directly as if it were an ordinary binary integer.
  • Show the final denary value clearly, including the negative sign.
Techniques used
decode a two's complement mantissadecode a two's complement exponentapply the floating-point value formulaconvert binary to denary
(c)

The given binary floating-point number is not normalised.

Normalise the floating-point number. Show your working.

MantissaExponent
0 0 0 0 0 0 0 1 1 11 0 0 1 1 1
MantissaExponent
3M
DifficultyMedium
Worked solution

Working

Mantissa 0000000111 represents 0.000000111_2.

Exponent 100111 is -25.

To normalise a positive mantissa, shift left until it starts 01:

00000001110111000000

This is 6 left shifts, so:

256=31-25 - 6 = -31

-31 in 6-bit two’s complement is 100001.

Answer

MantissaExponent
0 1 1 1 0 0 0 0 0 01 0 0 0 0 1
Final answer

Mantissa 0111000000, Exponent 100001

Detailed explanation

Background Concept

A floating-point number is normalised when the mantissa is shifted as far left as possible without changing the sign. In a two’s complement mantissa:

  • positive normalised numbers begin 01
  • negative normalised numbers begin 10

If a mantissa is not normalised, you shift it left until it becomes normalised. But shifting the mantissa left multiplies it by 2, so to keep the overall value unchanged, you must decrease the exponent by 1 for each left shift.

Understanding the Question

You are given a floating-point number whose mantissa is explicitly stated to be not normalised:

  • Mantissa = 0000000111
  • Exponent = 100111

You must rewrite it in normalised form without changing its value. So this is not about finding the denary value; it is about preserving the same number while moving the mantissa into valid normalised form.

Approach

First inspect the mantissa. Since it is positive, the normalised form must start 01. Count how many left shifts are needed to make that happen. Then subtract that same number from the exponent, because each left shift doubles the mantissa.

Finally, convert the new exponent back into the correct 6-bit two’s complement form.

Step-by-Step Reasoning

The mantissa is:

0000000111

Because the sign bit is 0, it is positive. Interpreted as a fraction, it is:

0.00000011120.000000111_2

This is not normalised, because it begins 00, not 01.

Now shift it left until the first two bits are 01.

Step by step:

  • 0000000111
  • 0000001110
  • 0000011100
  • 0000111000
  • 0001110000
  • 0011100000
  • 0111000000

So 6 left shifts are needed.

Now decode the exponent:

100111 is a 6-bit two’s complement number.

Its value is:

32+4+2+1=25-32 + 4 + 2 + 1 = -25

Because the mantissa was shifted left 6 places, the exponent must decrease by 6:

256=31-25 - 6 = -31

Now convert -31 into 6-bit two’s complement.

Positive 31 is:

011111

Invert:

100000

Add 1:

100001

So the new exponent is 100001.

The normalised floating-point number is therefore:

  • Mantissa = 0111000000
  • Exponent = 100001

Key Takeaways

  • A positive normalised mantissa must start 01.
  • Each left shift of the mantissa requires the exponent to decrease by 1.
  • Normalisation changes the representation, not the value.
  • Negative exponents must still be stored correctly in two’s complement.

Common Mistakes

  • Shifting the mantissa the wrong number of places.
  • Increasing the exponent instead of decreasing it after a left shift.
  • Forgetting that 100111 is negative in two’s complement.
  • Stopping at 0011100000, which is still not normalised because it starts 00.

Things to Be Careful About

  • Check the first two bits after normalisation, not just whether there is a 1 somewhere near the left.
  • Preserve the total field widths: 10 bits for mantissa, 6 bits for exponent.
  • Recalculate the exponent carefully after counting the shifts.
  • When encoding -31, make sure you use 6 bits exactly: 100001.
Techniques used
recognise a non-normalised mantissashift the mantissa left until normalisedadjust the exponent to preserve valueencode the new exponent in two's complement
(d)

The denary number 513 cannot be stored accurately as a normalised floating-point number in this computer system.

(i)

Explain the reason for this.

3M
DifficultyMedium
Worked solution

Answer

  • 513 = 1000000001_2.
  • In normalised form this is 0.1000000001_2 × 2^10.
  • The exponent 10 can be stored, but the mantissa needs 11 bits in total (sign bit plus 10 fractional bits).
  • Only 10 mantissa bits are available, so the final 1 cannot be stored and the value must be rounded.
Final answer

See explanation

Detailed explanation

Background Concept

Floating-point accuracy depends mainly on the number of bits available in the mantissa. The exponent controls range, while the mantissa controls precision.

A number can only be stored exactly if its normalised binary form fits completely into the mantissa field. If there are more significant bits than the mantissa can hold, the extra bits are lost. That causes rounding, so the stored value is only an approximation.

Understanding the Question

You are told that 513 cannot be stored accurately as a normalised floating-point number in this system. You must explain why.

The key clue is the word "accurately". This means the issue is not whether the value is too large overall, but whether the exact binary pattern fits into the mantissa without losing bits.

Approach

Convert 513 to binary, then normalise it. After that, count how many bits are needed in the mantissa. Compare that with the 10-bit mantissa available in the system.

If the exact normalised mantissa needs more bits than the field provides, that proves why the number cannot be stored exactly.

Step-by-Step Reasoning

First convert 513 to binary.

Since 512 = 2^9, we have:

513=512+1=10000000012513 = 512 + 1 = 1000000001_2

Now normalise it:

10000000012=0.10000000012×2101000000001_2 = 0.1000000001_2 \times 2^{10}

The exponent is 10, which is not the problem. A 6-bit two’s complement exponent can store 10 easily.

The problem is the mantissa.

The exact normalised mantissa is:

0.1000000001

That needs:

  • 1 sign bit
  • 10 fractional bits after the binary point

So it needs 11 bits in total.

But the system only has a 10-bit mantissa field. That means one significant bit is missing. The least significant 1 at the end cannot be stored exactly.

So the number must be rounded to the nearest value that does fit. Because of that loss of precision, 513 cannot be stored accurately.

Key Takeaways

  • The mantissa determines precision; the exponent determines range.
  • A number may be within range but still not be representable exactly.
  • To test exact storage, write the number in normalised binary and count mantissa bits.
  • Lost low-order bits cause rounding error.

Common Mistakes

  • Saying the exponent is too small or too large. Here the exponent is not the issue.
  • Forgetting to normalise before checking whether the mantissa fits.
  • Counting only the digits after the point and forgetting the sign bit is also part of the mantissa field.
  • Saying the number is "too big" instead of explaining the real precision problem.

Things to Be Careful About

  • The mantissa length is 10 bits total, not 10 bits after the binary point.
  • The exact normalised form of 513 ends with a final 1, and that is the bit that gets lost.
  • Use the wording accurately: the number cannot be stored exactly, so it must be rounded.
  • Distinguish precision problems from overflow problems.
Techniques used
convert denary to binaryexpress the value in normalised formcompare required precision with mantissa lengthrelate lost bits to rounding error
(ii)

Describe an alteration to the way floating-point numbers are stored to enable this number to be stored accurately using the same total number of bits.

2M
DifficultyMedium-Easy
Worked solution

Answer

  • Use more bits for the mantissa and fewer bits for the exponent.
  • For example, use an 11-bit mantissa and a 5-bit exponent.
  • Then 0.1000000001 × 2^10 can be stored exactly, and exponent 10 still fits.
Final answer

Use an 11-bit mantissa and a 5-bit exponent

Detailed explanation

Background Concept

If a floating-point number is inaccurate because of insufficient mantissa bits, the fix is to increase mantissa precision. Since the question says the same total number of bits must be used, you cannot add extra storage overall. Instead, you must redistribute bits between the mantissa and exponent.

This creates a trade-off:

  • more mantissa bits gives better precision
  • fewer exponent bits gives a smaller range

Understanding the Question

The previous part established that 513 cannot be stored exactly because the mantissa is too short. Now the question asks for a change to the storage format that would allow exact storage, while keeping the total number of bits the same.

So you must suggest a new split of the 16 bits between mantissa and exponent.

Approach

Give one more bit to the mantissa, because that is exactly what is missing. Then take one bit away from the exponent. Finally, check that the new exponent field is still large enough to store exponent 10.

Step-by-Step Reasoning

The original format is:

  • 10-bit mantissa
  • 6-bit exponent

Total:

10+6=16 bits10 + 6 = 16 \text{ bits}

From part (d)(i), the exact normalised form of 513 is:

0.10000000012×2100.1000000001_2 \times 2^{10}

That mantissa needs 11 bits in total, so the simplest alteration is:

  • 11-bit mantissa
  • 5-bit exponent

The total is still 16 bits.

Now check the exponent. A 5-bit two’s complement exponent has range:

16 to +15-16 \text{ to } +15

So exponent 10 still fits. Therefore the number can now be stored exactly.

Key Takeaways

  • To improve floating-point precision, increase the mantissa length.
  • If the total number of bits is fixed, bits must be taken from the exponent field.
  • Always check that the reduced exponent range still covers the required exponent.
  • Floating-point design is always a compromise between range and precision.

Common Mistakes

  • Suggesting more total bits, which the question does not allow.
  • Increasing the exponent instead of the mantissa, which would not solve the precision problem.
  • Suggesting a 4-bit exponent; that would not store exponent 10 in two’s complement.
  • Giving a vague answer like "use a larger mantissa" without describing the actual bit change.

Things to Be Careful About

  • Keep the total at 16 bits.
  • The exponent must still be able to represent 10 after the change.
  • One extra mantissa bit is enough here; you do not need a larger redesign.
  • State the alteration clearly, for example 11-bit mantissa and 5-bit exponent.
Techniques used
reallocate bits between mantissa and exponentincrease mantissa precisioncheck the reduced exponent still fits the value

The rest of this paper

8 more questions
  • Q2Data Representation8M
  • Q3System Software9M
  • Q4System Software · Computational Thinking and Problem-solving8M
  • Q5Artificial Intelligence (AI)8M
  • Q6Communication and Internet Technologies4M
  • Q7Hardware and Virtual Machines8M
  • Q8Computational Thinking and Problem-solving8M
  • Q9Further Programming8M
Loading the full paper…