Igcse Computer Science - Chapter 1
Igcse Computer Science - Chapter 1
1.1 Introduction
As you progress through this book you will begin to realise how complex computer
systems really are. By the time you reach Chapter 12 you should have a better
understanding of the fundamentals behind computers themselves and the software that
controls them.
However, no matter how complex the system, the basic building block in all
computers is the binary number system. This system is chosen since it consists of 1s
and 0s only. Since computers contain millions and millions of tiny ‘switches’, which
must be in the ON or OFF position, this lends itself logically to the binary system. A
switch in the ON position can be represented by 1; a switch in the OFF position can
be represented by 0.
The BINARY SYSTEM is based on the number 2. Thus, only the two ‘values’ 0 and 1
can be used in this system to represent each digit. Using the same method as denary,
this gives the headings of 20, 21, 22, 23 and so on. The typical headings for a binary
number with eight digits would be:
12
1.2.1 Converting from binary to denary
It is fairly straightforward to change a binary number into a denary number. Each time
a 1 appears in a column, the column value is added to the total. For example, the
binary number above is:
128 + 64 + 32 + 8 + 4 + 2 = 238 (denary)
The 0 values are simply ignored.
Activity 1.1
Convert the following binary numbers into denary:
a 00110011
b 01111111
c 10011001
d 01110100
e 11111111
f 00001111
g 10001111
h 11110000
i 01110000
j 11101110
Method 1
Consider the conversion of the denary number, 107, into binary. This method
involves placing 1s in the appropriate position so that the total equates to 107:
Method 2
This method involves successive division by 2. The remainders are then read from
BOTTOM to TOP to give the binary value. Again using 107, we get:
13
Figure 1.1
Activity 1.2
Convert the following denary numbers into binary (using both methods):
a41
b67
c86
d100
e111
f127
g144
h189
i200
j255
Table 1.1
Name of memory size Number of bits Equivalent denary value
1 kilobyte (1 KB) 210 1 024 bytes
14
1 megabyte (1 MB) 220 1 048 576 bytes
1 gigabyte (1 GB) 230 1 073 741 824 bytes
1 terabyte (1 TB) 240 1 099 511 627 776 bytes
1 petabyte (1 PB) 250 1 125 899 906 842 624 bytes
Figure 1.2
15
When computers (or microprocessors) are used to control devices (such as robots),
registers are used as part of the control system. The following example describes
how registers can be used in controlling a simple device.
A robot vacuum cleaner has three wheels, A, B and C. A rotates on a spindle to
allow for direction changes (as well as forward and backward movement); B and C
are fixed to revolve around their axles to provide only forward and backward
movement, and have an electric motor attached:
Figure 1.3
An 8-bit register is used to control the movement of the robot vacuum cleaner:
Figure 1.4
Activity 1.3
a What would be the effect if the register contained the following values?
i10011000
ii 1 0 1 0 0 1 0 1
iii 1 0 1 0 0 1 1 0
16
b What would the register contain if only motor C was ON and the motors
were turning in a BACKWARDS direction?
c What would the register contain if motor B and motor C were both ON but
B was turning in a backward direction and C was turning in a forward
direction?
d What would be the effect if the register contained the following?
11111111
Since 16 = 24 this means that FOUR binary digits are equivalent to each hexadecimal
digit. Table 1.2 summarises the link between binary, hexadecimal and denary.
Table 1.2
Binary value Hexadecimal value Denary value
0000 0 0
0001 1 1
0010 2 2
0011 3 3
0100 4 4
0101 5 5
0110 6 6
0111 7 7
1000 8 8
1001 9 9
1010 A 10
17
1011 B 11
1100 C 12
1101 D 13
1110 E 14
1111 F 15
Example 1
101111100001
First split this up into groups of 4 bits:
1011 1110 0001
Then, using Table 1.2, find the equivalent hexadecimal digits:
B E 1
Example 2
10000111111101
First split this up into groups of 4 bits:
10 0001 1111 1101
The left group only contains 2 bits, so add in two 0s:
0010 0001 1111 1101
Now use Table 1.2 to find the equivalent hexadecimal digits:
2 1 F D
Activity 1.4
Convert the following binary numbers into hexadecimal:
a11000011
18
b11110111
c1001111111
d10011101110
e000111100001
f100010011110
g0010011111110
h0111010011100
i1111111101111101
j00110011110101110
Converting from hexadecimal to binary is also very straightforward. Using the data in
Table 1.2, simply take each hexadecimal digit and write down the 4-bit code which
corresponds to the digit.
Example 3
4 5 A
Using Table 1.2, find the 4-bit code for each digit:
0100 0101 1010
Put the groups together to form the binary number:
010001011010
Example 4
B F 0 8
Again just use Table 1.2:
1011 1111 0000 1000
Then put all the digits together:
1011111100001000
Activity 1.5
Convert the following hexadecimal numbers into binary:
a6C
b59
cAA
dA00
e40E
fBA6
g9CC
19
h40AA
iDA47
j1AB0
Example 1
4 5 A
First multiply each digit by its value:
Example 2
C 8 F
First multiply each digit by its value:
Activity 1.6
Convert the following hexadecimal numbers into denary:
a6B
b9C
c4A
dFF
e1FF
fA01
gBB4
20
hCA8
i12AE
jAD89
To convert from denary to hexadecimal is a little more difficult. As with the
conversion from binary to denary, there are two very similar methods that can be
used. Again, the first method is ‘trial and error’ and the second method is more
methodical and involves repetitive division.
Method 1
Consider the conversion of the denary number, 2004, into hexadecimal. This method
involves placing hexadecimal digits in the appropriate position so that the total
equates to 2004:
Method 2
This method involves successive division by 16. The remainders are then read from
BOTTOM to TOP to give the hexadecimal value. Again using 2004, we get:
Figure 1.5
Activity 1.7
Convert the following denary numbers into hexadecimal (using both
methods):
a98
b227
c490
d511
e826
f1000
g2634
21
h3743
i4007
j5000
Figure 1.6
A program developer can look at each of the hexadecimal codes (as shown in Figure
1.6) and determine where the error lies. The value on the far left shows the memory
location so that it is possible to find out exactly where in memory the fault occurs.
This is clearly much more manageable using hexadecimal rather than using binary.
It’s a very powerful fault-tracing tool, but requires considerable knowledge of
computer architecture in order to interpret the results.
22
HYPERTEXT MARK-UP LANGUAGE (HTML) is used when writing and developing
web pages. HTML isn’t a programming language but is simply a mark-up language. A
mark-up language is used in the processing, definition and presentation of text (for
example, specifying the colour of the text).
HTML uses <tags> which are used to bracket a piece of code; for example, <td>
starts a standard cell in an HTML table, and </td> ends it. Whatever is between the
two tags has been defined. Here is a short section of HTML code:
<tr>
<td><h3>Small car</h3>
<h3>Used car sales</h3>
<h2>Cars from $500</h2>
<br><h2>Cash sales only</h2></td></br>
</tr>
<table border="1">
<colgroup>
<col span="2" style="background-color:red">
<col style="background-color:yellow">
</colgroup>
HTML code is often used to represent colours of text on the computer screen. The
values change to represent different colours. The different intensity of the three
primary colours (red, green and blue) is determined by its hexadecimal value. For
example:
• # FF 00 00 represents primary colour red
• # 00 FF 00 represents primary colour green
• # 00 00 FF represents primary colour blue
• # FF 00 FF represents fuchsia
• # FF 80 00 represents orange
• # B1 89 04 represents tan
and so on producing almost any colour the user wants. There are many websites
available that allow a user to find the HTML code for the colour needed.
Activity 1.8
Using the internet, find the HTML codes for a number of colours.
Try entering HTML code into the computer and see how the colours and
font types can be changed to good effect.
Make use of websites, such as www.html.am/ to produce your own web
pages.
23
With a little practice, you can import/embed images into your own design of
web page using freely available software.
Remember this is not a programming language. It is simply a mark-up
language, so very little programming skill is required to use HTML.
25
Figure 1.7
A good example of the use of ASCII codes is the representation of a web address (or
URL, which stands for uniform resource locator) such as www.hodder.co.uk which
becomes (using hexadecimal values):
Activity 1.9
Using the ASCII code table (Figure 1.7) convert the following URLs into the
26
equivalent hexadecimal:
a www.cie.org.uk
b www.cie.org.uk/computer_science
c https://www.hodder.co.uk
d www.HodderEducation.co.uk
e http://www.ucles.ac.uk/computing.htm
Sometimes the hexadecimal addresses are used in the address of files or web pages
as a security feature. It takes longer to type in the URL using the hexadecimal codes,
but it has the advantage that you are unlikely to fall into the trap of copying and
pasting a ‘fake’ website address.
27