CS 2210 – Notes Ch 1
CS 2210 – Notes Ch 1
O Levels
Computer Science
CS 2210 – Notes
Chapter No. 1
Data Representation
Number system
Text, sound & Image
Data storage & file compression
2|Page
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
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
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
To convert the binary number 1011 to denary, start by wri ng out the
binary headings from right to le
8 4 2 1
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
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
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
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
In this example you can see that the higher the sample rate, the closer to the
original sound wave the digital version looks
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
In an image with a colour depth of 2, you would have 00, 01, 10 & 11
available binary codes, so 4 colours
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