KLG Number System
KLG Number System
1
Base-N Number System
Base N
N Digits: 0, 1, 2, 3, 4, 5, …, N-1
Example: 1045N
Positional Number System
n 1 4 3 2 1 0
N N N N N N
d n 1 d 4 d3 d 2 d1 d 0
• Digit do is the least significant digit (LSD).
• Digit dn-1 is the most significant digit (MSD).
2
Decimal Number System
Base 10
Ten Digits: 0, 1, 2, 3, 4, 5, 6, 7, 8, 9
Example: 104510
Positional Number System
n 1 4 3 2 1 0
10 10 10 10 10 10
d n 1 d 4 d3 d 2 d1 d 0
5
Hexadecimal Number System
Base 16
Sixteen Digits: 0,1,2,3,4,5,6,7,8,9,A,B,C,D,E,F
Example: EF5616
Positional Number System
n1 4 3 2 1 0
16 16 16 16 16 16
0000 0 0100 4 1000 8 1100 C
0001 1 0101 5 1001 9 1101 D
0010 2 0110 6 1010 A 1110 E
0011 3 0111 7 1011 B 1111 F
6
Binary Addition
7
Hex Addition
• 4-bit Addition
4 + 4 = 8
4 + 8 = C
8 + 7 = F
F + E = 1D Note “carry”
8
Number Conversions
9
Decimal to Binary Conversion
Method I:
Use repeated subtraction.
Subtract largest power of 2, then next largest, etc.
10
Decimal to Binary Conversion
Suppose x = 156410
Subtract 1024: 1564-1024 (210) = 540 n=10 or 1 in the (210)’s position
Subtract 512: 540-512 (29) = 28 n=9 or 1 in the (29)’s position
28=256, 27=128, 26=64, 25=32 > 28, so we have 0 in all of these positions
Thus:
156410 = (1 1 0 0 0 0 1 1 1 0 0)2
11
Decimal to Binary Conversion
Method II:
Use repeated division by radix.
2 | 1564 2|__24_
782
2|_____ R=0 12
2|_____ R=0
391
2|_____ R=0 6
2|_____ R=0
195
2|_____ R=1 3
2|_____ R= 0
97
2|_____ R=1 1 R=1
2|_____
2|_____
48 R=1 0 R=1
24 R = 0
Collect remainders in reverse order
11000011100
12
Binary to Hex Conversion
01 1 0 0 0 0 1 1 1 0 0
Pad with 0’s
If unsigned number
13
Hexadecimal to Binary Conversion
Example
(1 E 9 C)16
14
Decimal to Hex Conversion
Method II:
Use repeated division by radix.
16 | 1564
97
16|_____ R = 12 = C
6
16|_____ R=1
0 R=6
N = 61C 16
15