Computer Science 9618/32 — October/November 2022
Cambridge A-Level · Advanced Theory · worked solutions for every part, with the mark scheme
Topics Data Representation · System Software · Hardware and Virtual Machines · Communication and Internet Technologies · Security · Artificial Intelligence (AI) · +2 more
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.
Write the largest positive two’s complement binary number that can be stored in this system.
Answer
Mantissa: 01111111111
Exponent: 01111
Mantissa 01111111111, Exponent 01111
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:
- choose the greatest valid positive normalised mantissa
- 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
0followed by as many1s 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 -bit two's complement integer field, the largest positive value has the pattern
0followed by1s.
Common Mistakes
- Writing an unnormalised positive mantissa such as
00111111111. This is positive, but not normalised. - Using
11111for 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.
Calculate the denary value of the given binary floating-point number.
Show your working.
| Mantissa | Exponent | ||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| 1 | 0 | 1 | 1 | 0 | 0 | 1 | 0 | 0 | 1 | 1 | 0 | 1 | 0 | 0 | 1 |
Working .....................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
Answer ......................................................................................................................................
Working
Exponent:
Mantissa:
Value:
Answer
-310.5
-310.5
Background Concept
A binary floating-point number stores a value in the form:
In this question, both the mantissa and the exponent use two's complement.
For the exponent, this works in the usual way:
- leading
0means positive - leading
1means 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 up to just less than .
In two's complement fractional form:
- the sign bit has weight
- the remaining bits have weights
So to convert the mantissa to denary, you add the weights of the 1 bits, remembering that the first bit contributes 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:
- convert the exponent to denary
- convert the mantissa to denary as a two's complement fraction
- combine them using
Approach
Start with the easier field: the exponent.
01001is 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 .
Step-by-Step Reasoning
First, convert the exponent 01001.
Because the first bit is 0, it is positive.
So the exponent is .
Now convert the mantissa 10110010011.
The first bit is 1, so this is a negative two's complement fraction. The weights are:
- first bit:
- then
Now match the 1 bits:
1 0 1 1 0 0 1 0 0 1 1
So the value is:
Now add those positive parts:
Therefore:
Now apply the exponent:
So the denary value is:
-310.5
Key Takeaways
- A floating-point value is found using .
- 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 .
- 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 , not .
- 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 .
- 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.
State when underflow occurs in a binary floating-point system.
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
.............................................................................................................................................
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.
A value is too small to be represented; the required exponent is below the minimum available.
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:
- the number's magnitude is smaller than the smallest representable non-zero value
- 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:
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.
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
