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

CS 2210 – Notes Ch 1

The document covers data representation in computer science, focusing on number systems such as binary, denary, and hexadecimal. It explains why computers use binary for processing data, the concept of character sets, and methods for converting between different number systems. Additionally, it provides examples and tips for understanding conversions between denary, binary, and hexadecimal formats.

Uploaded by

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

CS 2210 – Notes Ch 1

The document covers data representation in computer science, focusing on number systems such as binary, denary, and hexadecimal. It explains why computers use binary for processing data, the concept of character sets, and methods for converting between different number systems. Additionally, it provides examples and tips for understanding conversions between denary, binary, and hexadecimal formats.

Uploaded by

Hafeez Ur Rehman
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 39

1|Page

O Levels
Computer Science
CS 2210 – Notes

Chapter No. 1
Data Representation

 Number system
 Text, sound & Image
 Data storage & file compression
2|Page

Why Computers Use Binary


Why does data have to be converted to binary to be processed by a
computer?
 Data is processed in a computer using logic gates that only have two
states
 The binary number system only has two digits (1/0), which means each
digit can represent a different state (1 = on, 0 = off)
 All data must be converted to binary before a computer
can understand and process it
 Conver ng data to binary allows computers to process it at an
incredible speed, perform complex calcula ons and store vast amounts
of data efficiently

 Secondary storage is a great example of the process


o Magne c hard drives use North and South polarity to represent a
1 or a 0
o In Op cal disks, light hi ng a flat area (land) is interpreted as a 1
and light hi ng a bump (pit) is interpreted as a 0
 Take an example of driving a car
o When driving a car the accelerator pedal is used to increase the
cars speed
3|Page

o If a car was accelera ng from 50mph to 100mph the increase


would be gradual
o In a computer system, the car is doing either 50mph (0) or
100mph (1), there is no in-between
o Trying to change the computer system so that it has more
op ons would be less efficient and require more complex parts
for the computer to understand
Worked Example
Explain why computers process data in binary format [2]
Answer
 Computers process data using logic gates... [1]
 ... that can only have two states (1/0) [1]
The Denary, Binary & Hexadecimal Number Systems
What is denary?
 Denary is a number system that is made up of 10 digits (0-9)
 Denary is referred to as a base-10 number system
 Each digit has a weight factor of 10 raised to a power, the rightmost
digit is 1s (100), the next digit to the le 10s (101) and so on
 Humans use the denary system
for coun ng, measuring and performing maths calcula ons
 Using combina ons of the 10 digits we can represent any number

 In this example, (3 x 1000) + (2 x 100) + (6 x 10) + (8 x 1) = 3268


 To represent a bigger number we add more digits
What is binary?
 Binary is a number system that is made up of two digits (1 and 0)
4|Page

 Binary is referred to as a base-2 number system


 Each digit has a weight factor of 2 raised to a power, the rightmost digit
is 1s (20), the next digit to the le 2s (21) and so on
 Each me a new digit is added, the column value is mul plied by 2
 Using combina ons of the 2 digits we can represent any number

 In this example, Binary 1100 = (1 x 8) + (1 x 4) = 12


 To represent bigger numbers we add more binary digits (bits)
32,768 16,384 8,192 4,096 2,048 1,024 512 256 128 64 32 16 8 4
215 214 213 212 211 210 29 28 27 26 25 24 23 22
Examiner Tips and Tricks
In the exam you are expected to be able to work with up to and including 16
bits
The largest denary number that can be represented using 16 bits is:
 65,535 (Binary 1111111111111111)

Character Sets
What is a character set?
 A character set is all the characters and symbols that can
be represented by a computer system
 Each character is given a unique binary code
 Character sets are ordered logically, the code for ‘B’ is one more than
the code for ‘A’
 A character set provides a standard for computers to communicate and
send/receive informa on
5|Page

 Without a character set, one system might interpret 01000001


differently from another
 The number of characters that can be represented is determined by
the number of bits used by the character set
 Two common character sets are:
o American Standard Code for Informa on Interchange (ASCII)
o Universal Character Encoding (UNICODE)
What is hexadecimal?
 Hexadecimal is a number system that is made up of 16 digits, 10
numbers (0-9) and 6 le ers (A-F)
0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15
0 1 2 3 4 5 6 7 8 9 A B C D E F
 Hexadecimal is referred to as a base-16 number system
 Each digit has a weight factor of 16 raised to a power, the rightmost digit
is 1s (16^0), the next digit to the le 16s (16^1)
 In GCSE you are required to work with up to and including 2 digit
hexadecimal values
16s 1s
1 3
1 x16 3x1 = 19
 A quick comparison table demonstrates
a rela onship between hexadecimal and a binary nibble
 One hexadecimal digit can represent four bits of binary data
Denary Binary Hexadecimal
0 0000 0
1 0001 1
2 0010 2
3 0011 3
4 0100 4
6|Page

5 0101 5
6 0110 6
7 0111 7
8 1000 8
9 1001 9
10 1010 A
11 1011 B
12 1100 C
13 1101 D
14 1110 E
15 1111 F
Denary to Binary Conversion
How do you convert denary to binary?
 It is important to know the process of conver ng from denary to binary
to understand how computers interpret and process data
 To convert from denary to binary you must start by wri ng out a binary
number line
 Find the first column heading with a value larger than the denary
value you are conver ng
 Write down each column heading to the right (not including the largest
heading) un l you reach 1
32,768 16,384 8,192 4,096 2,048 1,024 512 256 128 64 32 16 8 4 2
Example 1
 To convert the denary number 45 to binary, start by wri ng out the
binary number line
 The first column heading larger than 45 is 64, so the number line would
be:
32 16 8 4 2 1
7|Page

 Start at the le most empty column heading (32)


 Divide column heading into denary number (how many mes does 32 fit
into 45?)
o 1 me with 13 remaining
13
32 16 8 4 2 1
1
 Repeat with next column heading (how many mes does 16 fit into 13?)
o 0 mes with 13 remaining
13 13
32 16 8 4 2 1
1 0
 Repeat un l all columns have a binary value
13 13 5 1 1 0
32 16 8 4 2 1
1 0 1 1 0 1
 Denary 45 is 101101 in binary (6 bits)
Examiner Tips and Tricks
Always read the ques on carefully to check for how many bits are expected in
your answer
 In the example above, a 6 bit answer has been given
 If they ques on requires an 8 bit answer, add 2 extra 0s to the start of
the answer
 Denary 45 is 101101 in 6 bit binary and 00101101 in 8 bit binary
Example 2
 To convert the denary number 3059 to binary, start by wri ng out the
binary number line
8|Page

 The first column heading larger than 3059 is 4096, so the number line
would be:
2,048 1,024 512 256 128 64 32 16 8 4 2 1

 Start at the le most empty column heading (2048)


 Divide column heading into denary number (how many mes does 2048
fit into 3059?)
o 1 me with 1011 remaining
1011
2,048 1,024 512 256 128 64 32 16 8 4 2 1
1
 Repeat with next column heading (how many mes does 1024 fit into
1011?)
o 0 mes with 1011 remaining
1011 1011
2,048 1,024 512 256 128 64 32 16 8 4 2 1
1 0
 Repeat un l all columns have a binary value
1011 1011 499 243 115 51 19 3 3 3 1 0
2,048 1,024 512 256 128 64 32 16 8 4 2 1
1 0 1 1 1 1 1 1 0 0 1 1
 Denary 3059 is 101111110011 in binary (12 bits)
Binary to Denary Conversion
 To convert from binary to denary, count how many bits make up the
value
 Write out the column headings for the number of bits given from right to
le
 Add together any column heading with a value of 1 in the column
Example 1 (4 bits)
9|Page

 To convert the binary number 1011 to denary, start by wri ng out the
binary headings from right to le
8 4 2 1

 Write in the binary digits under the headings from le to right


8 4 2 1
1 0 1 1
 Add together any column heading with a 1 under it
 (1 x 8) + (1 x 2) + (1 x 1) = 11
 Binary 1011 is 11 in denary
Examiner Tips and Tricks
If you are conver ng from binary to denary and the binary number ends in 1,
the denary answer must be an odd number!
Example 2 (8 bits)
 To convert the binary number 01100011 to denary, start by wri ng out
the binary headings from right to le
128 64 32 16 8 4 2 1

 Write in the binary digits under the headings from le to right


128 64 32 16 8 4 2 1
0 1 1 0 0 0 1 1
 Add together any column heading with a 1 under it
 (1 x 64) + (1 x 32) + (1 x 2) + (1 x 1) = 99
 Binary 01100011 is 99 in denary
Example 3 (14 bits)
 To convert the binary number 01110001110100 to denary, start
by wri ng out the binary headings from right to le
8,192 4,096 2,048 1,024 512 256 128 64 32 16 8 4 2 1
10 | P a g e

0 1 1 1 0 0 0 1 1 1 0 1 0 0
 Add together any column heading with a 1 under it
 (1 x 4096) + (1 x 2048) + (1 x 1024) + (1 x 64) + (1 x 32) + (1 x 16) + (1 x 4)
= 7284
 Binary 01110001110100 is 7284 in denary
Denary to Hexadecimal Conversion
How do you convert denary to hexadecimal?
Method 1 (denary to binary to hexadecimal)
 To convert the denary number 28 to hexadecimal, start by conver ng
the denary number to binary
128 64 32 16 8 4 2 1
0 0 0 1 1 1 0 0
 Split the 8 bit binary number into two nibbles as shown below
8 4 2 1 8 4 2 1
0 0 0 1 1 1 0 0
 Convert each nibble to its denary value
 0001 = 1 and 1100 = 12
 Using the comparison table, the denary value 1 is also 1 in hexadecimal
whereas denary value 12 is represented in hexadecimal as C
 Denary 28 is 1C in hexadecimal
Method 2 (divide by 16)
 To convert the denary number 163 to hexadecimal, start by dividing the
denary value by 16 and recording the whole mes the number goes in
and the remainder

 163 16 = 10 remainder 3
 In hexadecimal the whole number = digit 1 and the remainder = digit 2
 Digit 1 = 10 (A)
 Digit 2 = 3
 Denary 163 is A3 in hexadecimal
11 | P a g e

Hexadecimal to Denary Conversion


How do you convert hexadecimal to denary?
Method 1 (hexadecimal to binary to denary)
 To convert the hexadecimal number B9 to denary, take each hexadecimal
digit and convert it from its denary value to 4 bit binary (nibble)
B (11) 9
8 4 2 1 8 4 2 1
1 0 1 1 1 0 0 1
 Join the two nibbles to make an 8 bit number (byte)
 Convert from binary to denary
128 64 32 16 8 4 2 1
1 0 1 1 1 0 0 1
 (1 x 128) + (1 x 32) + (1 x 16) + (1 x 8) + (1 x 1) = 185
 Hexadecimal B9 is 185 in denary
Method 2 (mul ply by 16)
 To convert the hexadecimal number 79 to denary, start by mul plying
the first hexadecimal digit by 16

 7 ✖ 16 = 112
 Add digit 2 to the result
 112 + 9 = 121
 Hexadecimal 79 is 121 in denary
Examiner Tips and Tricks
Remember that the exam is non-calculator, if you are not confident mul plying
and dividing by 16 then use method 1 on both conversions
Binary to Hexadecimal Conversion
How do you convert from binary to hexadecimal?
 It is important before revising how to convert from binary to
hexadecimal and vice versa that you fully understand
the binary and hexadecimal number systems.
12 | P a g e

0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15
0 1 2 3 4 5 6 7 8 9 A B C D E F
Example 1
 To convert the binary number 10110111 to hexadecimal, first split the 8
bit number into 2 binary nibbles
8 4 2 1 8 4 2 1
1 0 1 1 0 1 1 1
 For each nibble, convert the binary to it’s denary value
 (1 x 8) + (1 x 2) + (1 x 1) = 11 (B)
 (1 x 4) + (1 x 2) + (1 x 1) = 7
 Join them together to make a 2 digit hexadecimal number
 Binary 10110111 is B7 in hexadecimal
Example 2
 To convert the binary number 00111001 to hexadecimal, first split the 8
bit number into 2 binary nibbles
8 4 2 1 8 4 2 1
0 0 1 1 1 0 0 1
 For each nibble, convert the binary to it’s denary value
 (1 x 2) + (1 x 1) = 3
 (1 x 8) + (1 x 1) = 9
 Join them together to make a 2 digit hexadecimal number
 Binary 00111001 is 39 in hexadecimal
Hexadecimal to Binary Conversion
How do you convert from hexadecimal to binary?
Example 1
 To convert the hexadecimal number 5F to binary, first split the digits
apart and convert each to a binary nibble
8 4 2 1
13 | P a g e

0 1 0 1 =5
8 4 2 1
1 1 1 1 = 15 (F)
 Join the 2 binary nibbles together to create an 8 bit binary number
128 64 32 16 8 4 2 1
0 1 0 1 1 1 1 1
 Hexadecimal 5F is 01011111 in binary
Example 2
 To convert the hexadecimal number 26 to binary, first split the digits
apart and convert each to a binary nibble
8 4 2 1
0 0 1 0 =2
8 4 2 1
0 1 1 0 =6
 Join the 2 binary nibbles together to create an 8 bit binary number
128 64 32 16 8 4 2 1
0 0 1 0 0 1 1 0
 Hexadecimal 26 is 00100110 in binary
Uses of Hexadecimal
Why is hexadecimal used?
 In Computer Science hexadecimal is o en preferred when working
with large values
 It takes fewer digits to represent a given value in hexadecimal than in
binary
o 1 hexadecimal digit corresponds 4 bits (one nibble) and can
represent 16 unique values (0-F)
 It is beneficial to use hexadecimal over binary because:
o The more bits there are in a binary number, the harder it makes
for a human to read
14 | P a g e

o Numbers with more bits are more prone to errors when being
copied
 Examples of where hexadecimal can be seen:
o MAC addresses
o Colour codes
o URLs
MAC addresses
 A typical MAC address consists of 12 hexadecimal digits, equivalent
to 48 digits in in binary
o AA:BB:CC:DD:EE:FF
o 10101010:10111011:11001100:11011101:11101110:11111111
 Wri ng down or performing calcula ons with 48 binary digits makes
it very easy to make a mistake

Colour codes
 A typical hexadecimal colour code consists of 6 hexadecimal digits,
equivalent to 24 digits in binary
o #66FF33 (green)
o 01000010:11111111:00110011
15 | P a g e

URL's
 A URL can only contain standard characters (a-z and A-Z), numbers (0-9)
and some special symbols which is enough for basic web browsing
 If a URL needs to include a character outside of this set, they are
converted into a hexadecimal code
 Hexadecimal codes included in a URL are prefixed with a % sign
Adding Posi ve 8-bit Binary Integers
What is binary addi on?
 Binary addi on is the process of adding together two binary
integers (up to and including 8 bits)
 To be successful there are 5 golden rules to apply:
Binary Addi on Binary Answer Working
16 | P a g e

1s
0+0= 0
0 =0

1s
0+1= 1
1 =1

1s
1+0= 1
1 =1

2s 1s
1+1= 10
1 0 =2

2s 1s
1+1+1= 11
1 1 =3
 Like denary addi on, start from the rightmost digit and move le
 Carrying over occurs when the sum of a column is greater than 1,
passing the excess to the next le column
Example 1
 Add together the binary values 1001 and 0100
8 4 2 1
1 0 0 1 +
0 1 0 0
C

 Star ng from right to le , add the two binary values together applying
the 5 golden rules
 If your answer has 2 digits, place the rightmost digit in the column
and carry the remaining digit to the next column on the le
 In this example, start with 1+0, 1+0 = 1, so place a 1 in the column
8 4 2 1
+
1 0 0 1
17 | P a g e

0 1 0 0
C
1
 Repeat un l all columns have a value
8 4 2 1
1 0 0 1 +
0 1 0 0
C
1 1 0 1
 The sum of adding together binary 1001 (9) and 0100 (4) is 1101 (13)
Examiner Tips and Tricks
Make sure any carried digits are clearly visible in your answer, there are marks
available for working. Carries can be put above or below in the addi on
Example 2
 Add together the binary values 00011001 and 10000100
128 64 32 16 8 4 2 1
0 0 0 1 1 0 0 1 +
1 0 0 0 1 0 0 1
C

 Star ng from right to le , add the two binary values together applying
the 5 golden rules
 If your answer has 2 digits, place the rightmost digit in the column
and carry the remaining digit to the next column on the le
 In this example, start with 1+1, 1+1 = 10, so place a 0 in the column and
carry the 1 to the next column
128 64 32 16 8 4 2 1
+
0 0 0 1 1 0 0 1
18 | P a g e

1 0 0 0 1 0 0 1
1 C
0
 Repeat un l all columns have a value
128 64 32 16 8 4 2 1
0 0 0 1 1 0 0 1 +
1 0 0 0 1 0 0 1
1 1 1 C
1 0 1 0 0 0 1 0
 The sum of adding together binary 00011001 (25) and 10001001 (137)
is 10100010 (162)
Overflow & Binary Addi on
What is an overflow error?
 An overflow error occurs when the result of a binary addi on exceeds
the available bits
 For example, if you took binary 11111111 (255) and tried to
add 00000001 (1) this would cause an overflow error as the result would
need a 9th bit to represent the answer (256)
256 128 64 32 16 8 4 2 1
1 1 1 1 1 1 1 1 +
0 0 0 0 0 0 0 1
1 1 1 1 1 1 1 1 C
0 0 0 0 0 0 0 0
Examiner Tips and Tricks
When star ng a binary addi on ques on, always look at the ques on that
comes a er. If it asks you to name what problem has been caused, you know
the binary addi on ques on must cause an overflow error and therefore mean
a carried bit that does not fit in to the answer
19 | P a g e

Binary Shi s
What is a logical binary shi ?
 A logical binary shi is how a computer system performs basic
mul plica on and division on non-nega ve values (0 and posi ve
numbers)
 Binary digits are moved le or right a set number of mes
 A le shi mul plies a binary number by 2 (x2)
 A right shi divides a binary number by 2 (/2)
 A shi can move more than one place at a me, the principle remains
the same
 A le shi of 2 places would mul ply the original binary number by 4
(x4)
How do you perform a logical le shi of 1?
 Here is the binary representa on of the denary number 40
128 64 32 16 8 4 2 1
0 0 1 0 1 0 0 0
 To perform a le logical binary shi of 1, we move each bit 1 place to the
le
 The digit in the 128 column (MSB) will move le causing an overflow
error
 The 1 column becomes empty so is filled with a 0
128 64 32 16 8 4 2 1
0 1 0 1 0 0 0 = 40
0 1 0 1 0 0 0 0 = 80
 The original binary representa on of denary 40 (32+8) was mul plied
by 2 and became 80 (64+16)
How do you perform a logical le shi of 2?
 Here is the binary representa on of the denary number 28
128 64 32 16 8 4 2 1
20 | P a g e

0 0 0 1 1 1 0 0
 To perform a le binary shi of 2, we move each bit 2 places to the le
 The digit in the 128 (MSB) and 64 column will move le causing
an overflow error
 The 1 and 2 column become empty so are filled with a 0
128 64 32 16 8 4 2 1
0 1 1 1 0 0 = 28
0 1 1 1 0 0 0 0 = 112
 The original binary representa on of denary 28 (16+8+4) was mul plied
by 4 and became 112 (64+32+16)
How do you perform a logical right shi of 1?
 Here is the binary representa on of the denary number 40
128 64 32 16 8 4 2 1
0 0 1 0 1 0 0 0
 To perform a right binary shi of 1, we move each bit 1 place to the right
 The digit in the 1 column (LSB) will move right causing an underflow
error
 The 128 column becomes empty so is filled with a 0
128 64 32 16 8 4 2 1
0 0 1 0 1 0 0 = 40
0 0 0 1 0 1 0 0 = 20
 The original binary representa on of denary 40 (32+8) was divided by
2 and became 20 (16+4)
How do you perform a logical right shi of 2?
 Here is the binary representa on of the denary number 200
128 64 32 16 8 4 2 1
1 1 0 0 1 0 0 0
 To perform a right binary shi of 2, we move each bit 2 places to the
right
21 | P a g e

 The digits in the 1 (LSB) and 2 columns will move right causing an
underflow error
 The 128 and 64 columns become empty so are filled with a 0
128 64 32 16 8 4 2 1
1 1 0 0 1 0 = 200
0 0 1 1 0 0 1 0 = 50
 The original binary representa on of denary 200 (128+64+8) was divided
by 4 and became 50 (32+16+2)
Two's Complement
What is two's complement?
 Two's complement is a method of using signed binary
values to represent nega ve numbers
 Using two's complement the le most bit is designated the most
significant bit (MSB)
 To represent nega ve numbers this bit must equal 1, turning the column
value in to a nega ve
 Working with 8 bits, the 128 column becomes -128
-128 64 32 16 8 4 2 1
1 1 1 1 1 1 1 1 = -1
 In the example above to represent -1, add column values with a 1 to
the MSB
o MSB (-128)
o Add 64 (-128+64 = -64
o Add 32 (-64+32 = -32)
o Add 16 (-32+16 = -16)
o Add 8 (-16+8 = -8)
o Add 4 (-8+4 = -4)
o Add 2 (-4+2 = -2)
o Add 1 (-2+1 = -1)
22 | P a g e

 The two's complement representa on of -1 is 11111111


Quick two's complement conversion
 To represent -76
 Write out the posi ve version of the number
128 64 32 16 8 4 2 1
0 1 0 0 1 1 0 0 = 76
 Star ng from the least significant bit (right most column), copy out the
binary values up to and including the first 1
-128 64 32 16 8 4 2 1
1 0 0
 For the remaining digits, invert them (0s to 1s/1s to 0s)
-128 64 32 16 8 4 2 1
1 0 1 1 0 1 0 0
 -128 + 32 + 16 + 4 = -76
 The two's complement representa on of -76 is 10110100
Character Sets
What is a character set?
 A character set is all the characters and symbols that can
be represented by a computer system
 Each character is given a unique binary code
 Character sets are ordered logically, the code for ‘B’ is one more than
the code for ‘A’
 A character set provides a standard for computers to communicate and
send/receive informa on
 Without a character set, one system might interpret 01000001
differently from another
 The number of characters that can be represented is determined by
the number of bits used by the character set
 Two common character sets are:
23 | P a g e

o American Standard Code for Informa on Interchange (ASCII)


o Universal Character Encoding (UNICODE)

ASCII
What is ASCII?
 ASCII is a character set and was an accepted standard for informa on
interchange
 ASCII uses 7 bits, providing 27 unique codes (128) or a maximum of 128
characters it can represent.
24 | P a g e
25 | P a g e

 ASCII only represents basic characters needed for English, limi ng its use
for other languages
Extended ASCII
 Extended ASCII uses 8 bits, providing 256 unique codes (28 = 256) or a
maximum of 256 characters it can represent
 Extended ASCII provides essen al characters such as mathema cal
operators and more recent symbols such as ©
Limita ons of ASCII & extended ASCII
 ASCII has a limited number of characters which means it can only
represent the English alphabet, numbers and some special characters
o A, B, C, ………, Z
o a, b, c ,.............,z
o 0, 1, 2,........, 9
o !, @, #, …..
 ASCII cannot represent characters from languages other than English
 ASCII does not include modern symbols or emojis common in today's
digital communica on
UNICODE
What is UNICODE?
 UNICODE is a character set and was created as a solu on to the
limita ons of ASCII
 UNICODE uses a minimum of 16 bits, providing 216 unique codes
(65,536) or a minimum of 65,536 characters it can represent
 UNICODE can represent characters from all the major languages around
the world
Examiner Tips and Tricks
Exam ques ons o en ask you to compare ASCII & UNICODE, for example the
number of bits, number of characters and what they store
26 | P a g e

ASCII vs UNICODE
ASCII UNICODE
Number of bits 7-bits 16-bits
Number of
128 characters 65,536 characters
characters
Used to represent characters in the Used to represent characters across
Uses
English language. the world.
It can represent more characters
than ASCII.
It uses a lot less storage space than It can support all common
Benefits
UNICODE. characters across the world.
It can represent special characters
such as emoji's.
It can only represent 128
characters. It uses a lot more storage space
Drawbacks
It cannot store special characters than ASCII.
such as emoji's.
Worked Example
The computer stores text using the ASCII character set.
Part of the ASCII character set is shown:
Character ASCII Denary Code
E 69
F 70
G 71
H 72
(a)
Iden fy the character that will be represented by the ASCII denary code 76 [1]
(b)
Iden fy a second character set [1]
Answers
(a) L (must be a capital) (b) UNICODE
27 | P a g e

How Sound is Sampled & Stored


How is sound sampled & stored?
 Measurements of the original sound wave are captured and stored as
binary on secondary storage
 Sound waves begin as analogue and for a computer system to
understand them they must be converted into a digital form
 This process is called Analogue to Digital conversion (A2D)
 The process begins by measuring the amplitude of the analogue sound
wave at a point in me, called samples
 Each measurement (sample) generates a value which can be represented
in binary and stored
 Using the samples, a computer is able to create a digital version of the
original analogue wave
 The digital wave is stored on secondary storage and can be played back
at any me by reversing the process

 In this example, the grey line represents the digital wave that has been
created by taking samples of the original analogue wave
 In order for the digital wave to look more like the analogue wave the
sample rate and bit depth can be changed
28 | P a g e

Sample Rate & Sample Resolu on


What is sample rate?
 Sample rate is the amount of samples taken per second of the analogue
wave
 Samples are taken each second for the dura on of the sound
 The sample rate is measured in Hertz (Hz)
 1 Hertz is equal to 1 sample of the sound wave

In this example you can see that the higher the sample rate, the closer to the
original sound wave the digital version looks

 The sampling rate of a typical audio CD is 44.1kHz (44,100 Hertz or


44,100 samples per second)
 Using the graphic above helps to answer the ques on, “Why does
telephone hold music sound so bad?”
29 | P a g e

What is sample resolu on?


 Sample resolu on is the number of bits stored per sample of sound
 Sample resolu on is closely related to the colour depth of a bitmap
image, they measure the same thing in different contexts
What effect do sample rate and sample resolu on have?
Sample rate Sample resolu on
High Low High Low
Playback quality ⇑ ⇓ ⇑ ⇓
File size ⇑ ⇓ ⇑ ⇓
30 | P a g e

Bitmap Images
What is a bitmap?
 A bitmap image is made up of squares called pixels
 A pixel is the smallest element of a bitmap image
 Each pixel is stored as a binary code
 Binary codes are unique to the colour in each pixel
 A typical example of a bitmap image is a photograph

 The more colours and more detail in the image, the higher the quality of
the image and the more binary that needs to be stored
Resolu on & Colour Depth
What is resolu on?
 Resolu on is the total amount of pixels that make up a bitmap image
 The resolu on is calculated by mul plying the height and width of the
image (in pixels)
 In general, the higher the resolu on the more detail in the
image (higher quality)
 Resolu on can also refer to the total amount of pixels horizontally in a
display, such as:
o Computer monitors - 1440p means 1440 pixels horizontally
compared to 4K which is 3840 pixels (roughly 4 thousand)
o TVs - HD (high defini on) channels have a resolu on of 1080p,
1080 pixels horizontally compared to newer UHD (ultra high
defini on) channels with 3840 pixels (4K)
o YouTube - The quality bu on allows a user to change the video
playback resolu on from 144p (144 pixels horizontally) up to 4K
31 | P a g e

What is colour depth?


 Colour depth is the number of bits stored per pixel in a bitmap image
 The colour depth is dependent on the number of colours needed in the
image
 In general, the higher the colour depth the more detail in the
image (higher quality)
 In a black & white image the colour depth would be 1, meaning 1 bit is
enough to create a unique binary code for each colour in the image
(1=white, 0=black)

 In an image with a colour depth of 2, you would have 00, 01, 10 & 11
available binary codes, so 4 colours

 As colour depth increases, so does the amount of colours available in an


image
 The amount of colours can be calculated as 2n (n = colour depth)
32 | P a g e

Colour Depth Amount of Colours


1 bit 2 (B&W)
2 bit 4
4 bit 16
8 bit 256
24 bit 16,777,216 (True Colour)
What is the impact of resolu on and colour depth?
 As the resolu on and/or colour depth increases, the bigger the size of
the file becomes on secondary storage
 The higher the resolu on, the more pixels are in the image, the more
bits are stored
 The higher the colour depth, the more bits per pixel are stored
 Striking a balance between quality and file size is always a considera on

Worked Example
1. Define the term Pixel [1]
2. If an image has a colour depth of 2 bits, how many colours can the image
represent? [1]
3. Describe the impact of changing an images resolu on from 500x500 to
1000x1000 [2]
Answers
1. The smallest element of a bitmap image (1 square)
2. 4
3. The image quality would be higher [1] the file size would be larger [1]
33 | P a g e

Units of Data Storage


What are units of data storage?
 A unit of data is a term given to describe different amounts of binary
digits stored on a digital device
 These are the units you need to know for IGCSE:
Unit Symbol Value
Bit b 1 or 0
Nibble 4b
Byte B 8b
Kibibyte KiB 1024 B (210)
Mebibyte MiB 1,048,576 KB (220)
Gibibyte GiB 1,073,741,824 MB (230)
Tebibyte TiB 1,099,511,626,776 GB (240)
Megabyte vs Mebibyte
 1 kibibyte (1KiB) = 1024 bytes (1024 B) - binary prefixes (to the power of
2)
 1 kilobyte (1KB) = 1000 bytes (1000 B) - decimal prefixes (to the power
of 10)
Conver ng between units
 It is o en a requirement of the exam to be able to convert between
different units of data, for example bytes to mebibytes (larger) or
kibibytes to bytes (smaller)
 This process involves division, moving up in size of unit
and mul plica on, moving down in size of unit
 When dealing with all units bigger than a byte we use mul ples
of 1024 (210)
 For example, 2000 kibibytes in mebibytes would be 2000 / 1024 = 1.95
MiB and 2 tebibytes in gibibytes would be 2 * 1024 = 2048 GiB
 When dealing with bits and bytes the same process is used with the
value 8 as there are 8 bits in a byte
34 | P a g e

 For example, 24 bits in bytes would be 24 / 8 = 3 B and 10 bytes in bits


would be 10 * 8 = 80 b
Unit
Bit
Mul ply by 8 ⇑ Divide by 8 ⇓
Byte
Kibibyte
Mebibyte
Mul ply by 1024 ⇑ Divide by 1024 ⇓
Gibibyte
Tebibyte
Calcula ng File Sizes
How do you calculate the size of a bitmap image?
 Calcula ng the size of a bitmap image can be carried out with either of
the following formulas:
o Resolu on x colour depth
o Image width x image height x colour depth
Example
Image Files
(Resolu on) x (Colour Depth)

Size of bitmap image


=
Resolu on = width x
Resolu on 250,000
height
Colour Depth 24 bits (3 bytes) 24 bits = 3 bytes
=
6,000,000 bits
(bit to bytes) /8
250,000 x 24 750,000 bytes
(bytes to KiB)
732 KiB
/1024
250000 x 3 = 750,000 bytes
35 | P a g e

(bytes to KiB) 732 KiB


/1024
OR
Image Files
(Image width) x (Image height) x (Colour Depth)

Size of bitmap image =


Image width 500
Image height 500
Colour Depth 24 bits 24 bits = 3 bytes
= 6,000,000 bits
(500 x 500 x 24) (bit to bytes) /8 750,000 bytes
(bytes to KiB) /1024 732 KiB
= 750,000 bytes
(500 x 500 x 3)
(bytes to KiB) /1024 732 KiB
How do you calculate the size of a sound file?
 Calcula ng the size of a sound file is carried out with the following
formula:
o Sample rate x dura on x sample resolu on
Example
Sound Files
(Sample Rate) x (Dura on in seconds) x (Sample Resolu on)

Size of sound file


=
Sample rate 100 Samples per second
Dura on 60 Seconds
Number of bits stored per
Sample resolu on 24
sample
100 x 60 x 24 = 144,000 bits
36 | P a g e

(bit to bytes) /8 18,000 bytes


(bytes to KiB) 18 KiB
/1024
The Need For Compression
What is compression?
 Compression is reducing the the size of a file so that it takes up less
space on secondary storage
 The impact of compression is:
o Less storage space required
o Less bandwidth required
o Shorter transmission me
 Compression can be achieved using two methods, lossy and lossless
Lossy Compression
What is lossy compression?
 Lossy compression is when data is lost in order to reduce the size on
secondary storage
 Lossy compression is irreversible
 Lossy can greatly reduce the size of a file but at the expense of losing
quality
 Lossy is only suitable for data where reducing quality is acceptable, for
example images, video and sound
 In photographs, lossy compression will try to group similar colours
together, reducing the amount of colours in the image without
compromising the overall quality of the image
37 | P a g e
38 | P a g e

 In the images above, lossy compression is applied to a photograph and


drama cally reduces the file size
 Data has been removed and the overall quality has been reduced,
however it is acceptable as it is difficult to visually see a difference
 Lossy compressed photographs take up less storage space which means
you can store more and they are quicker to share across a network
Lossless Compression
What is lossless compression?
 Lossless compression is when data is encoded in order to reduce the size
on secondary storage
 Lossless compression is reversible, the file can be returned to its original
state
 Lossless can reduce the size of a file but not as drama cally as lossy
 Lossless can be used on all data but is more suitable for data where a
loss in quality is unacceptable, for example documents
 In a document, lossless compression algorithms such as run length
encoding (RLE) can be used to analyse the contents looking
for pa erns and repe on.
What is run length encoding?
 Run length encoding (RLE) is a form of lossless data compression
that condenses iden cal elements into a single value with a count
 For a text file, "AAAABBBCCDAA" is compressed to "4A3B2C1D2A"
 The string has four 'A's, followed by three 'B's, two 'C's, one 'D', and two
'A's
 RLE is used in bitmap images to compress sequences of the same colour
 For example, a line in an image with 5 red pixels followed by 3 blue pixels
could be represented as "5R3B"
Lossless file formats
39 | P a g e

 In the image above, lossless compression is automa cally applied to


document formats such as DOCX and PDF with a different rate of
success
 When you open a lossless compressed document the decompression
process reverses the algorithms and returns the data back to its original
state
 Lossless compressed documents take up less storage space which means
you can store more and they are quicker to share across a network
Worked Example
An email is sent containing a sound file.
Lossy compression is used to compress the sound file.
Explain two reasons why using lossy compression is beneficial. [4]
How to answer this ques on
 What are the differences between lossy and lossless?
 Can you state two differences? [2 marks]
 Can you say why each point is a benefit? [2 marks]
Answer
 Lossy will decrease the file size [1]
 ...so it can sent via email quicker [1]
 Lossy means data is lost [1]
 ...the difference is unlikely to be no ced by humans [1]

You might also like