Data Representation: Number Systems
Data Representation: Number Systems
Number systems
Number system
Counting things identifying the quantity of something. the set of symbols used to express quantities as the basis for counting, determining order, comparing amounts, performing calculations, and representing value.
3
Number system
People and computers do not normally speak the same language. Methods of translating information into forms that are understandable and usable to both are necessary. Humans generally speak in words and numbers expressed in the decimal number system, while computers only understand coded electronic pulses that represent digital information.
4
Decimal System
Based on decimal digits
0, 1, 2, 3, 4, 5, 6, 7, 8, 9
an a a
n
an
1 an
(a 0)
5
Decimal System
Decimal system has a base of 10
75 = 7 x 101 + 5 x 100 8563 = 8 x 103 + 5 x 102 + 6 x 101 + 3 x 100 0.368 = 3 x 10-1 + 6 x 10-2 + 8 x 10-3
104 103 102 101 100 10-1 10-2 10-3
10000
1000
100
10
0.1
0.01
0.001
Decimal System
For example, the number 657 is equivalent to: 6X102 + 5X101 + 7X100 7 sum 50 600 657
Binary System
Binary system has only two digits
0 and 1
To differentiate binary system and decimal system, we can use the following notations:
Decimal: 7510, 11010 Binary: 10102
Binary System
M u lt ip le s o f 2 2 D e c im a l e q u iv a le n t 16 8 4 2 1 0 .5 0 .2 5 0 .1 2 5
4
-1
-2
-3
0 2 4 610
sum
Example 2:
2110 = 101012
10
11
O c ta l
10
11
12
13
14
15
16
17
20
12
Hexadecimal Notation
Binary system is good for computers, but not convenient for human beings.
10110111 10100101 11010001 00110101
The conversion between binary system and decimal system is tedious. Computer professionals are used to use a compact notation
Hexadecimal notation
13
Hexadecimal Notation
uses the number 16 as a base. The Hexadecimal system is represented by any of the following 16 digits: 016 through 916, and A16 through F16 corresponding to decimal numbers 10 to15.
14
Hexadecimal Notation
Binary digits are grouped into sets of four, so there are 16 hexadecimal digits.
16
17
18
19
Radix Point
To convert a binary number to decimal by using the positional notation method; Step 1Write out the number to be converted; then, write in the decimal equivalent for each position with a 1 indicated. Step 2Add these values to determine the decimal equivalent of the binary number.
21
Radix Point
E x a m p le : C o n v e r t 1 0 1 1 0 . 0 1
2
t o d e c im a l.
P r o b le m :
0 8
1 4
1 2
0. 1
0 0 .5
D e c im a l: 1 6 V a lu e :
0 .2 5 0 .2 5 2 4 + 16 2 2 .2 5
10
T h e re fo re 1 0 1 1 0 .0 1
is e q u a l t o 2 2 . 2 5
10.
Take
n o te
th a t th e
a n s w e r m a y s im p ly
be
w r it t e n
a s 2 2 . 2 5 . D e c im a l n u m b e r s c a n
be
w r it t e n w it h o u t in c lu d in g t h e b a s e .
22
B in a r y H e x a d e c im a l
1000 8
1001 9
1010 A
1011 B
1100 C
1101 D
1110 E
1111 F
Step 1 Starting at the radix point and moving either right or left, break the number into groups of four. The grouping of binary into four bit groups is called binary-coded hexadecimal (BCH).
Step 2Convert each group of binary numbers into its hexadecimal equivalent.
23
B in a r y H e x a d e c im a l
1000 8
1001 9
1010 A
1011 B
1100 C
1101 D
1110 E
1111 F
E x a m p le : C o n v e r t 1 1 1 0 1 0 0 1 1 . 1 1 1 R a d ix P o in t
to h e x .
0001
1101
0011.
1110
3.
16
T h e re fo re 1 1 1 0 1 0 0 1 1 .1 1 1
is e q u a l t o 1 D 3 . E
16.
24
t o b in a r y .
16
1010
1100
1110
T h e re fo re A C E
16
is e q u a l t o 1 0 1 0 1 1 0 0 1 1 1 0
2.
25
Converting between Binary and Hexadecimal Much easier now! 10110111 10100101 11010001 00110101
B 7 A (B7A5D135)16 5 D 1 3 5
27
ASCII specifies a correspondence between digital bit patterns and the symbols of a written language.
Digital bit patterns are those stored inside the computer Symbols are those shown to users, like a, Y, 8, etc.
29
Byte
A single bit has two states: 0 or 1 One byte = 8 binary bits = 2 hexadecimal digits
A byte is also called an octet
Two bytes (16 bits) can have 216 = 65,536 states Four bytes (32 bits) can have 232=4,294,967,296 states
30
33