Data representation: user-defined types, files and floating point – A Level Computer Science (old syllabus, to 2021) (9608)
Quick quiz: 10 random questions from this topic. Answer them all, then open the Summary.
Question text
2
(a) A computer system stores real numbers using floating‑point representation. The floating‑point
numbers have:
•
eight bits for the mantissa
•
four bits for the exponent.
The mantissa and exponent are both in two’s complement form.
(i)
Calculate the denary value of the following floating‑point number.
Mantissa
Exponent
0
0
1
1
1
0
0
0
0
1
1
1
Show your working.
Working …
…
…
…
…
Answer …
[3]
(ii)
State how you know the floating‑point number in part (a)(i) is not normalised.
…
… [1]
(iii)
Normalise the floating‑point number in part (a)(i).
Mantissa
Exponent
[2]
(b) (i)
Write the largest positive number that this system can represent as a normalised
floating‑point number in this format.
Mantissa
Exponent
[2]
(ii)
Write the smallest positive number that can be stored as a normalised floating‑point
number in this format.
Mantissa
Exponent
[2]
(c) The number of bits available to represent a real number is increased to 16.
State the effect this has on the numbers that can be represented, if the additional four bits are
used in the:
(i)
mantissa …
… [1]
(ii)
exponent …
… [1]
(d) A student enters the following code into an interpreter.
X = 0.1
Y = 0.2
Z = 0.3
OUTPUT (X + Y + Z)
The student is surprised to see the output:
0.6000000000000001
Explain why this is output.
…
…
…
…
…
… [3]
Question text
1
In a particular computer system, real numbers are stored using floating-point representation with:
•
10 bits for the mantissa
•
6 bits for the exponent
•
two’s complement form for both mantissa and exponent.
(a) Calculate the normalised floating-point representation of +192.5 in this system. Show your
working.
Mantissa
Exponent
Working …
…
…
…
… [3]
(b) Calculate the normalised floating-point representation of –192.5 in this system. Show your
working.
Mantissa
Exponent
Working …
…
…
…
… [3]
(c) The floating-point representation has changed. There are now 12 bits for the mantissa and 4
bits for the exponent as shown.
Mantissa
Exponent
Explain why +192.5 cannot be accurately represented in this format.
…
…
…
…
…
… [3]
Question text
6
A company specialises in educational software.
(a) The company is concerned that malware might disrupt their business.
(i)
Add appropriate descriptions and terms in the table.
Description
Term
Redirection to a bogus website that appears to be
A
legitimate to gain confidential data.
…
B
Use email to attempt to gain a user’s confidential data.
…
…
C
Spyware
…
…
…
D
Worm
…
…
[4]
(ii)
A member of staff is using the Internet to carry out research. They are worried about the
threat from terms A and B.
Identify one solution to the each of the threats.
Term A …
…
Term B …
…
[2]
(b) A customer downloads a new educational software package from the company.
Explain how the customer’s and the company’s computers use a hashing algorithm to assure
the customer that:
•
the software has come from the company (is authentic) and
•
no one has altered it.
…
…
…
…
…
…
…
… [4]
Question text
2
The diagram shows four files and three methods of file organisation.
Draw one line to match each file with its most appropriate method of file organisation.
File
File organisation
Text file
Sequential
File for recording the temperature every hour
Random
Master file for paying each employee every month
Serial
Customer user name and password file
[4]
Question text
2
Data types can be classified as composite or non-composite.
(a) Draw one line from each data type to its correct classification.
Data type
Classification
Pointer
Record
Composite
Set
Class
Non-composite
Integer
[2]
(b) A user-defined data type, timeOfDay, is declared using the following pseudocode.
TYPE timeOfDay = (morning, afternoon, evening, night)
(i)
Identify the type of user-defined data type declared and state its classification.
Type …
Classification …
[2]
(ii)
Write pseudocode to declare the variable session of type timeOfDay.
Assign the value afternoon to the variable session.
…
…
…
… [2]
Question text
1
Data types can be defined using pseudocode.
The data type, BicycleRecord, is defined in pseudocode as:
TYPE BicycleRecord
DECLARE BicycleID
:
INTEGER
DECLARE BicycleAvailable :
BOOLEAN
DECLARE BicycleLocation : (RiverSide, BusStation, TrainStation,
TownSquare, Library)
DECLARE DateChecked
:
DATE
ENDTYPE
A variable, LoanBicycle, is declared in pseudocode as:
DECLARE LoanBicycle : BicycleRecord
(a) Write pseudocode statements to assign 567 to the BicycleID of LoanBicycle and
FALSE to the BicycleAvailable of LoanBicycle.
…
… [2]
(b) The type definition for BicycleRecord is changed.
(i)
The definition has been extended to include borrower identification numbers,
BorrowerID, for the last 10 people who borrowed a bicycle. Each identification number
is an integer.
Write the pseudocode statement needed in the type definition of BicycleRecord.
…
… [1]
(ii)
The values for the field BicycleID must be between 500 and 599 inclusive.
Rewrite one pseudocode line from the type definition of BicycleRecord to implement
the change.
…
… [1]
(c) Data about all the bicycles are stored in a file that uses random file organisation.
BicycleID is used as the key field.
Explain how a program could add an extra record to this file.
…
…
…
…
…
… [3]
Question text
1
(a) A computer system uses floating-point representation to store real numbers. The floating-point
numbers have:
•
8 bits for the mantissa
•
8 bits for the exponent
The mantissa and exponent are both in two’s complement form.
(i)
Calculate the denary value of the following floating-point number. It is not in normalised
form.
Mantissa
Exponent
0
0
1
0
1
0
1
0
0
0
0
0
0
1
0
1
Show your working.
Working …
…
…
…
…
Answer …
[3]
(ii)
Convert the denary number + 7.5 into a normalised floating-point number.
Show your working.
Mantissa
Exponent
Working …
…
…
…
…
[3]
(iii)
Convert the denary number − 7.5 into a normalised floating-point number.
Show your working.
Mantissa
Exponent
Working …
…
…
…
…
[3]
(b) A normalised floating-point number is shown.
Mantissa
Exponent
0
1
1
1
1
1
1
1
0
1
1
1
1
1
1
1
(i)
State the significance of this binary number.
…
… [1]
(ii)
State what will happen if a positive number is added to this number.
…
… [1]
Question text
3
In a computer system, real numbers are stored using normalised-floating point representation
with:
•
8 bits for the mantissa
•
4 bits for the exponent
•
two’s complement form for both mantissa and exponent.
(a) Calculate the normalised floating-point representation of + 21.75 in this system. Show your
working.
Working …
…
…
…
…
…
Mantissa
Exponent
[3]
(b) Find the denary value for the following binary floating-point number.
Mantissa
Exponent
1
0
1
1
0
0
0
0
1
1
1
0
Show your working.
Working …
…
…
…
…
Answer …
[3]
Question text
1
In a particular computer system, real numbers are stored using floating-point representation with:
•
12 bits for the mantissa
•
4 bits for the exponent
•
two’s complement form for both mantissa and exponent
(a) Calculate the floating-point representation of + 2.5 in this system. Show your working.
Mantissa
Exponent
•
…
…
…
…
…
… [3]
(b) Calculate the floating-point representation of − 2.5 in this system. Show your working.
Mantissa
Exponent
•
…
…
…
…
…
… [3]
(c) Find the denary value for the following binary floating-point number. Show your working.
Mantissa
Exponent
• 0
0
1
1
0
0
0
0
0
0
0
0
0
0
1
1
…
…
…
…
…
… [3]
(d) (i)
State whether the floating-point number given in part (c) is normalised or not normalised.
… [1]
(ii)
Justify your answer given in part (d)(i).
…
… [1]
(e) The system changes so that it now allocates 8 bits to both the mantissa and the exponent.
State two effects this has on the numbers that can be represented.
1 …
Question text
1
Real numbers are stored using floating-point representation in a computer system.
This representation uses:
•
8 bits for the mantissa, followed by
•
4 bits for the exponent.
Two’s complement form is used for both the mantissa and the exponent.
(a) (i)
A real number is stored as a 12-bit normalised binary number as follows:
Mantissa
Exponent
0
1
0
1
0
0
1
0
0
0
1
0
Calculate the denary value for this binary number. Show your working.
Working …
…
…
Denary value …
[3]
(ii)
Calculate the normalised binary number for −3.75. Show your working.
Mantissa
Exponent
Working …
…
…
…
[3]
(b) The number of bits available to represent a real number is increased to 16.
State the effect of increasing the size of the exponent by 4 bits.
…
… [1]
(c) State why some binary representations can lead to rounding errors.
…
… [1]
(d) Complete the following descriptions by inserting the two missing terms.
… can occur in the exponent of a floating-point number, when the
exponent has become too large to be represented using the number of bits available.
A calculation results in a number so small that it cannot be represented by the number of bits
available. This is called … .
[2]