Chapter 16: Data Representation: Answers To Coursebook Questions and To Worksheet Questions
Chapter 16: Data Representation: Answers To Coursebook Questions and To Worksheet Questions
Chapter 16: Data Representation: Answers To Coursebook Questions and To Worksheet Questions
Question 16.01
a The following table shows the addresses when 10 is used in the second row and the addresses when 11 is
used in the third row.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30
1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0
1 2 3 4 5 6 7 8 9 10 0 1 2 3 4 5 6 7 8 9 10 0 1 2 3 4 5 6 7 8
b The number of possible addresses in the file is equal to the number used for the division so there are more
when 11 is used.
c No
d Prime numbers can give an advantage if there are some key values used more often than others. If a non-
prime number is used, one or more of its factors may also be a factor for the key values most often used,
leading to the hash function being more likely to produce the same address many times.
Task 16.01
The denary value has to be converted to a fixed-point real value first. This is done in two stages: the integer part is
converted first then the fractional part. If the approach taken is to convert the positive value first then take the
two’s complement later, we start by converting the 7. The binary equivalent of 7 is 111 but this is only used for
unsigned integers; here it must be represented as 0111. The fractional part .75 converts to .11 in binary.
Converting 0111.11 to the two’s complement produces 1000.01. There is a short-cut route to this value, which is
to recognise that -7.75 is equal to -8 + .25, which is 1000 + .01.
To convert the binary value 1000.01 to a normalised form with a defined exponent we have to move the binary
point to follow the most significant bit. A shift of three places is required to give 1.00001 × 23. The floating-point
representation is therefore:
100001000 0011
(The gap between mantissa and exponent is there for ease of reading.)
Exam-style Questions
1 a 1 mark each for any of the following up to a maximum of 3: The answer could name a type, such as
enumerated or pointer (1), or give an example (1). A built-in data type has a pre-defined range of possible
values (1), used by any program (1), whereas for user-defined the programmer defines a specific range
unique to that program (1).
b i 1 mark each for any of the following up to a maximum of 2: Collection of components (1), each with a
value (1), can be different types, both built-in and user defined (1).
ii 1 mark each for any of the following up to a maximum of 2: Related data can be referenced with one
construct (1), very flexible because different types allowed for the components (1), a value for a
component can be accessed individually (1).
3.5 converts to 11.1 in binary, but 0 must be put at the start to ensure it is a positive value in two’s
complement form.
Then 011.1 has to be changed to 0.1110000 to produce a normalised representation that fits the 8-bit
mantissa with the binary point in the correct position. This has involved a shift of the binary point by two
places to the left so the exponent has to be the binary for 2.
b
1 0 0 1 0 0 0 0 0 0 0 0 0 0 1 0
Again, this can begin by converting 3.5 to 011.1 in binary (the 0 must be placed at the start). To convert
this to a negative value the two’s complement has to be taken, which produces 100.1. This is expanded to
1.0010000, which has involved a shift left of two places so the exponent is the binary for 2.
c 14
The exponent is 4 so the mantissa has to have the binary point shifted right by four places :
0.1110000 becomes 01110.000. The denary is 8 + 4 + 2 = 14
d i It is normalised
ii Because the two leftmost bits in the mantissa are different.
Cambridge International AS & A Level Computer Science 9608 paper 32 Q1 November 2016
Learners often find this type of question problematic. A systematic approach is needed, looking at the
mantissa and exponent separately. For each, the first bit sets the sign, 0 for positive and 1 for negative. Then
it is necessary to remember that for a negative number in two’s complement the first bit represents a
negative value but all of the others represent positive values.
9
There are some straightforward rules here. The first bit defines the sign. If the next bit is different the
representation is normalised. The binary point is initially after the first bit. To evaluate the number, the binary
point has to be moved according to the value for the exponent. Three of these have exponent value 3 (0011)
so the binary point moves three places right. Then the normal conversion of the binary can follow. Each one
should be checked!