0% found this document useful (0 votes)
0 views

Ch1 Notes

This document covers data representation in computing, focusing on number systems including binary, denary, and hexadecimal. It explains conversions between these systems, binary addition, overflow errors, logical shifts, and two's complement for representing negative numbers. The chapter aims to provide a comprehensive understanding of how text, sound, and images are represented in computers, along with data storage and compression techniques.

Uploaded by

farazsaadi0309
Copyright
© © All Rights Reserved
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
0 views

Ch1 Notes

This document covers data representation in computing, focusing on number systems including binary, denary, and hexadecimal. It explains conversions between these systems, binary addition, overflow errors, logical shifts, and two's complement for representing negative numbers. The chapter aims to provide a comprehensive understanding of how text, sound, and images are represented in computers, along with data storage and compression techniques.

Uploaded by

farazsaadi0309
Copyright
© © All Rights Reserved
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 16

viii

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

1.1 Number systems


1.1.1 Binary represents data
No matter how complex the system, the basic building block in all computers is
the binary number system. This system is chosen because it consists of 1s and
0s only which correspond to ON and OFF states in the computer system.

1.1.2 Binary, denary and hexadecimal number systems


The binary system
The maximum size of a
The binary number system is based on the number 2; it can only binary number you will
use the two values 0 and 1 (these are referred to as bits). The see in the exam is 16 bits
binary heading values are 20, 21, 22, 23 and so on.
If an 8-bit system is being used the headings are: 128 (27), 64 (26),
32 (25), 16 (24), 8 (23), 4 (22), 2 (21) and 1 (20). A typical binary
number, based on this system, would be 0 1 1 1 1 0 0 1.
The denary system is a base 10 number system with column headings:
100 (1), 101 (10), 102 (100), 103 (1000) and so on.
Converting from binary to denary
To convert from binary to denary, simply add together all the
heading values where a 1-value appears.
It is illegal to photocopy this page

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

Converting from denary to binary


To convert from positive denary to binary, it is necessary to carry out
successive divisions by 2 until a zero value results. The remainders
are read from bottom to top to give the binary value:
For example, to convert 142 to binary:

2 142 read the remainder from bottom


2 71 remainder: 0 to top to get the binary number:
2 35 remainder: 1 10001110
2 17 remainder: 1
2 8 remainder: 1
2 4 remainder: 0
2 2 remainder: 0
2 1 remainder: 0
0 remainder: 1

(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

Converting from hexadecimal to denary and from


denary to hexadecimal
To convert a hexadecimal number to denary, it is necessary to
multiply each hexadecimal digit by its heading value and then add
them together. For example,
1FD = (1 × 256) + (15 × 16) + (12 × 1) = 508
4EB5 = (4 × 4096) + (14 × 256) + (11 × 16) + (5 × 1) = 20 149

2 Cambridge IGCSE™ and O Level Computer Science Study and Revision Guide Second Edition
1 Data representation

To convert from denary to hexadecimal, it is necessary to carry out


successive divisions by 16 until zero value results. The remainders
are read from bottom to top to give the hexadecimal value. For
example, to convert 2004 to hexadecimal:

16 2004 read the remainder from bottom


16 125 remainder: 4 to top to get the hexadecimal
16 7 remainder: 13
number: 7D4 (D = 13)
0 remainder: 7

1.1.3 Uses of the hexadecimal system


The hexadecimal number system is often used by computer
programmers and designers because it is easier to deal with, for
example AF01, than the binary equivalent of 1010111100000001.
Some of the main uses of the hexadecimal system are listed here.
l Error codes refer to memory locations where the error occurs;
they are automatically generated by the computer.
l A Media Access Control (MAC) address identifies a device on a
network (via the NIC). The MAC address is in the format NN-NN-
NN-DD-DD-DD (first six digits are the manufacturer code and the
last six digits are the serial number of the device).
l An Internet Protocol (IP) address is given to a device when it
joins a network; there are two types – IPv4 (32-bit code) and IPv6
(uses 128-bit code).
l Hypertext mark-up language (HTML) colour codes; the colour of each
pixel on screen is made up of a combination of red, green and blue; the
amount of each colour is represented by a hex code. For example,
# FF 00 00 is pure red, # FF 80 00 is a shade of orange, # B1 89
04 is a tan colour.

1.1.4 Addition of binary numbers


Binary addition involves a carry and a sum for each of the 2 or 3 bits
being added:
binary digit operation carry sum
0 0 0 0+0+0 0 0
0 0 1 0+0+1 0 1
0 1 0 0+1+0 0 1
0 1 1 0+1+1 1 0
1 0 0 1+0+0 0 1
1 0 1 1+0+1 1 0
It is illegal to photocopy this page

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

We will set this out showing carry and sum values:


column 1: 1 + 0 = 1 no carry
0 0 1 0 0 1 1 1 column 2: 1 + 1 = 0 carry 1 to next column
+
01001010 column 3: 1 + 0 + 1 = 0 carry 1 to next column
1 1 1 carry values
column 4: 0 + 1 + 1 = 0 carry 1 to next column
0111 0 0 0 1 sum values
column 5: 0 + 0 + 1 = 1 no carry
Answer: 01110001 column 6: 1 + 0 = 1 no carry
column 7: 0 + 1 = 1 no carry
column 8: 0 + 0 = 0 no carry
Overflow
Overflow occurs if the result of a calculation is too large for the
allocated word size (for example a word size of 8 bits can represent
a maximum value of 255).
For example:
Add 0 1 1 0 1 1 1 0 and 1 1 0 1 1 1 1 0 (using an 8-bit word size)

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.

1.1.5 Logical binary shifts


Logical shifts involve shifting (moving) bits to the left (multiplying by 2
for each shift) or the right (dividing by 2 for each shift). If shifting to the
left or right results in a loss of 1-bits, then this would result in an error.
When shifting a binary number, any gaps created by the shift
It is illegal to photocopy this page

operation can be filled by zeros. For example, the denary number


54 is 00110110 in binary. If we put this into an 8-bit register:

128 64 32 16 8 4 2 1

0 0 1 1 0 1 1 0

The left-most bit is often referred to as the most significant bit

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

The value of the binary bits is now 54 × 22 = 216.


Suppose we now shift the original number one place to the right:

128 64 32 16 8 4 2 1

0 0 0 1 1 0 1 1

Note how the left-most bit position is now filled with a 0

The value of the binary bits is now 54 ÷ 21 = 27.


Suppose we now shift the original binary number four places to the left:

128 64 32 16 8 4 2 1

0 1 1 0 0 0 0 0

This should give 54 × 24 = 864, but actually gives 96 which is clearly


incorrect. Since two of the 1-bits were lost following a logical shift,
an error would be generated. Similarly, if we shift the original binary
number four places to the right:

128 64 32 16 8 4 2 1

0 0 0 0 0 0 1 1

Again, an error would be generated since the result of the right


shift should be 54 ÷ 24 = 3.375, but actually results in the value 3.

1.1.6 Two’s complement (binary numbers)


To allow for the possibility of representing negative integers we
make use of two’s complement notation. For example:
−128 64 32 16 8 4 2 1 This represents a negative number:
−128+64+32+4+2=−26
1 1 1 0 0 1 1 0
It is illegal to photocopy this page

We can still store positive values. For example,


0 1 1 0 0 1 1 0 this represents 64 + 32 + 4 + 2 = 102

Converting denary numbers into binary in two’s complement


format, involves placing 1-bits in the appropriate position
remembering that the right-most bit now represents −128.

Hodder & Stoughton Limited © David Watson and Helen Williams 2022 5
1.1 Number systems

To convert negative denary numbers into binary in two’s


complement format can be done in two ways.
Consider the number +67 in 8-bit (two’s complement) binary format:
−128 64 32 16 8 4 2 1

0 1 0 0 0 0 1 1

One method of finding the binary equivalent to −67 is to simply put 1-


bits in their correct places:
−128 64 32 16 8 4 2 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:

first, write the positive binary value, such as 67 0 1 0 0 0 0 1 1

then invert each binary value then add 1 to that 1 0 1 1 1 1 0 0

number 1

this gives us the binary for -67 1 0 1 1 1 1 0 1

Sample questions and answers


a) Write the denary number 44 as an 8-bit binary number.
b) Carry out a logical shift two places left on your binary number
found in part a). Comment on your answer.
c) Carry out a logical shift two places right on your binary number
found in part a). Comment on your answer.
d) Write the denary number 220 as an 8-bit binary number. Add this binary
number to your binary number found in part a). Comment on your answer.
e) Write −44 as an 8-bit binary number using two’s complement format. [9]

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

operations is needed (as in parts d) and e)), it is imperative that you


show all your working so that some marks can still be gained even if your
answer is incorrect. Throughout questions of this type, keep your work
logical and thorough so that the examiner can easily follow your logic.
To reduce the possibility of errors, it is a good idea to write your 8-bit
binary number in register/word format:
128 64 32 16 8 4 2 1

6 Cambridge IGCSE™ and O Level Computer Science Study and Revision Guide Second Edition
1 Data representation

Sample high-level answer Teacher’s comments


a) 128 64 32 16 8 4 2 1 The first student has given
a very well-explained
0 0 1 0 1 1 0 0 answer and they have used
the 8-bit word format; this
greatly helps in parts b), c)
b) 128 64 32 16 8 4 2 1 and e) of this question.

1 0 1 1 0 0 0 0

This is equivalent to 128 + 32 + 16 = 176. Shifting two places left


should give the result 44 × 22 = 176, which means the actual result is
the same as the expected result.
c) 128 64 32 16 8 4 2 1

0 0 0 0 1 0 1 1

This is equivalent to 8 + 2 + 1 = 11. Shifting two places right


should give the result 44 ÷ 22 = 11, which means the actual result
is the same as the expected result.
d) 128 64 32 16 8 4 2 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

A ninth bit is generated following this binary addition

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

(−128 + 64 +16 + 4 = −44)

Hodder & Stoughton Limited © David Watson and Helen Williams 2022 7
1.1 Number systems

Sample low-level answer Teacher’s comments


a) 2 44 The second student
2 22 remainder: 0 has used the correct
2 11 remainder: 0 conversion method in
parts a) and d), but
2 5 remainder: 1
they have written the
2 2 remainder: 1 binary numbers in the
2 1 remainder: 0 wrong order and the
answer to part a) is not
0 remainder: 1
in 8-bit format. Answer
Gives the answer: 0 0 1 1 0 1 b) is incorrect since they
b) 0 0 1 1 0 1 becomes 1 1 0 1 haven’t added extra zeros
c) 0 0 1 1 0 1 becomes 0 0 0 0 1 1 0 1 (they could have gained a
follow-through mark from
d)220 2 part a) if they added the
110 2 remainder: 0 extra two zeros). Part
c) would gain a follow
55 2 remainder: 0
through mark since this
27 2 remainder: 1 time the additional
13 2 remainder: 1 zeros were added. Part
6 2 remainder: 1 e) is completely wrong.
3 2 remainder: 0 Probably two or three
marks maximum out of 9.
1 2 remainder: 1
0 remainder: 1

Gives the answer: 0 0 1 1 1 0 1 1


e) −001101

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

4 Convert the denary number 75 into an 8-bit binary number using


the two’s complement format. [3]
5 a) i) Convert the denary number 116 into a binary 8-bit number.
ii) Carry out a logical shift two places to the right on the binary
number obtained in part a)i).
iii) Carry out a logical shift three places to the left on the binary
number obtained in part a)i). Comment on your answer. [5]
b) i) Write the hexadecimal numbers 3 C and 4 4 as 8-bit binary
numbers.
ii) Add the two binary numbers found in part b)i).
iii) Carry out a logical shift six places to the right on your
answer to part b)ii). Comment on your answer. [5]

8 Cambridge IGCSE™ and O Level Computer Science Study and Revision Guide Second Edition
1 Data representation

1.2 Text, sound and images


1.2.1 Text
All keyboard characters (including control codes) are represented in a
computer using 7-bit American Standard Code for Information Interchange
(ASCII code) or 8-bit Extended ASCII code character set. For example,
each ASCII value is found in a stored table when a key is pressed on
the keyboard. The main drawback of the ASCII code system is it can’t
be used to represent non-Western languages, such as Chinese or
Japanese characters. One way round this is to use Unicode, which can
support up to 4 bytes per character (that is, up to 32 bits per character).

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

10 much more accurate


e
l
l
i

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

1.2.3 Representation of (bitmap) images


Bitmap images are made up of pixels (picture elements). An image
is made up of a two-dimensional matrix of pixels. Each pixel can be
represented as a binary number, so bitmap images are stored as a
series of binary numbers, so that:
l a black and white image only requires 1 bit per pixel (1 =
white, 0 = black)
l if each pixel is represented by 2 bits, there are 22 (= 4) possible
values (00, 01, 10 and 11) – therefore, four colours could be
represented or four shades of grey Tip
l if each pixel is represented by 3 bits, there are 23 (= 8) possible values As colour depth and/or
– therefore, eight colours could be represented or eight shades of resolution increase, the
grey; and so on. quality of the image will
The number of bits to represent each possible colour is called the improve; but this also
causes an increase in
colour depth. Image resolution refers to the number of pixels that
file size which impacts
make up an image, for example 4096 × 3072 (= 12 582 912) pixels
on the storage/memory
could be used to make up an image. Each pixel will be represented requirements.
by a number of bits (for example, a colour depth of 32 bits).

1.3 Data storage and file compression


1.3.1 Measurement of data storage
Recall that a bit refers to each binary digit and is the smallest unit; four
bits make up a nibble (an old unit) and eight bits make up a byte.
Memory size and storage size are both measured in terms of bytes
Data storage and memory is measured in terms of bytes:
l 1 KiB (kibibyte) = 210 bytes
l 1 MiB (mebibyte) = 220 bytes
l 1 GiB (gibibyte) = 230 bytes
Tip
l 1 TiB (tebibyte) = 240 bytes
l 1 PiB (pebibyte) = 250 bytes Remember that answers
must be given in the units
l 1 EiB (exbibyte) = 260 bytes specified by the question.

1.3.2 Calculation of file size


The file size of an image is calculated by:
image resolution (number of pixels) × colour depth (in bits)
For example, a photograph is taken by a camera that uses a colour
depth of 32 bits; the photograph is 1024 × 1080 pixels in size. We
It is illegal to photocopy this page

can work out the file size as follows:


1024 × 1080 × 32 = 35 389 440 bits ≡ 4 423 680 bytes ≡ 4.22 MiB
The file size of a sound file is calculated by:
sample rate (in Hz) × sample resolution (bits) × length of sample (secs)
For example, an audio file which is 60 minutes in length uses a
sample rate of 44 100 and a sample resolution of 16 bits. We can
work out the file size as follows:
44 100 × 16 × (60 × 60) = 2 540 160 000 bits ≡ 317 520 000 bytes ≡ 302.8 MiB

10 Cambridge IGCSE™ and O Level Computer Science Study and Revision Guide Second Edition
1 Data representation

1.3.3 Data compression


Files are often compressed to save storage used, reduce streaming
and downloading/uploading times, reduce the bandwidth requirements
and reduce costs (for example, if storing files using cloud storage).

1.3.4 Lossy and lossless file compression


Two common types of (file) compression are lossy and lossless.
Lossy Lossless
l File compression algorithms eliminate unnecessary data. l Data from the original uncompressed file can
l The original file cannot be reconstructed once it has been be reconstructed following compression.
compressed. l No data is lost following the application of the
l The files are smaller than those produced by lossless lossless algorithms.
algorithms. l Most common example is RLE.
l Examples include MPEG and JPEG.

Lossy file compression


Examples of lossy file compression include the following.

Lossy compression

MP3 MP4 JPEG

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.

Lossless file compression


Run length encoding (RLE) is an example of lossless
compression. It works by:
l reducing the size of a string of adjacent, identical data items
l the repeating unit is encoded into two values:
l first value represents number of identical data items
l second value represents code (such as ASCII) of data item.

Using RLE on text data


It is illegal to photocopy this page

For example aaaaaaa/bbbbbbbbbb/c/d/c/d/c/d/eeeeeeee becomes:


255 08 97 // 255 10 98 // 99 /100 /99 /100 /99 /100 // 255 08 101

This is the ASCII code of the repeating unit

This is the number of times the character unit is repeated

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

Using RLE with images


This example shows how the file size of a colour image can be
reduced using RLE.
The figure below shows an object in four colours. Each colour is made
up of red, green and blue (RGB) according to the code on the right.

Square Components
colour Red Green Blue

0 0 0
255 255 255

0 255 0
255 0 0

This produces the following data:


200040255030006255255255100020255042550040
25501255255255225500125525525540255042550040255
04255255255202550100022552552552255002255255255
30004025502000
The original image (8 × 8 square) would need three bytes per
square (to include all three RGB values). Therefore, the
uncompressed file for this image is:
8 × 8 × 3 = 192 bytes.
The RLE code has 92 values, which means the compressed file will
be 92 bytes in size. This gives a file reduction of about 52%. It
should be noted that the file reductions in reality will not be as large
as this due to other data which needs to be stored with the
compressed file (for example, a file header).

Sample questions and answers


a) i) Explain the two terms lossy and lossless file compression. [2]
ii) Give two advantages of compressing files and data. [2] Tips
iii) Give one drawback of using lossy file compression and one Since the first part is an
drawback of using lossless file compression. [2] ‘explain’ question, it is
b) A camera detector has an array of 2048 by 3072 pixels and uses a colour necessary to give a
depth of 32 bits. The camera has a 64 GiB memory capacity. Calculate detailed explanation of
how many typical images could be stored on the camera. [3] the two terms mentioned
in the question. Parts a)
ii) and a)iii) just require a
Sample high-level answer brief description since
It is illegal to photocopy this page

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

10 Peak ‘A’ (the word ‘space’ on its own


9 is worth 0 marks). The first
8
7
answer to part a) iii) is just a
6 repeat of a) i) and the
5 second answer isn’t
4
3 necessarily true. The
2 calculation in part b) is a
1
0 mess but they would
Time intervals probably gain a mark for the
calculation of number of
a) What type of data is natural sound? [1] bits; but the rest of their
b) The sound resolution being used is 16 bits. Write down the answer is confused or
binary values of simply incorrect.
i) peak ‘A’ and peak ‘B’;
ii) peak ‘B’ has two potential values; describe how this problem
could be resolved. [3]
It is illegal to photocopy this page

c) Explain what is meant by:


i) sampling resolution
ii) sampling rate. [2]
d) A sound source is being sampled at 20 000 samples per
second. The sampling resolution used is 32 bits.
i) Give one advantage of using 32 bits rather than 8 bits.
ii) Give one disadvantage of using 32 bits rather than 8 bits.
iii) Estimate the file size if a 30 second sound sample was being
recorded.
Give your answer in MiB. [4]

Hodder & Stoughton Limited © David Watson and Helen Williams 2022 13
1.3 Data storage and file compression

7 An ancient Roman mosaic was being scanned by archaeologists and


the pattern saved on a computer. Each black tile has the binary value
0 and each white tile has the binary value 1.
a) What is the file size of the raw data? [1]
b) Describe how run length encoding (RLE) could be used to reduce
the size of the raw file. Your answer should include calculations to
show how the file size could be reduced. [6]
8 Explain the following four terms:
a) MP3 file
b) JPEG file
c) 1 Tebibyte
d) pixel [8]
9 A student gave the following answers in an end-of-term test on
computer science. In each case, explain why the student’s answers
were incorrect. Also suggest what answer the student should have
given in each case.
a) 1 MiB is equivalent to 1 000 000 bytes of data.
b) A file which undergoes a lossy compression algorithm can be
restored to its original file whenever required.
c) RLE works effectively on any run of repeating units.
d) ASCII code is a subset of Unicode.
e) To play back a sound file stored on a computer through a set
of external speakers requires the use of an analogue to digital
converter (ADC). [10]
It is illegal to photocopy this page

10 When zooming in to an image (that is, increasing its size on


screen), it may become pixelated.
a) What is meant by the term pixelated? [2]
b) Explain why an image can become pixelated. [2]
c) Colour images are made up of red, green and blue elements.
Each of the three colour elements can be represented by 256 bit
combinations (from 0 to 255, where 0 = colour not present and
255 = maximum colour element present).
i) What is the hexadecimal equivalent of 255?
ii) Describe how it is possible to represent millions of different
colours using red, green and blue elements. (You may assume,
for example, that pure red is represented by # FF 00 00). [4]

14 Cambridge IGCSE™ and O Level Computer Science Study and Revision Guide Second Edition

You might also like