Computer Science 9618/32 — May/June 2021
Cambridge A-Level · Advanced Theory · worked solutions for every part, with the mark scheme
Topics Data Representation · System Software · Computational Thinking and Problem-solving · Artificial Intelligence (AI) · Communication and Internet Technologies · Hardware and Virtual Machines · +1 more
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.
Calculate the normalised floating-point representation of –7.25 in this system.
Show your working.
| Mantissa | Exponent |
|---|---|
Working
Normalised form:
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
| Mantissa | Exponent |
|---|---|
1 0 0 0 1 1 0 0 0 0 | 0 0 0 0 1 1 |
Mantissa 1000110000, Exponent 000011
Background Concept
In this floating-point system, a number is stored as:
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:
- convert
-7.25to binary - write it in normalised form
- store the mantissa in 10-bit two’s complement
- 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:
7is111₂0.25is0.01₂
So:
Because the number is negative:
Now normalise it. We want a mantissa with the binary point after the sign bit:
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:
- invert bits:
1000101111 - 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 starts10. - 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^0and 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
11or00011instead of the full 6-bit000011.
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.
Calculate the denary value of the given binary floating-point number.
Show your working.
| Mantissa | Exponent |
|---|---|
| 1 0 1 1 0 0 0 1 1 1 | 0 0 0 1 1 1 |
Working
Mantissa 1011000111 is negative.
Two’s complement of 1011000111:
- invert:
0100111000 - add 1:
0100111001
So mantissa = -0.100111001_2.
Exponent 000111 = 7.
Answer
Denary value = -78.25
-78.25
Background Concept
To find the denary value of a floating-point number, decode each field separately:
- decode the mantissa as a two’s complement binary fraction
- decode the exponent as a two’s complement integer
- calculate
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:
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:
Now apply the exponent:
Multiplying by 2^7 moves the binary point 7 places to the right:
Now convert that binary number to denary.
Integer part 1001110₂:
Fractional part .01₂:
So the total is:
Key Takeaways
- A leading
1in 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
1011000111directly as if it were an ordinary binary integer. - Show the final denary value clearly, including the negative sign.
The given binary floating-point number is not normalised.
Normalise the floating-point number. Show your working.
| Mantissa | Exponent |
|---|---|
| 0 0 0 0 0 0 0 1 1 1 | 1 0 0 1 1 1 |
| Mantissa | Exponent |
|---|---|
Working
Mantissa 0000000111 represents 0.000000111_2.
Exponent 100111 is -25.
To normalise a positive mantissa, shift left until it starts 01:
0000000111 → 0111000000
This is 6 left shifts, so:
-31 in 6-bit two’s complement is 100001.
Answer
| Mantissa | Exponent |
|---|---|
0 1 1 1 0 0 0 0 0 0 | 1 0 0 0 0 1 |
Mantissa 0111000000, Exponent 100001
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:
This is not normalised, because it begins 00, not 01.
Now shift it left until the first two bits are 01.
Step by step:
0000000111000000111000000111000000111000000111000000111000000111000000
So 6 left shifts are needed.
Now decode the exponent:
100111 is a 6-bit two’s complement number.
Its value is:
Because the mantissa was shifted left 6 places, the exponent must decrease by 6:
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
100111is negative in two’s complement. - Stopping at
0011100000, which is still not normalised because it starts00.
Things to Be Careful About
- Check the first two bits after normalisation, not just whether there is a
1somewhere 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.
The denary number 513 cannot be stored accurately as a normalised floating-point number in this computer system.
Explain the reason for this.
Answer
513 = 1000000001_2.- In normalised form this is
0.1000000001_2 × 2^10. - The exponent
10can 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
1cannot be stored and the value must be rounded.
See 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:
Now normalise it:
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
513ends with a final1, 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.
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.
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^10can be stored exactly, and exponent10still fits.
Use an 11-bit mantissa and a 5-bit exponent
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:
From part (d)(i), the exact normalised form of 513 is:
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:
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
10in 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
10after 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.
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