Ch1 Notes
Ch1 Notes
1 Data representation
Key objectives
The objectives of this chapter are to revise: l text, sound and images
l number systems l ASCII and Unicode character sets
l the binary, denary and hexadecimal number l representation of sound in a computer
systems l sampling rate and sample resolution
l conversion of numbers between all three l image representation, including resolution and
number systems colour depth
l use of the hexadecimal (hex) number system l data storage and file compression
l binary addition l calculation of file sizes
l overflow error l the need for data (file) compression
l logical shifts l lossy and lossless compression
l two’s complement format for negative and
positive binary numbers
For example:
01111001=64+32+16+8+1(=121)
011110001011=1024+512+256+128+8+2+1(=1931) … and so
on.
Hodder & Stoughton Limited © David Watson and Helen Williams 2022 1
1.1 Number systems
(Note: if the answer is, for example, 111011 and 8-bits are used to
represent numbers, then just infill with zeros to give: 00111011.)
The hexadecimal system
The hexadecimal number system is based on the number 16. The
16 digits are represented by the numbers 0 to 9 and the letters A to F
(representing 10 to 15). The hexadecimal headings are 160, 161, 162,
163, and so on. A typical hexadecimal number would be 1F3A.
Converting from binary to hexadecimal and
hexadecimal to binary
To convert a binary number to a hexadecimal number, it is first
necessary to split the binary number into 4-bit groups starting from
the right-hand side. If the final (left-most group) doesn’t contain four
binary digits, then infill by zeros is done. Each 4-bit group is then
assigned a hexadecimal digit. For example:
1011 1111 0000 1001 becomes (11) (15) (0) (9) that is, BF09
1 0011 1110 0111 must first be rewritten as 0001 0011 1110 0111
which becomes (1) (3) (14) (7) that is 13E7
To convert from hexadecimal to binary, it is necessary to write the
4-bit binary code for each hexadecimal digit. For example:
45A becomes 0100 0101 1010
E48D becomes 1110 0100 1000 1101
It is illegal to photocopy this page
2 Cambridge IGCSE™ and O Level Computer Science Study and Revision Guide Second Edition
1 Data representation
1 1 0 1+1+0 1 0
1 1 1 1+1+1 1 1
For example:
Add 00100111 + 01001010
Hodder & Stoughton Limited © David Watson and Helen Williams 2022 3
1.1 Number systems
0 1 1 0 1 1 1 0
+ 1 1 0 1 1 1 1 0
1) 1 1 1 1 1 1 carry values
ninth bit 1) 0 1 0 0 1 1 0 0 sum values
This addition has generated a ninth bit. The 8 bits of the answer 0 1
0 0 1 1 0 0 give the denary value (64 + 8 + 4) of 76 which is clearly
incorrect (the denary value of the addition is 110 + 222 = 332).
The generation of a ninth bit is a clear indication that the sum has exceeded
the maximum value possible for 8 bits; that is, 255 (28 – 1). This is known
as an overflow error and is an indication that a number is too big to be
stored in the computer using, in this case, an 8-bit register.
This shows that the greater the number of bits which can be used to
represent a number then the larger the number that can be stored.
For example, a 16-bit register would allow a maximum value of 216 –
1 (= 65 535) to be stored, a 32-bit register would allow a maximum
value of 232 – 1 (= 4 294 967 295), and so on.
128 64 32 16 8 4 2 1
0 0 1 1 0 1 1 0
4 Cambridge IGCSE™ and O Level Computer Science Study and Revision Guide Second Edition
1 Data representation
If we now shift the bits in this register two places to the left:
128 64 32 16 8 4 2 1
1 1 0 1 1 0 0 0
Note how the two right-most bit positions are now filled with 0s
128 64 32 16 8 4 2 1
0 0 0 1 1 0 1 1
128 64 32 16 8 4 2 1
0 1 1 0 0 0 0 0
128 64 32 16 8 4 2 1
0 0 0 0 0 0 1 1
Hodder & Stoughton Limited © David Watson and Helen Williams 2022 5
1.1 Number systems
0 1 0 0 0 0 1 1
1 0 1 1 1 1 0 1
−128+32+16+8+4+1=−67
Looking at the two binary numbers above, this gives us another possible
way of finding the binary representation of a negative denary number:
number 1
Tips
When a comment about your answer is required, explain whether the
result you get is what you would have expected; then give a reason why
it is (or is not) as expected. Where a mathematical sequence of
It is illegal to photocopy this page
6 Cambridge IGCSE™ and O Level Computer Science Study and Revision Guide Second Edition
1 Data representation
1 0 1 1 0 0 0 0
0 0 0 0 1 0 1 1
1 1 0 1 1 1 0 0
This is the 8-bit binary representation of 220. Adding this to the original
binary number from part (a): 0 0 1 0 1 1 0 0 results in the answer:
128 64 32 16 8 4 2 1
1 0 0 0 0 1 0 0 0
The expected result for this addition (220 + 44) is 264. However, the value
8 is generated. This is clearly incorrect and is due to the fact that the
result of the sum exceeds the maximum value which can be represented
by an 8-bit word (that is, 255). An overflow error has occurred.
e)
44: 0 0 1 0 1 1 0 0
It is illegal to photocopy this page
inverted: 1 1 0 1 0 0 1 1
add 1: 1
result: 1 1 0 1 0 1 0 0
Hodder & Stoughton Limited © David Watson and Helen Williams 2022 7
1.1 Number systems
Exam-style questions
a) i) Convert the 16-bit binary number 1100 0000 1101 1110 to
hexadecimal.
ii) Convert the hexadecimal number 2 A 9 F to a 16-bit binary
number. [3]
b) i) Convert the hexadecimal number 3 F C to a denary number.
ii) Convert the denary number 2 8 1 6 to a hexadecimal number. [3]
2 a) Convert the following denary numbers into 8-bit binary numbers:
i) 95
ii) 30
iii) 205 [3]
b) i) Carry out the binary addition of parts a)i) and a)ii).
ii) Carry out the binary addition of parts a)i) and a)iii). Comment
on your answer. [3]
3 Describe three uses of the hexadecimal number system. [6]
It is illegal to photocopy this page
8 Cambridge IGCSE™ and O Level Computer Science Study and Revision Guide Second Edition
1 Data representation
1.2.2 Sound
Sound is analogue data. To store sound in a computer, it is necessary
to convert the analogue data into a digital format. The digital data can
then be played back through a loudspeaker once it has been converted
back to electrical signals (see Chapter 3 for more details).
To convert sound to digital, the sound waves must be sampled at regular
time intervals. The amplitude (loudness) of the sound uses a number of
bits to represent the range (for example, 0 to 15 bits). The greater the
number of bits used to represent the amplitude, the greater the accuracy
of the sampled sound. The number of bits per sample is called the
sampling resolution; the sampling rate is the number of sound samples
taken per second. Look at these two diagrams to show the difference.
In the first diagram, only 8 bits (0 to 7) are used to represent the amplitude,
whereas 16 bits are used in the second diagram. This means the second
diagram allows 16 distinct values to represent amplitude, whereas the first
diagram only has eight values to represent the same amplitude range.
7
This amplitude value is
amplitude
6 between 4 and 5
5 (therefore, not very
accurate, since the value
4
4 has to be taken).
Sound
00 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20
Time intervals
15
14 The same amplitude
13
value is now exactly
12
11 (therefore, it is a
amplitu
11
de
9
8
representation).
7
Soun
pagethisphotocopyt
6
d
5
4
3
2
1
00 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20
Time intervals
o
Hodder & Stoughton Limited © David Watson and Helen Williams 2022 9
1.3 Data storage and file compression
10 Cambridge IGCSE™ and O Level Computer Science Study and Revision Guide Second Edition
1 Data representation
Lossy compression
Reduces music file size by about 90%. Used to reduce multimedia file size Reduces file size of an image thus
rather than just sound (MP3). reducing storage requirement.
Some quality of sound is lost but
most is retained. Allows movies to be streamed over Human eyes don’t detect differences
the internet with reasonable quality. in colour shades as well as brightness.
Removes sounds outside human
ear range. Separating pixel colour from
brightness allows images to be split
Eliminates softer sounds using into 8 × 8 blocks; this allows certain
perceptual music shaping. information to be discarded without
losing too much image quality.
255 is a flag indicating that the two values that follow are the number
of repeating units and the ASCII code of the repeating unit
Hodder & Stoughton Limited © David Watson and Helen Williams 2022 11
1.3 Data storage and file compression
Square Components
colour Red Green Blue
0 0 0
255 255 255
0 255 0
255 0 0
a) i) With lossy file compression, the file compression algorithms eliminate all you are asked to give
unnecessary data and the original file can no longer be reconstructed; examples. Do not
some data is irretrievably lost. The resultant files are much smaller than elaborate too much here
the original files. Examples include MPEG and JPEG.
since it will simply waste
time without any gain in
With lossless file compression, data from the original uncompressed file
marks. Part b) is a
can be reconstructed following application of the lossless compression
calculation, so it is vital
algorithms. No data is lost following the application of the lossless
that you show every step
compression algorithms. A typical example is run length encoding (RLE). in your calculation to
ii) Two advantages include: reduction in storage space used to store the files, show your logic and gain
faster download/upload of files across networks since they are much smaller. credit if your final answer
It is less expensive to store the files if cloud storage is used. is incorrect.
12 Cambridge IGCSE™ and O Level Computer Science Study and Revision Guide Second Edition
1 Data representation
iii) One drawback of lossy file compression is that data is Teacher’s comments
permanently lost so that the original file cannot be reconstructed.
One drawback of lossless file compression is that the compressed The first answer is a
files are still larger than those created from lossy compression. comprehensive description
b) number of bits = 2048 × 3072 × 32 = 201 326 592 bits of lossy and lossless data
compression and would
divide by 8 to convert to bytes = 25 165 824 bytes
probably gain full marks.
camera memory size in bytes = 64 × 1024 × 1024 ×
The calculation shows
1024 = 68 719 476 736
all of the steps, which is
number of images = (68 719 476 736) ÷ (25 165 824) = 2730 images
a good exam technique
– if you make any errors
in your calculation, by
Sample low-level answer showing all steps, you
a) i) lossy means data is lost permanently when a file is compressed could still gain a good
whereas lossless doesn’t lose any of the data for ever. mark even if your final
ii) uses up less space and it is faster and easier to send files over the internet answer is incorrect.
iii) lossy – lose data The second answer would
lossless – more complicated compression algorithm probably gain one mark for
b) 2048 × 3072 pixels = 6 291 456 bytes the reference to lossy files
Number of images = (6 292 456) ÷ 64 = 98 304 images stored. losing data permanently in
contrast to lossless. It
would also gain one mark
for a)ii) for reference to
Exam-style questions transfer of files over the
6 The following diagram shows the sampling of a sound source: internet. However, the
statement ‘uses up less
15 space’ won’t get any marks
14 Peak ‘B’
13 – it needs to refer to storage
12 space or memory space
11
Sound amplitude
Hodder & Stoughton Limited © David Watson and Helen Williams 2022 13
1.3 Data storage and file compression
14 Cambridge IGCSE™ and O Level Computer Science Study and Revision Guide Second Edition