Unit 1: Data representation�
IGCSE Computer Science (0478)
www.thebiscomputing.com
Representation
We use symbols to represent many things. �
Can you think of some examples?
2
www.thebiscomputing.com
Representation
Computers are good at storing numbers — we’ll find out why later
Programs, text, numbers, images, sound, etc. are all represented in a computer using numbers
We just need to agree a coding system, e.g. 65 means A
Source: Pixabay
www.thebiscomputing.com
Data and instructions
The invention of computers allowed us to perform calculations more quickly, accurately, and efficiently than people can.
What are the components of a calculation? e.g. 5×12
Source: Pixabay
www.thebiscomputing.com
Data and instructions
How can we communicate our instructions to a computer?
By writing or running programs
How can we communicate data to a computer?
By entering or loading values
Source: Pixabay
www.thebiscomputing.com
Representation
How many states can a switch or bulb be in?
|
1 |
|
0 |
OR
|
1 |
|
0 |
OR
Two: on and off
These two states could also be called:
www.thebiscomputing.com
Representation
Think about how you could communicate a message to a friend in a different location using a two-state system.
You might like to use light, sound, electricity, or something else.
How could you communicate a short message to your friend?
Source: Pixabay
www.thebiscomputing.com
Binary representation
If you have more bulbs, you can represent more things.
How many combinations are there for a group of two light bulbs?
8
| |
0 | 1 |
www.thebiscomputing.com
Binary representation: solution
If you have more bulbs, you can represent more things.
How many combinations are there for a group of two light bulbs?
Four combinations:
9
| |
0 | 0 |
| |
0 | 1 |
| |
1 | 0 |
| |
1 | 1 |
www.thebiscomputing.com
Binary representation
In a computer, transistors are used instead of these bulbs.
Transistors are tiny electronic switches.
These 1s and 0s are actually the basis of a counting system called binary.
10
| | | | | | | |
1 | 0 | 1 | 0 | 1 | 1 | 1 | 0 |
These switches could represent 10101110 in binary.
www.thebiscomputing.com
Computers and electricity
Computers use electric circuits and switches to represent all data and instructions.
What are the tiny switches inside computers called?
Transistors. These are tiny at around 7 nanometers.
How many do you think would fit across a human hair?
11
Source: Wikimedia commons, Human-hair-1
www.thebiscomputing.com
14,285 transistors can fit across a single human hair
12
www.thebiscomputing.com
Computers and electricity
These transistors allow electricity to be on or off in a circuit.
We combine lots of circuits to represent data.
Everything in a computer is represented with combinations of 1s and 0s.
These switches could represent 10101110 in binary.
13
www.thebiscomputing.com
Number bases
What is the value of this number?
9019
14
| | | |
9 | 0 | 1 | 9 |
www.thebiscomputing.com
Number bases
What is the value of this number?
9019
Nine thousand and nineteen
15
| | | |
9 | 0 | 1 | 9 |
www.thebiscomputing.com
Number bases
Why does the first 9 hold more value than the last 9?
16
| | | |
9 | 0 | 1 | 9 |
www.thebiscomputing.com
Number bases
Why does the first 9 hold more value than the last 9?
Each number has a place value
17
| | | |
9 | 0 | 1 | 9 |
www.thebiscomputing.com
Number bases
What are the place values in this number?
18
| | | |
9 | 0 | 1 | 9 |
www.thebiscomputing.com
Number bases
What are the place values in this number?
19
| | | 1 |
9 | 0 | 1 | 9 |
www.thebiscomputing.com
Number bases
What are the place values in this number?
20
| | 10 | 1 |
9 | 0 | 1 | 9 |
www.thebiscomputing.com
Number bases
What are the place values in this number?
21
| 100 | 10 | 1 |
9 | 0 | 1 | 9 |
www.thebiscomputing.com
Number bases
What are the place values in this number?
22
1000 | 100 | 10 | 1 |
9 | 0 | 1 | 9 |
www.thebiscomputing.com
Number bases
You work out the next place value by multiplying by 10 as you move from right to left.
23
1000 | 100 | 10 | 1 |
9 | 0 | 1 | 9 |
x 10
x 10
x 10
www.thebiscomputing.com
Digits
How many digits are there in our decimal number system?
24
Source: Pixabay
www.thebiscomputing.com
Digits
How many digits are there in our decimal number system?
We have 10 digits:
0, 1, 2, 3, 4, 5, 6, 7, 8, 9
Our number system is a base 10 number system because it has 10 digits.
25
Source: Pixabay
www.thebiscomputing.com
Binary
Binary is a base 2 number systems.
This is because it uses only 2 digits: 0 and 1.
Make a prediction
What do you think the place value might be of each of the numbers in this table?
26
| | | 1 |
1 | 0 | 0 | 1 |
www.thebiscomputing.com
Binary
Binary is a base 2 number systems.
This is because it uses only 2 digits: 0 and 1.
Make a prediction
What do you think the place value might be of each of the numbers in this table?
27
| | 2 | 1 |
1 | 0 | 0 | 1 |
www.thebiscomputing.com
Binary
Binary is a base 2 number systems.
This is because it uses only 2 digits: 0 and 1.
Make a prediction
What do you think the place value might be of each of the numbers in this table?
28
| 4 | 2 | 1 |
1 | 0 | 0 | 1 |
www.thebiscomputing.com
Binary
Binary is a base 2 number systems.
This is because it uses only 2 digits: 0 and 1.
Make a prediction
What do you think the place value might be of each of the numbers in this table?
29
8 | 4 | 2 | 1 |
1 | 0 | 0 | 1 |
www.thebiscomputing.com
Binary
You work out the next place value by multiplying by 2 as you move from right to left.
30
8 | 4 | 2 | 1 |
1 | 0 | 0 | 1 |
x 2
x 2
x 2
www.thebiscomputing.com
Binary
You work out the next place value by multiplying by 2 as you move from right to left.
Each binary digit is called a bit.
31
8 | 4 | 2 | 1 |
1 | 0 | 0 | 1 |
x 2
x 2
x 2
www.thebiscomputing.com
Number bases
To work out the value of a number, you need to know its place value.
You then multiple the digit by its place value.
32
1000 | 100 | 10 | 1 |
9 | 0 | 1 | 9 |
www.thebiscomputing.com
Number bases
To work out the value of a number, you need to know its place value.
You then multiple the digit by its place value.
33
1000 | 100 | 10 | 1 |
9 | 0 | 1 | 9 |
9 x 1000 | 0 x 100 | 1 x 10 | 9 x 1 |
www.thebiscomputing.com
Number bases
To work out the value of a number, you need to know its place value.
You then multiple the digit by its place value.
34
1000 | 100 | 10 | 1 |
9 | 0 | 1 | 9 |
9 x 1000 | 0 x 100 | 1 x 10 | 9 x 1 |
9000 | 0 | 10 | 9 |
www.thebiscomputing.com
Number bases
Finally, you add all of those numbers together.
35
1000 | 100 | 10 | 1 |
9 | 0 | 1 | 9 |
9 x 1000 | 0 x 100 | 1 x 10 | 9 x 1 |
9000 | 0 | 10 | 9 |
www.thebiscomputing.com
Number bases
Finally, you add all of those numbers together.
36
1000 | 100 | 10 | 1 |
9 | 0 | 1 | 9 |
9 x 1000 | 0 x 100 | 1 x 10 | 9 x 1 |
9000 | 0 | 10 | 9 |
Nine thousand and nineteen
www.thebiscomputing.com
Number bases
You do exactly the same thing with binary numbers.
37
8 | 4 | 2 | 1 |
1 | 0 | 0 | 1 |
www.thebiscomputing.com
Number bases
You do exactly the same thing with binary numbers.
You multiply the digit by its place value.
38
8 | 4 | 2 | 1 |
1 | 0 | 0 | 1 |
1 x 8 | 0 x 4 | 0 x 2 | 1 x 1 |
www.thebiscomputing.com
Number bases
You do exactly the same thing with binary numbers.
You multiply the digit by its place value.
39
8 | 4 | 2 | 1 |
1 | 0 | 0 | 1 |
1 x 8 | 0 x 4 | 0 x 2 | 1 x 1 |
8 | 0 | 0 | 1 |
www.thebiscomputing.com
Number bases
Then you add all of the values together.
40
8 | 4 | 2 | 1 |
1 | 0 | 0 | 1 |
1 x 8 | 0 x 4 | 0 x 2 | 1 x 1 |
8 | 0 | 0 | 1 |
www.thebiscomputing.com
Number bases
Then you add all of the values together.
41
8 | 4 | 2 | 1 |
1 | 0 | 0 | 1 |
1 x 8 | 0 x 4 | 0 x 2 | 1 x 1 |
8 | 0 | 0 | 1 |
Nine
www.thebiscomputing.com
Number bases
Then you add all of the values together.
In binary it is a little easier because you are always multiplying by either 1 or 0.
You don’t really need to multiply.
42
8 | 4 | 2 | 1 |
1 | 0 | 0 | 1 |
1 x 8 | 0 x 4 | 0 x 2 | 1 x 1 |
8 | 0 | 0 | 1 |
Nine
www.thebiscomputing.com
Number bases
How can you tell the number base of a number that you are presented with?
e.g.
101
43
www.thebiscomputing.com
Number bases
You can use a subscript at the end of the number to state the number base.
1012
10110
�A base of 2 means that it is a binary number.
A base of 10 means that it is a decimal number.
44
www.thebiscomputing.com
Binary?
45
Base 10
Base 2
www.thebiscomputing.com
Binary?
46
Base 10
Base 2
www.thebiscomputing.com
How many digits does decimal have?
47
10
2
www.thebiscomputing.com
48
10
2
www.thebiscomputing.com
Converting from binary to decimal
In order to convert from binary to decimal you need to know the place value of each digit in the number.
When you are just starting to learn how to do this it is a good idea to always use a table like this one.
49
128 | 64 | 32 | 16 | 8 | 4 | 2 | 1 |
| | | | | | | |
www.thebiscomputing.com
Converting from binary to decimal
In order to convert from binary to decimal you need to know the place value of each digit in the number.
When you are just starting to learn how to do this it is a good idea to always use a table like this one.
Draw this table now.
50
128 | 64 | 32 | 16 | 8 | 4 | 2 | 1 |
| | | | | | | |
www.thebiscomputing.com
Converting from binary to decimal
If I give you the binary number 111 then you place the digits from right to left in the table.
51
128 | 64 | 32 | 16 | 8 | 4 | 2 | 1 |
| | | | | | | |
www.thebiscomputing.com
Converting from binary to decimal
If I give you the binary number 111 then you place the digits from right to left in the table.
52
128 | 64 | 32 | 16 | 8 | 4 | 2 | 1 |
| | | | | | | 1 |
www.thebiscomputing.com
Converting from binary to decimal
If I give you the binary number 111 then you place the digits from right to left in the table.
53
128 | 64 | 32 | 16 | 8 | 4 | 2 | 1 |
| | | | | | 1 | 1 |
www.thebiscomputing.com
Converting from binary to decimal
If I give you the binary number 111 then you place the digits from right to left in the table.
54
128 | 64 | 32 | 16 | 8 | 4 | 2 | 1 |
| | | | | 1 | 1 | 1 |
www.thebiscomputing.com
Converting from binary to decimal
Then you need to look at their place value and add those values together.
4 + 2 + 1 = 7
55
128 | 64 | 32 | 16 | 8 | 4 | 2 | 1 |
| | | | | 1 | 1 | 1 |
www.thebiscomputing.com
Converting from binary to decimal
Then you need to look at their place value and add those values together.
4 + 2 + 1 = 7
111 in binary is 7 in decimal
56
128 | 64 | 32 | 16 | 8 | 4 | 2 | 1 |
| | | | | 1 | 1 | 1 |
www.thebiscomputing.com
Converting from binary to decimal
Let’s try another.
Convert 1010 from binary to decimal.
57
128 | 64 | 32 | 16 | 8 | 4 | 2 | 1 |
| | | | 1 | 0 | 1 | 0 |
www.thebiscomputing.com
Converting from binary to decimal
This time you have some 0s. These can be left out of your calculation.
58
128 | 64 | 32 | 16 | 8 | 4 | 2 | 1 |
| | | | 1 | 0 | 1 | 0 |
www.thebiscomputing.com
Converting from binary to decimal
This time you have some 0s. These can be left out of your calculation.
8 + 2 = 10
59
128 | 64 | 32 | 16 | 8 | 4 | 2 | 1 |
| | | | 1 | 0 | 1 | 0 |
www.thebiscomputing.com
Converting from binary to decimal
This time you have some 0s. These can be left out of your calculation.
8 + 2 = 10
1010 in binary is 10 in decmial
60
128 | 64 | 32 | 16 | 8 | 4 | 2 | 1 |
| | | | 1 | 0 | 1 | 0 |
www.thebiscomputing.com
Converting from binary to decimal
Let’s try a slightly larger binary number.
Convert 101111 from binary to decimal.
61
128 | 64 | 32 | 16 | 8 | 4 | 2 | 1 |
| | 1 | 0 | 1 | 1 | 1 | 1 |
www.thebiscomputing.com
Converting from binary to decimal
Let’s try a slightly larger binary number.
Convert 101111 from binary to decimal.
62
128 | 64 | 32 | 16 | 8 | 4 | 2 | 1 |
| | 1 | 0 | 1 | 1 | 1 | 1 |
www.thebiscomputing.com
Converting from binary to decimal
Let’s try a slightly larger binary number.
Convert 101111 from binary to decimal.
101111 in binary is 47 in decimal
63
128 | 64 | 32 | 16 | 8 | 4 | 2 | 1 |
| | 1 | 0 | 1 | 1 | 1 | 1 |
www.thebiscomputing.com
Converting from binary to decimal
Use your table to help you answer the following quick fire questions.
64
128 | 64 | 32 | 16 | 8 | 4 | 2 | 1 |
| | | | | | | |
www.thebiscomputing.com
Convert these numbers from binary to decimal
65
www.thebiscomputing.com
101
66
5
6
www.thebiscomputing.com
101
67
5
6
www.thebiscomputing.com
1111
68
14
15
www.thebiscomputing.com
1111
69
14
15
www.thebiscomputing.com
10111
70
23
21
www.thebiscomputing.com
10111
71
23
21
www.thebiscomputing.com
1110
72
11
12
13
14
www.thebiscomputing.com
1110
73
11
12
13
14
www.thebiscomputing.com
10000011
74
128
131
129
132
www.thebiscomputing.com
10000011
75
128
131
129
132
www.thebiscomputing.com
Converting from decimal to binary
It is a little tricker to convert from decimal to binary.
You need to work from left to right.
And you need to subtract, not add.
76
128 | 64 | 32 | 16 | 8 | 4 | 2 | 1 |
| | | | | | | |
www.thebiscomputing.com
Converting from decimal to binary
Let’s start with a small decimal number.
5
77
128 | 64 | 32 | 16 | 8 | 4 | 2 | 1 |
| | | | | | | |
www.thebiscomputing.com
Converting from decimal to binary
Let’s start with a small decimal number.
5
You start by looking for the highest value that fits into the number 5.
78
128 | 64 | 32 | 16 | 8 | 4 | 2 | 1 |
| | | | | | | |
www.thebiscomputing.com
Converting from decimal to binary
Let’s start with a small decimal number.
5
You start by looking for the highest value that fits into the number 5.
79
128 | 64 | 32 | 16 | 8 | 4 | 2 | 1 |
| | | | | | | |
www.thebiscomputing.com
Converting from decimal to binary
Let’s start with a small decimal number.
5
You start by looking for the highest value that fits into the number 5.
80
128 | 64 | 32 | 16 | 8 | 4 | 2 | 1 |
| | | | | | | |
www.thebiscomputing.com
Converting from decimal to binary
Let’s start with a small decimal number.
5
You start by looking for the highest value that fits into the number 5.
81
128 | 64 | 32 | 16 | 8 | 4 | 2 | 1 |
| | | | | | | |
www.thebiscomputing.com
Converting from decimal to binary
Let’s start with a small decimal number.
5
You start by looking for the highest value that fits into the number 5.
82
128 | 64 | 32 | 16 | 8 | 4 | 2 | 1 |
| | | | | | | |
www.thebiscomputing.com
Converting from decimal to binary
Let’s start with a small decimal number.
5
You start by looking for the highest value that fits into the number 5.
83
128 | 64 | 32 | 16 | 8 | 4 | 2 | 1 |
| | | | | | | |
www.thebiscomputing.com
Converting from decimal to binary
Let’s start with a small decimal number.
5
You start by looking for the highest value that fits into the number 5.
84
128 | 64 | 32 | 16 | 8 | 4 | 2 | 1 |
| | | | | 1 | | |
www.thebiscomputing.com
Converting from decimal to binary
Once you have found a value, you enter a 1 in that column.
You then take that value away from your current number (5).
5 - 4 = 1
85
128 | 64 | 32 | 16 | 8 | 4 | 2 | 1 |
| | | | | 1 | | |
www.thebiscomputing.com
Converting from decimal to binary
Then you start looking for the highest value that fits into your remaining number.
5 - 4 = 1
86
128 | 64 | 32 | 16 | 8 | 4 | 2 | 1 |
| | | | | 1 | | |
www.thebiscomputing.com
Converting from decimal to binary
Then you start looking for the highest value that fits into your remaining number.
5 - 4 = 1
87
128 | 64 | 32 | 16 | 8 | 4 | 2 | 1 |
| | | | | 1 | | |
www.thebiscomputing.com
Converting from decimal to binary
Then you start looking for the highest value that fits into your remaining number.
5 - 4 = 1
88
128 | 64 | 32 | 16 | 8 | 4 | 2 | 1 |
| | | | | 1 | 0 | |
www.thebiscomputing.com
Converting from decimal to binary
Found it!
5 - 4 = 1
1 - 1 = 0
89
128 | 64 | 32 | 16 | 8 | 4 | 2 | 1 |
| | | | | 1 | 0 | 1 |
www.thebiscomputing.com
Converting from decimal to binary
Finally, you are left with your decimal to binary conversion.
5 in decimal is 101 in binary
90
128 | 64 | 32 | 16 | 8 | 4 | 2 | 1 |
| | | | | 1 | 0 | 1 |
www.thebiscomputing.com
Converting from decimal to binary
You can double-check your maths by doing a quick conversion back to binary to just make sure.
101 in binary is 5 in decimal!
This becomes more essential with higher numbers, especially if you are in an exam!
5 in decimal is 101 in binary
91
128 | 64 | 32 | 16 | 8 | 4 | 2 | 1 |
| | | | | 1 | 0 | 1 |
www.thebiscomputing.com
Converting from decimal to binary
Let’s try a higher number.
Convert the decimal number 60 into binary.
92
128 | 64 | 32 | 16 | 8 | 4 | 2 | 1 |
| | | | | | | |
www.thebiscomputing.com
Converting from decimal to binary
Let’s try a higher number.
Convert the decimal number 60 into binary.
What is the highest number in our table that will fit into 60?
93
128 | 64 | 32 | 16 | 8 | 4 | 2 | 1 |
| | | | | | | |
www.thebiscomputing.com
Converting from decimal to binary
Let’s try a higher number.
Convert the decimal number 60 into binary.
What is the highest number in our table that will fit into 60?
94
128 | 64 | 32 | 16 | 8 | 4 | 2 | 1 |
| | 1 | | | | | |
www.thebiscomputing.com
Converting from decimal to binary
Let’s try a higher number.
Convert the decimal number 60 into binary.
Take 32 away from 60, what are you left with?
60 - 32 = ?
95
128 | 64 | 32 | 16 | 8 | 4 | 2 | 1 |
| | 1 | | | | | |
www.thebiscomputing.com
Converting from decimal to binary
Let’s try a higher number.
Convert the decimal number 60 into binary.
Take 32 away from 60, what are you left with?
60 - 32 = 28
96
128 | 64 | 32 | 16 | 8 | 4 | 2 | 1 |
| | 1 | | | | | |
www.thebiscomputing.com
Converting from decimal to binary
Let’s try a higher number.
Convert the decimal number 60 into binary.
What is the highest value that fits into 28?
60 - 32 = 28
97
128 | 64 | 32 | 16 | 8 | 4 | 2 | 1 |
| | 1 | 1 | | | | |
www.thebiscomputing.com
Converting from decimal to binary
Let’s try a higher number.
Convert the decimal number 60 into binary.
Take 16 away from 28, what are you left with?
60 - 32 = 28
28 - 16 = ?
98
128 | 64 | 32 | 16 | 8 | 4 | 2 | 1 |
| | 1 | 1 | | | | |
www.thebiscomputing.com
Converting from decimal to binary
Let’s try a higher number.
Convert the decimal number 60 into binary.
Take 16 away from 28, what are you left with?
60 - 32 = 28
28 - 16 = 12
99
128 | 64 | 32 | 16 | 8 | 4 | 2 | 1 |
| | 1 | 1 | | | | |
www.thebiscomputing.com
Converting from decimal to binary
Let’s try a higher number.
Convert the decimal number 60 into binary.
What is the highest value that fits into 12?
60 - 32 = 28
28 - 16 = 12
100
128 | 64 | 32 | 16 | 8 | 4 | 2 | 1 |
| | 1 | 1 | | | | |
www.thebiscomputing.com
Converting from decimal to binary
Let’s try a higher number.
Convert the decimal number 60 into binary.
What is the highest value that fits into 12?
60 - 32 = 28
28 - 16 = 12
101
128 | 64 | 32 | 16 | 8 | 4 | 2 | 1 |
| | 1 | 1 | 1 | | | |
www.thebiscomputing.com
Converting from decimal to binary
Let’s try a higher number.
Convert the decimal number 60 into binary.
Take 8 away from 12, what are you left with?
60 - 32 = 28
28 - 16 = 12
12 - 8 = ?
102
128 | 64 | 32 | 16 | 8 | 4 | 2 | 1 |
| | 1 | 1 | 1 | | | |
www.thebiscomputing.com
Converting from decimal to binary
Let’s try a higher number.
Convert the decimal number 60 into binary.
Take 8 away from 12, what are you left with?
60 - 32 = 28
28 - 16 = 12
12 - 8 = 4
103
128 | 64 | 32 | 16 | 8 | 4 | 2 | 1 |
| | 1 | 1 | 1 | | | |
www.thebiscomputing.com
Converting from decimal to binary
Let’s try a higher number.
Convert the decimal number 60 into binary.
What is the highest value that fits into 4?
60 - 32 = 28
28 - 16 = 12
12 - 8 = 4
104
128 | 64 | 32 | 16 | 8 | 4 | 2 | 1 |
| | 1 | 1 | 1 | | | |
www.thebiscomputing.com
Converting from decimal to binary
Let’s try a higher number.
Convert the decimal number 60 into binary.
What is the highest value that fits into 4?
60 - 32 = 28
28 - 16 = 12
12 - 8 = 4
105
128 | 64 | 32 | 16 | 8 | 4 | 2 | 1 |
| | 1 | 1 | 1 | 1 | | |
www.thebiscomputing.com
Converting from decimal to binary
Let’s try a higher number.
Convert the decimal number 60 into binary.
Take 4 away from 4, what are you left with?
60 - 32 = 28
28 - 16 = 12
12 - 8 = 4
4 - 4 = ?
106
128 | 64 | 32 | 16 | 8 | 4 | 2 | 1 |
| | 1 | 1 | 1 | 1 | | |
www.thebiscomputing.com
Converting from decimal to binary
Let’s try a higher number.
Convert the decimal number 60 into binary.
Take 4 away from 4, what are you left with?
60 - 32 = 28
28 - 16 = 12
12 - 8 = 4
4 - 4 = 0
107
128 | 64 | 32 | 16 | 8 | 4 | 2 | 1 |
| | 1 | 1 | 1 | 1 | | |
www.thebiscomputing.com
Converting from decimal to binary
Let’s try a higher number.
Convert the decimal number 60 into binary.
There is nothing left so we enter 0s in the remaining columns.
60 - 32 = 28
28 - 16 = 12
12 - 8 = 4
4 - 4 = 0
108
128 | 64 | 32 | 16 | 8 | 4 | 2 | 1 |
| | 1 | 1 | 1 | 1 | 0 | 0 |
www.thebiscomputing.com
Converting from decimal to binary
Let’s try a higher number.
Convert the decimal number 60 into binary.
We have our answer!
60 in decimal is 111100 in binary
109
128 | 64 | 32 | 16 | 8 | 4 | 2 | 1 |
| | 1 | 1 | 1 | 1 | 0 | 0 |
www.thebiscomputing.com
Converting from decimal to binary
Let’s try a higher number.
Convert the decimal number 60 into binary.
Now we double-check that we were right.
32 + 16 + 8 + 4 = ?
110
128 | 64 | 32 | 16 | 8 | 4 | 2 | 1 |
| | 1 | 1 | 1 | 1 | 0 | 0 |
www.thebiscomputing.com
Converting from decimal to binary
Let’s try a higher number.
Convert the decimal number 60 into binary.
Now we double-check that we were right.
32 + 16 + 8 + 4 = 60
111
128 | 64 | 32 | 16 | 8 | 4 | 2 | 1 |
| | 1 | 1 | 1 | 1 | 0 | 0 |
www.thebiscomputing.com
Converting from decimal to binary
Try these conversions from decimal to binary.
112
128 | 64 | 32 | 16 | 8 | 4 | 2 | 1 |
| | | | | | | |
www.thebiscomputing.com
Converting from decimal to binary: solutions
Try these conversions from decimal to binary.
113
| 128 | 64 | 32 | 16 | 8 | 4 | 2 | 1 |
128 | 1 | 0 | 0 | 0 | 0 | 0 | 0 | 0 |
120 | | 1 | 1 | 1 | 1 | 0 | 0 | 0 |
80 | | 1 | 0 | 1 | 0 | 0 | 0 | 0 |
200 | 1 | 1 | 0 | 0 | 1 | 0 | 0 | 0 |
190 | 1 | 0 | 1 | 1 | 1 | 1 | 1 | 0 |
www.thebiscomputing.com
Converting from decimal to binary: solutions
Try these conversions from decimal to binary.
114
| 128 | 64 | 32 | 16 | 8 | 4 | 2 | 1 |
128 | 1 | 0 | 0 | 0 | 0 | 0 | 0 | 0 |
120 | | 1 | 1 | 1 | 1 | 0 | 0 | 0 |
80 | | 1 | 0 | 1 | 0 | 0 | 0 | 0 |
200 | 1 | 1 | 0 | 0 | 1 | 0 | 0 | 0 |
190 | 1 | 0 | 1 | 1 | 1 | 1 | 1 | 0 |
www.thebiscomputing.com
Converting from decimal to binary: solutions
Try these conversions from decimal to binary.
115
| 128 | 64 | 32 | 16 | 8 | 4 | 2 | 1 |
128 | 1 | 0 | 0 | 0 | 0 | 0 | 0 | 0 |
120 | | 1 | 1 | 1 | 1 | 0 | 0 | 0 |
80 | | 1 | 0 | 1 | 0 | 0 | 0 | 0 |
200 | 1 | 1 | 0 | 0 | 1 | 0 | 0 | 0 |
190 | 1 | 0 | 1 | 1 | 1 | 1 | 1 | 0 |
www.thebiscomputing.com
Converting from decimal to binary: solutions
Try these conversions from decimal to binary.
116
| 128 | 64 | 32 | 16 | 8 | 4 | 2 | 1 |
128 | 1 | 0 | 0 | 0 | 0 | 0 | 0 | 0 |
120 | | 1 | 1 | 1 | 1 | 0 | 0 | 0 |
80 | | 1 | 0 | 1 | 0 | 0 | 0 | 0 |
200 | 1 | 1 | 0 | 0 | 1 | 0 | 0 | 0 |
190 | 1 | 0 | 1 | 1 | 1 | 1 | 1 | 0 |
www.thebiscomputing.com
Converting from decimal to binary: solutions
Try these conversions from decimal to binary.
117
| 128 | 64 | 32 | 16 | 8 | 4 | 2 | 1 |
128 | 1 | 0 | 0 | 0 | 0 | 0 | 0 | 0 |
120 | | 1 | 1 | 1 | 1 | 0 | 0 | 0 |
80 | | 1 | 0 | 1 | 0 | 0 | 0 | 0 |
200 | 1 | 1 | 0 | 0 | 1 | 0 | 0 | 0 |
190 | 1 | 0 | 1 | 1 | 1 | 1 | 1 | 0 |
www.thebiscomputing.com
Converting from decimal to binary
Try these conversions from decimal to binary.
118
128 | 64 | 32 | 16 | 8 | 4 | 2 | 1 |
| | | | | | | |
www.thebiscomputing.com
Converting from decimal to binary: solutions
Try these conversions from decimal to binary.
119
| 128 | 64 | 32 | 16 | 8 | 4 | 2 | 1 |
65 | | 1 | 0 | 0 | 0 | 0 | 0 | 1 |
129 | 1 | 0 | 0 | 0 | 0 | 0 | 0 | 1 |
160 | 1 | 0 | 1 | 0 | 0 | 0 | 0 | 0 |
210 | 1 | 1 | 0 | 1 | 0 | 0 | 1 | 0 |
176 | 1 | 0 | 1 | 1 | 0 | 0 | 0 | 0 |
www.thebiscomputing.com
The four golden rules of binary addition
Rule 1
0 + 0 = 0
120
| | | | 0 |
| | | + | 0 |
| | | | 0 |
| | | | |
In decimal, 0 + 0 = 0
www.thebiscomputing.com
The four golden rules of binary addition
Rule 2
0 + 1 = 1
121
| | | | 0 |
| | | + | 1 |
| | | | 1 |
| | | | |
In decimal, 0 + 1 = 1
www.thebiscomputing.com
The four golden rules of binary addition
Rule 3
1 + 1 = 10
122
| | | | 1 |
| | + | | 1 |
| | | 1 | 0 |
| | | | |
In decimal, 1 + 1 = 2
www.thebiscomputing.com
The four golden rules of binary addition
Rule 4
1 + 1 + 1 = 11
123
| | | | 1 |
| | | | 1 |
| | + | | 1 |
| | | 1 | 1 |
| | | | |
In decimal, 1 + 1 + 1 = 3
www.thebiscomputing.com
Binary addition
Rules
124
| | | 1 | 0 | 0 |
+ | | | | 1 | 0 |
= | | | | | |
www.thebiscomputing.com
Binary addition
Rules
125
| | | 1 | 0 | 0 |
+ | | | | 1 | 0 |
= | | | | | 0 |
www.thebiscomputing.com
Binary addition
Rules
126
| | | 1 | 0 | 0 |
+ | | | | 1 | 0 |
= | | | | 1 | 0 |
www.thebiscomputing.com
Binary addition
Rules
127
| | | 1 | 0 | 0 |
+ | | | | 1 | 0 |
= | | | 1 | 1 | 0 |
www.thebiscomputing.com
Binary addition
Rules
100 + 10 = 110 in binary
4 + 2 = 6 in decimal
128
| | | 1 | 0 | 0 |
+ | | | | 1 | 0 |
= | | | 1 | 1 | 0 |
www.thebiscomputing.com
Binary addition
Rules
129
| | | 1 | 0 | 0 |
+ | | | 1 | 0 | 1 |
= | | | | | |
www.thebiscomputing.com
Binary addition
Rules
130
| | | 1 | 0 | 0 |
+ | | | 1 | 0 | 1 |
= | | | | | 1 |
www.thebiscomputing.com
Binary addition
Rules
131
| | | 1 | 0 | 0 |
+ | | | 1 | 0 | 1 |
= | | | | 0 | 1 |
www.thebiscomputing.com
Binary addition
Rules
132
| | | 1 | 0 | 0 |
+ | | | 1 | 0 | 1 |
= | | 1 | 0 | 0 | 1 |
www.thebiscomputing.com
Binary addition
Rules
100 + 101 = 1001 in binary
4 + 5 = 9 in decimal
133
| | | 1 | 0 | 0 |
+ | | | 1 | 0 | 1 |
= | | 1 | 0 | 0 | 1 |
www.thebiscomputing.com
Binary addition
Rules
134
| | | 1 | 0 | 1 |
+ | | | | 1 | 1 |
= | | | | | |
| | | | | |
www.thebiscomputing.com
Binary addition
Rules
135
| | | 1 | 0 | 1 |
+ | | | | 1 | 1 |
= | | | | | 0 |
| | | | 1 | |
www.thebiscomputing.com
Binary addition
Rules
136
| | | 1 | 0 | 1 |
+ | | | | 1 | 1 |
= | | | | | 0 |
| | | | 1 | |
www.thebiscomputing.com
Binary addition
Rules
137
| | | 1 | 0 | 1 |
+ | | | | 1 | 1 |
= | | | | 0 | 0 |
| | | 1 | 1 | |
www.thebiscomputing.com
Binary addition
Rules
138
| | | 1 | 0 | 1 |
+ | | | | 1 | 1 |
= | | | | 0 | 0 |
| | | 1 | 1 | |
www.thebiscomputing.com
Binary addition
Rules
139
| | | 1 | 0 | 1 |
+ | | | | 1 | 1 |
= | | 1 | 0 | 0 | 0 |
| | | 1 | 1 | |
www.thebiscomputing.com
Binary addition
Rules
101 + 11 = 1000 in binary
5 + 3 = 8 in decimal
140
| | | 1 | 0 | 1 |
+ | | | | 1 | 1 |
= | | 1 | 0 | 0 | 0 |
| | | 1 | 1 | |
www.thebiscomputing.com
Binary addition
Rules
141
| | | 1 | 1 | 1 |
+ | | | | 1 | 1 |
= | | | | | |
| | | | | |
www.thebiscomputing.com
Binary addition
Rules
142
| | | 1 | 1 | 1 |
+ | | | | 1 | 1 |
= | | | | | 0 |
| | | | 1 | |
www.thebiscomputing.com
Binary addition
Rules
143
| | | 1 | 1 | 1 |
+ | | | | 1 | 1 |
= | | | | | 0 |
| | | | 1 | |
www.thebiscomputing.com
Binary addition
Rules
144
| | | 1 | 1 | 1 |
+ | | | | 1 | 1 |
= | | | | 1 | 0 |
| | | 1 | 1 | |
www.thebiscomputing.com
Binary addition
Rules
145
| | | 1 | 1 | 1 |
+ | | | | 1 | 1 |
= | | | | 1 | 0 |
| | | 1 | 1 | |
www.thebiscomputing.com
Binary addition
Rules
146
| | | 1 | 1 | 1 |
+ | | | | 1 | 1 |
= | | 1 | 0 | 1 | 0 |
| | | 1 | 1 | |
www.thebiscomputing.com
Binary addition
Rules
111 + 11 = 1010 in binary
7 + 3 = 10 in decimal
147
| | | 1 | 1 | 1 |
+ | | | | 1 | 1 |
= | | 1 | 0 | 1 | 0 |
| | | 1 | 1 | |
www.thebiscomputing.com
Binary addition: try it yourself!
Rules
148
| | | | | |
+ | | | | | |
= | | | | | |
| | | | | |
www.thebiscomputing.com
Binary addition: solutions
Rules
149
| | | | | |
+ | | | | | |
= | | | | | |
| | | | | |
www.thebiscomputing.com
Binary shifting
150
www.thebiscomputing.com
Binary shifting
Binary shifting is shifting the bits to the left or to the right.
If we shift to the left then we multiply.
If we shift to the right then we divide.
151
Source: Pixabay
www.thebiscomputing.com
Binary shifting
Take a look at this example.
I want to multiply 1002 by 102
152
128 | 64 | 32 | 16 | 8 | 4 | 2 | 1 |
0 | 0 | 0 | 0 | 0 | 1 | 0 | 0 |
www.thebiscomputing.com
Binary shifting
Take a look at this example.
I want to multiply 1002 by 102
I shift the bits to the left by one place
153
128 | 64 | 32 | 16 | 8 | 4 | 2 | 1 |
0 | 0 | 0 | 0 | 0 | 1 | 0 | 0 |
www.thebiscomputing.com
Binary shifting
Take a look at this example.
I want to multiply 1002 by 102
I shift the bits to the left by one place
154
128 | 64 | 32 | 16 | 8 | 4 | 2 | 1 |
0 | 0 | 0 | 0 | 1 | 0 | 0 | 0 |
www.thebiscomputing.com
Binary shifting
Take a look at this example.
I want to multiply 1002 by 102
I shift the bits to the left by one place
410 x 210 = 810
Or
1002 x 102 = 10002
155
128 | 64 | 32 | 16 | 8 | 4 | 2 | 1 |
0 | 0 | 0 | 0 | 1 | 0 | 0 | 0 |
www.thebiscomputing.com
Binary shifting
You can use binary shifts to multiply by 2, 4, 8, 16 etc.
If you want to multiply by 4 then you shift left by 2 spaces.
156
128 | 64 | 32 | 16 | 8 | 4 | 2 | 1 |
0 | 0 | 0 | 0 | 0 | 1 | 0 | 0 |
x2
x2
www.thebiscomputing.com
Binary shifting
You can use binary shifts to multiply by 2, 4, 8, 16 etc.
If you want to multiply by 4 then you shift left by 2 spaces.
157
128 | 64 | 32 | 16 | 8 | 4 | 2 | 1 |
0 | 0 | 0 | 1 | 0 | 0 | 0 | 0 |
x2
x2
www.thebiscomputing.com
Binary shifting
410 x 410 = 1610
1002 x 1002 = 100002
158
128 | 64 | 32 | 16 | 8 | 4 | 2 | 1 |
0 | 0 | 0 | 1 | 0 | 0 | 0 | 0 |
x2
x2
www.thebiscomputing.com
Binary shifting
Let’s try one!
1112 x 10002 = ?
159
128 | 64 | 32 | 16 | 8 | 4 | 2 | 1 |
0 | 0 | 0 | 0 | 0 | 1 | 1 | 1 |
www.thebiscomputing.com
Binary shifting
Let’s try one!
1112 x 10002 = ?
This is multiplying our number by 8.
How many shifts do you need to do to get from 1 to 8?
160
128 | 64 | 32 | 16 | 8 | 4 | 2 | 1 |
| | | | | | | |
www.thebiscomputing.com
Binary shifting
Let’s try one!
1112 x 10002 = ?
This is multiplying our number by 8.
How many shifts do you need to do to get from 1 to 8?
161
128 | 64 | 32 | 16 | 8 | 4 | 2 | 1 |
| | | | | | | |
x2
x2
x2
www.thebiscomputing.com
Binary shifting
Let’s try one!
1112 x 10002 = ?
This is multiplying our number by 8.
This means that we need to shift our bits three spaces to the left.
162
128 | 64 | 32 | 16 | 8 | 4 | 2 | 1 |
0 | 0 | 0 | 0 | 0 | 1 | 1 | 1 |
www.thebiscomputing.com
Binary shifting
Let’s try one!
1112 x 10002 = ?
This is multiplying our number by 8.
This means that we need to shift our bits three spaces to the left.
163
128 | 64 | 32 | 16 | 8 | 4 | 2 | 1 |
0 | 0 | 1 | 1 | 1 | 0 | 0 | 0 |
www.thebiscomputing.com
Binary shifting
1112 x 10002 = 1110002
Or
710 x 810 = 5610
164
128 | 64 | 32 | 16 | 8 | 4 | 2 | 1 |
0 | 0 | 1 | 1 | 1 | 0 | 0 | 0 |
www.thebiscomputing.com
Which direction do you shift to multiply?
165
LEFT
RIGHT
www.thebiscomputing.com
Which direction do you shift to multiply?
166
LEFT
RIGHT
www.thebiscomputing.com
Binary shifting
In order to divide, we do the same thing but step to the right!
167
128 | 64 | 32 | 16 | 8 | 4 | 2 | 1 |
0 | 0 | 0 | 0 | 0 | 1 | 0 | 0 |
www.thebiscomputing.com
Binary shifting
Let’s try this one:
1002 / 102 = ?
168
128 | 64 | 32 | 16 | 8 | 4 | 2 | 1 |
0 | 0 | 0 | 0 | 0 | 1 | 0 | 0 |
www.thebiscomputing.com
Binary shifting
Let’s try this one:
1002 / 102 = ?
We are dividing by 2 so we shift to the right by one place.
169
128 | 64 | 32 | 16 | 8 | 4 | 2 | 1 |
0 | 0 | 0 | 0 | 0 | 1 | 0 | 0 |
/ 2
www.thebiscomputing.com
Binary shifting
1002 / 102 = 102
Or
410 / 210 = 210
170
128 | 64 | 32 | 16 | 8 | 4 | 2 | 1 |
0 | 0 | 0 | 0 | 0 | 0 | 1 | 0 |
/ 2
www.thebiscomputing.com
Binary shifting
Let’s try another one:
1012 / 1002 = ?
171
128 | 64 | 32 | 16 | 8 | 4 | 2 | 1 |
0 | 0 | 0 | 0 | 0 | 1 | 0 | 1 |
www.thebiscomputing.com
Binary shifting
Let’s try another one:
1012 / 1002 = ?
Here we are dividing by 4 so we need to shift the values to the right by 2 places.
172
128 | 64 | 32 | 16 | 8 | 4 | 2 | 1 |
0 | 0 | 0 | 0 | 0 | 1 | 0 | 1 |
www.thebiscomputing.com
Binary shifting
Let’s try another one:
1012 / 1002 = ?
Here we are dividing by 4 so we need to shift the values to the right by 2 places.
173
128 | 64 | 32 | 16 | 8 | 4 | 2 | 1 |
0 | 0 | 0 | 0 | 0 | 0 | 0 | 1 |
www.thebiscomputing.com
Binary shifting
1012 / 1002 = 12
In binary shifting, we can only work with whole numbers.
Any remainders are discarded.
174
128 | 64 | 32 | 16 | 8 | 4 | 2 | 1 |
0 | 0 | 0 | 0 | 0 | 0 | 0 | 1 |
www.thebiscomputing.com
Binary shifting
1012 / 1002 = 12
If we do the same division with our decimal numbers then we are left with a decimal value.
510 / 410 = 1.2510
175
128 | 64 | 32 | 16 | 8 | 4 | 2 | 1 |
0 | 0 | 0 | 0 | 0 | 0 | 0 | 1 |
www.thebiscomputing.com
Which direction do you shift to divide?
176
LEFT
RIGHT
www.thebiscomputing.com
Which direction do you shift to divide?
177
LEFT
RIGHT
www.thebiscomputing.com
Binary shifting: try it yourself!
MULTIPLY
DIVIDE
178
128 | 64 | 32 | 16 | 8 | 4 | 2 | 1 |
| | | | | | | |
Draw a table to help you!
www.thebiscomputing.com
Binary shifting: solutions
MULTIPLY
DIVIDE
128 | 64 | 32 | 16 | 8 | 4 | 2 | 1 |
| | | | | | | |
www.thebiscomputing.com
Binary Subtraction
Can you subtract binary numbers? The answer is yes.
Subtraction of binary numbers is an arithmetic operation similar to the subtraction of decimal numbers or base 10 numbers.
| | 8 | 4 | 2 | 1 | |
9 | | 1 | 0 | 0 | 1 | |
-3 | | 0 | 0 | 1 | 1 | |
6 | | | | | | |
| | | | | | |
www.thebiscomputing.com
Binary Subtraction
| | 8 | 4 | 2 | 1 |
12 | | | | | |
-7 | | | | | |
5 | | | | | |
| | | | | |
| | 8 | 4 | 2 | 1 |
9 | | | | | |
-5 | | | | | |
4 | | | | | |
| | | | | |
www.thebiscomputing.com
Binary Subtraction
| | 8 | 4 | 2 | 1 |
14 | | | | | |
-9 | | | | | |
5 | | | | | |
| | | | | |
| | 8 | 4 | 2 | 1 |
13 | | | | | |
-2 | | | | | |
11 | | | | | |
| | | | | |
www.thebiscomputing.com
2’s Complement - Positive Binary Numbers
Up until now, we have assumed all binary numbers are positive integers.
To allow the possibility of representing negative integers we make use of two’s
complement. In this section we will again assume 8-bit registers are being used.
Only one minor change to the binary headings needs to be introduced here:
| -128 | 64 | 32 | 16 | 8 | 4 | 2 | 1 |
+19 | 0 | 0 | 0 | 1 | 0 | 0 | 1 | 1 |
+4 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | 0 |
Example 1:
The following two examples show how we can write the following positive binary
numbers in the two’s complement format 19 and 4:
www.thebiscomputing.com
2’s Complement
| -128 | 64 | 32 | 16 | 8 | 4 | 2 | 1 |
+38 | 0 | 0 | 1 | 0 | 0 | 1 | 1 | 0 |
Example 2:
Convert 38 to 8-bit binary numbers using the two’s complement format.
Since this number is positive, we must have a zero in the –128 column. It is then a
simple case of putting 1-values into their correct positions to make up the value
of 38:
www.thebiscomputing.com
2’s Complement
| -128 | 64 | 32 | 16 | 8 | 4 | 2 | 1 |
+125 | 0 | 1 | 1 | 1 | 1 | 1 | 0 | 1 |
Example 3:
Convert 125 to 8-bit binary numbers using the two’s complement format.
Since this number is positive, we must have a zero in the –128 column. It is then a
simple case of putting 1-values into their correct positions to make up the value
of 125:
www.thebiscomputing.com
2’s Complement
| -128 | 64 | 32 | 16 | 8 | 4 | 2 | 1 |
+125 | 0 | 1 | 1 | 1 | 1 | 1 | 0 | 1 |
Example 4:
Convert 125 to 8-bit binary numbers using the two’s complement format.
Since this number is positive, we must have a zero in the –128 column. It is then a
simple case of putting 1-values into their correct positions to make up the value
of 125:
www.thebiscomputing.com
| -128 | 64 | 32 | 16 | 8 | 4 | 2 | 1 |
| | | | | | | | |
www.thebiscomputing.com
2’s Complement - Negative Binary Numbers
| -128 | 64 | 32 | 16 | 8 | 4 | 2 | 1 |
-109 | 1 | 0 | 0 | 1 | 0 | 0 | 1 | 1 |
Example 1:
Convert -109 to 8-bit binary numbers using the two’s complement format.
By following our normal rules, each time a 1 appears in a column, the column value is added to the total. So, we can see that in denary this is: −128 + 16 + 2 + 1 = −109.
1 for negative numbers
-128 + 19 = -109
www.thebiscomputing.com
2’s Complement - Negative Binary Numbers
| -128 | 64 | 32 | 16 | 8 | 4 | 2 | 1 |
-28 | 1 | 1 | 1 | 0 | 0 | 1 | 0 | 0 |
Example 2:
Convert -28 to 8-bit binary numbers using the two’s complement format.
By following our normal rules, each time a 1 appears in a column, the column value is added to the total. So, we can see that in denary this is: −128 + 64 + 32 + 4 = −28
1 for negative numbers
-128 + 100 = -28
www.thebiscomputing.com
2’s Complement - Negative Binary Numbers
| -128 | 64 | 32 | 16 | 8 | 4 | 2 | 1 |
-11 | 1 | 1 | 1 | 1 | 0 | 1 | 0 | 1 |
Example 3:
Convert -11 to 8-bit binary numbers using the two’s complement format.
By following our normal rules, each time a 1 appears in a column, the column value is added to the total. So, we can see that in denary this is: −128 + 64 + 32 + 16 + 4 + 1 = −11.
1 for negative numbers
-128 + 117 = -11
www.thebiscomputing.com
Converting negative denary numbers into binary numbers in two’s complement format
| -128 | 64 | 32 | 16 | 8 | 4 | 2 | 1 |
67 | 0 | 1 | 0 | 0 | 0 | 0 | 1 | 1 |
Consider the number +67 in 8-bit (two’s complement) binary format:
Method 1: Now let’s consider the number −67. One method of finding the binary equivalent to −67 is to simply put 1s in their correct places:
| -128 | 64 | 32 | 16 | 8 | 4 | 2 | 1 |
-67 | 1 | 0 | 1 | 1 | 1 | 1 | 0 | 1 |
−128 + 32 + 16 + 8
+ 4 + 1 = −67
www.thebiscomputing.com
Method 2: Now let’s consider the number −67. One method of finding the binary equivalent to −67 is to simply put 1s in their correct places:
| -128 | 64 | 32 | 16 | 8 | 4 | 2 | 1 |
67 | 0 | 1 | 0 | 0 | 0 | 0 | 1 | 1 |
| 1 | 0 | 1 | 1 | 1 | 1 | 0 | 0 |
| | | | | | | + | 1 |
-67 | 1 | 0 | 1 | 1 | 1 | 1 | 0 | 1 |
first write the number as a positive binary value – in this case 67:
invert each binary value,which means swap the 1s and 0s around:
then add 1 to that number:
this gives us the binary for −67:
www.thebiscomputing.com
| -128 | 64 | 32 | 16 | 8 | 4 | 2 | 1 |
| | | | | | | | |
www.thebiscomputing.com
1.2 Text, Sound and Images
1.2.1 Character sets – ASCII code
The ASCII code system (American Standard Code for Information Interchange) was set up in 1963 for use in communication systems and computer systems.
A newer version of the code was published in 1986.
The standard ASCII code character set consists of 7-bit codes (0 to 127 in denary or 00 to 7F in hexadecimal) that represent the letters, numbers and characters found on a standard keyboard. The main disadvantage is that it
does not represent characters in non-Western languages.
www.thebiscomputing.com
1.2.1 Character sets – Unicode
Unicode can represent all languages of the world, thus supporting many operating systems, search engines and internet browsers used globally.
ASCII uses one byte to represent a character, whereas Unicode will support up to four bytes per character.
www.thebiscomputing.com
1.2.2 Representation of sound
Sound waves are vibrations in the air. The human ear senses these vibrations and interprets them as sound.
Each sound wave has a frequency, wavelength and amplitude.
The amplitude specifies the loudness of the sound.
www.thebiscomputing.com
Sound waves vary continuously. This means that sound is analogue. Computers cannot work with analogue data, so sound waves need to be sampled in order to be stored in a computer.
Sampling means measuring the amplitude of the sound wave. This is done using an analogue to digital converter (ADC).
Sampling rate is the number of sound samples taken per second. This is measured in hertz (Hz), where 1Hz means ‘one sample per second’.
www.thebiscomputing.com
1.2.2 Representation of images
Bitmap images are made up of pixels; an image is made up of a two-dimensional matrix of pixels. Pixels can take different shapes such as:
Each pixel can be represented as a binary number, and so a bitmap image is stored in a computer as a series of binary numbers.
www.thebiscomputing.com
The number of bits used to represent each colour is called the colour depth.
(22 = 4), corresponding to 00, 01, 10, or 11
(23 = 8), corresponding to 000, 001, 010, 011, 100, 101, 110, 111.
Modern computers have a 24 bit colour depth, which means over
16 million different colours can be represented
www.thebiscomputing.com
1.3 Data storage and file compression
1.3.1 Measurement of data storage & 1.3.2 calculation for File size
A bit is the basic unit of all computing memory storage terms and is either 1 or 0.
The file size of an image is calculated as:
The size of a mono sound file is calculated as:
image resolution (in pixels) × colour depth (in bits)
sample rate (in Hz) × sample resolution (in bits) × length of sample (in seconds)
www.thebiscomputing.com
Question 1: To calculate the file size of this image, firstly although only two colours have been used, let's presume a colour depth of 8 bit for this image.
Solution:
Firstly; calculate the total amount of pixels used in the image
8 pixels wide by 8 pixels tall: 8 x 8 = 64 (A total of 64 pixels used to represent the entire image)
Secondly; multiply the total pixels used by the colour depth (8 bits have been used to represent the content of each pixel) 64 pixels in total multiplied by 8(colour depth): 64 x 8 = 512
Answer: Image has a file size of 512 bits
www.thebiscomputing.com
Question 2: To calculate the file size of this image, firstly although only two colours have been used, let's presume a colour depth of 8 bit for this image.
Solution:
Firstly; calculate the total amount of pixels used in the image
8 pixels wide by 8 pixels tall: 16 x 16 = 256 (A total of 256 pixels used to represent the entire image)
Secondly; multiply the total pixels used by the colour depth (8 bits have been used to represent the content of each pixel) 256 pixels in total multiplied by 8(colour depth): 256 x 8 = 2048
Answer: Image has a file size of 2048 bits
www.thebiscomputing.com
1.3 Data Compression
Sound and image files can be very large, so they are often compressed to reduce their size.Compression is necessary for several reasons:
fewer bits and therefore transfer faster.�
www.thebiscomputing.com
Feature | Lossless Compression | Lossy Compression |
Definition | Reduces file size without losing any data. The file can be restored exactly to its original form. | Reduces file size by permanently removing some data that is less important or not easily noticed. |
Data loss | ❌ No data is lost | ✅ Some data is lost permanently |
File quality after compression | Quality stays the same as the original | Quality is slightly lower than the original |
Can original file be restored? | ✅ Yes, exactly the same | ❌ No, some parts are lost forever |
Common uses | Text files, software, PNG and GIF images | Photos, music, and videos |
Examples | ZIP, PNG, GIF, FLAC | JPEG, MP3, MP4, AAC |
www.thebiscomputing.com
Exam Style Questions
Download
205
www.thebiscomputing.com