Data Representation - duncanrig.s

Download Report

Transcript Data Representation - duncanrig.s

Data Representation
S2
This unit covers how the computer
represents•
•
•
•
Numbers
Text
Graphics
Control
Numbers
Our number system is called the Decimal or denary
number system. We use the digits 0 to 9 to represent any
number.
We use the column headings –
Thousands Hundreds
3
Tens Units
2
5
so 325 is made up of 3 hundreds + 2 tens + 5 units
300 +
20+
=325
5
Computers have their own number system called Binary.
They only have 2 digits to represent any number, 0 or 1.
0 = off
1 = on
Each 0 or 1 is called a bit. (binary digit)
In Binary the column headings are –
128
64
32
16
8
4
2
1
Converting a binary number to denary
Example: Convert 0100 0101 to denary
Step 1 – write down column headings
128
64
32
16
8
4
2
1
Step 2 – place binary number under correct heading
128
64
32
16
8
4
2
1
0
1
0
0
0
1
0
1
Step 3 -
Add up all the headings that have a 1 underneath them
64
+4
+1
= 69ten
So, 0100 0101 in denary is 69ten.
Example 2 : Convert 1001 1010 to denary
Step 1 – write down column headings
128
64
32
16
8
4
2
1
Step 2 – place binary number under correct heading
128
64
32
16
8
4
2
1
1
0
0
1
1
0
1
0
Step 3 Add up all the headings that have a 1 underneath them
128
+16
+8
+2
= 154 ten
So, 1001 1010 in denary is 154ten.
Convert the following binary
numbers to denary
1.
2.
3.
4.
5.
6.
7.
8.
0000 0011
0001 1001
0110 0100
1000 0010
1010 1010
1100 1011
1110 0011
1111 0010
1. 3ten
2. 25ten
3. 100ten
4. 130ten
5. 170ten
6. 203ten
7. 227ten
8. 242 ten
Convert the following decimal
numbers to binary
1.
2.
3.
4.
5.
6.
7.
8.
12
25
47
63
88
106
201
254
1. 0000 1100
2. 0001 1001
3. 0010 1111
4. 0011 1111
5. 0101 1000
6. 0110 1010
7. 1100 1001
8. 1111 1110
HOW TEXT IS STORED IN A COMPUTER
A binary code is used to represent each character. The
code used most often is known as the American Standard
Code for Information Interchange – or ASCII.
CHARACTER – any symbol or letter on the computer
keyboard e.g. c, G, 2, 9, $ are all characters
BYTE – a binary code which is made up of eight bits; a
byte is used to represent one character.
Examples of ASCII codes:
CHARACTER
CODE
R
01010010
m
01101101
%
00100101
+
00101011
The word “Hello” would be stored as:
H
01001000
e
01100101
l
01101100
l
01101100
o
01101111
Representing Graphics
Graphics (pictures) on the computer screen are made up of
tiny dots called pixels.
Each pixel may be “on” or “off” depending on whether the
value of the pixel in memory is 1 or 0.
0 0
0
0
0
0 0
0
0
1 1
1
1 0
0
0 0
0
1
0
0 0
0
0
0
0 1
0
0 0
0
0 0
0 1
0 0 0
0
0 0
0
1
0
0 0
0
0 0
0
0
0 0 0
0
0 0
0
0
0
0
1
0 0
By writing in the place values above each box, we can
calculate the numbers the computer would need to store
to be able to show the graphic on screen.
128
64
32
16
8
4
2
1
0 0
0
0
0
0 0
0
=0
0
1 1
1
1 0
0
=64+32+16+8+4=124
0 0
0
1
0
0 0
0
=16
0
0
0 1
0
0 0
0
=16
0 0
0 1
0 0 0
0
=16
0 0
0
1
0
0 0
0
=16
0 0
0
0
0 0 0
0
=0
0 0
0
0
0
0
=0
1
0 0
For the computer to show this graphic on screen, the
following numbers
0, 124, 16, 16, 16, 16, 0, 0 have to be stored in memory.