Representation of numeric data in computer

advertisement
Representation of numeric data in computer
A.
Basic unit of representation in computer
A bit – short form of binary digit, is either a ‘0’ or ‘1’
A byte – group of 8 bits
B.
Number systems represented in computer
i)
The decimal(denary) number system
- the most commonly used number system in daily life
- consists of digits 0,1,2,3,4,5,6,7,8,9
ii)
The binary number system
- consists of digits 0 and 1 only
-
all data are represented in binary digits ‘0’ or ‘1’ inside computer
it is the simplest number system
iii) The hexadecimal number system
- consists of 16 digits, 0,1,2,3,4,5,6,7,8,9,A,B,C,D,E,F
- 4 bits can be represented by 1 hexadecimal digit, therefore it is a shorthand
form to represent binary digits, e.g.
- ‘9’ represents binary digits ‘1001’
- ‘3’ represents binary digits ‘0011’
- ‘A’ represents binary digits ‘1010’
- ‘F’ represents binary digits ‘1111’
C.
Conversion of binary number to decimal number
e.g. 1012 = 1x22 + 0x21 + 1x20 = 4 + 0 + 1 = 510
e.g. 10112 = 1x23 + 0x22 + 1x21 + 1x20 = 8 + 0 + 2 + 1 = 1110
D.
Conversion of hexadecimal number to decimal number
e.g. 2A16 = 2x161 + 10x160 = 32 + 10 = 4210
e.g. 1AF16 = 1x162 + 10x161 + 15x160 = 256 + 160 + 15 = 43110
E.
Conversion of decimal number to binary number
use short division method, repeatedly divided by 2
e.g. 710 = 1112
e.g. 1410 = 11102
F.
Conversion of decimal number to hexadecimal number
use short division method, repeatedly divided by 16
e.g. 2810 = 1C16
e.g. 25510 = FF16
1
Exercise
1.
Convert the following numbers to decimal numbers
(a) 101012
(b) 11112
(c) AB16
(d) 24E16
2.
Convert the following numbers to binary numbers
(a) 2910
(b) 10710
3.
Convert the following numbers to hexadecimal numbers
(a) 1710
(b) 10010
2
Conversion between binary and hexadecimal
Refer to the table on the right
(a) Convert 7BF16 to binary number
(b) Convert 101101011012 to
hexadecimal number
3
Hexadecimal
Binary equivalent
0
0000
1
0001
2
0010
3
0011
4
0100
5
0101
6
0110
7
0111
8
1000
9
1001
A
1010
B
1011
C
1100
D
1101
E
1110
F
1111
Download