1 Number Systems
1 Number Systems
28
Hexadecimal Number System
• Base (radix) = 16 1 E 5 . 7 A
• 16 digits
• {0, 1, 2, 3, 4, 5, 6, 7, 8,
• 9, A, B, C, D, E, F}
• Digit Position 256 16 1 1/16 1/256
• Integer & fraction
• Digit Weight
1*256 14*16 5*1 7*1/16 10*1/256
•
• Magnitude
256 + 224 + 5 + 0.4375 + 0.0390
• Sum of “Digit x Weight” 625
• Formal Notation 𝑎 ∗𝐵 +𝑎 ∗𝐵 +𝑎 ∗𝐵 +𝑎 ∗𝐵 +𝑎 ∗𝐵
29
Binary Number System
1 0 1 . 0 1
• Base (radix) = 2
• 2 digits {0, 1}
• binary digits “bits”
• Digit Position
4 2 1 1/2 1/4
• Integer & fraction
• Digit Weight
• 1*4 0*2 1*1 0*1/2 1*1/4
• Magnitude
4 + 0 + 1 + 0 + 0.25
• Sum of “Digit x Weight”
• Formal Notation 𝑎 ∗𝐵 +𝑎 ∗𝐵 +𝑎 ∗𝐵 +𝑎 ∗𝐵 +𝑎 ∗𝐵
30
Binary Number System
31
Number Base Conversion
Decimal to Binary/Octal/Hexadecimal
• Integer Conversion
1. Divide the number by the “Base”
2. Take the remainder as a coefficient
3. Take the quotient and repeat the division
• Fraction conversion
1. Multiply the number by the “Base”
2. Take the integer part as a coefficient
3. Take the resultant fraction repeat the multiplication
33
Decimal to Binary/Octal/Hexadecimal
• Example: to binary More conveniently
• Answer:
MSB LSB 34
Decimal to Binary/Octal/Hexadecimal
• Example: to binary Integer Remainder
Quotient Remainder Coefficient 41
41/2 20 1 𝑎 =1 20 1
20/2 10 0 𝑎 =0 10 0
10/2 5 0 𝑎 =0 5 0
5/2 2 1 𝑎 =1 2 1
2/2 1 0 𝑎 =0 1 0
1/2 0 1 𝑎 =1 0 1
• Answer:
35
Decimal to Binary/Octal/Hexadecimal
• Example: to octal
Integer Remainder
153
19 1
2 3
0 2
• Answer:
36
Decimal to Binary/Octal/Hexadecimal
• Example: to hexadecimal
Integer Remainder
1973
123 5
7 11
0 7
• Answer:
37
Decimal to Binary/Octal/Hexadecimal
• Example: to binary
Integer Fraction Coefficient
0.6875*2 1 0.3750 𝑎 =1
0.3750*2 0 0.7500 𝑎 =0
0.7500*2 1 0.500 𝑎 =1
0.500*2 1 0.000 𝑎 =1
• Answer:
38
Decimal to Binary/Octal/Hexadecimal
• Example: to octal
0.513*8 4.104
0.104*8 0.832
0.832*8 6.656
0.656*8 5.248
0.248*8 1.984
0.984*8 7.872
39
Decimal to Binary/Octal/Hexadecimal
• Using the examples above
40
Decimal to Binary/Octal/Hexadecimal
• Example: to hexadecimal
Integer Remainder
834
52 2 0.25*16 4.00
3 4
0 3
• Answer:
41
Decimal to Binary/Octal/Hexadecimal
• Example: to hexadecimal
Integer Remainder
445
27 13 0.75*16 12.00
1 11
0 1
• Answer:
42