3. PAGE 1 3
Number Systems (1)
• Positional Notation
N = (an-1an-2 ... a1a0 . a-1a-2 ... a-m)r (1.1)
where . = radix point
r = radix or base
n = number of integer digits to the left of the radix point
m = number of fractional digits to the right of the radix point
an-1 = most significant digit (MSD)
a-m = least significant digit (LSD)
• Polynomial Notation (Series Representation)
N = an-1 x rn-1 + an-2 x rn-2 + ... + a0 x r0 + a-1 x r-1 ... + a-m x r-m
= (1.2)
• N = (251.41)10 = 2 x 102 + 5 x 101 + 1 x 100 + 4 x 10-1 + 1 x 10-2
a r
i
i
i m
n
1
4. PAGE 1 4
Number Systems (2)
• Binary numbers
– Digits = {0, 1}
– (11010.11)2 = 1 x 24 + 1 x 23 + 0 x 22 + 1 x 21 + 0 x 20 + 1 x 2-1 + 1 x 2-2
= (26.75)10
– 1 K (kilo) = 210 = 1,024, 1M (mega) = 220 = 1,048,576,
1G (giga) = 230 = 1,073,741,824
• Octal numbers
– Digits = {0, 1, 2, 3, 4, 5, 6, 7}
– (127.4)8 = 1 x 82 + 2 x 81 + 7 x 80 + 4 x 8-1 = (87.5)10
• Hexadecimal numbers
– Digits = {0, 1, 2, 3, 4, 5, 6, 7, 8, 9, A, B, C, D, E, F}
– (B65F)16 = 11 x 163 + 6 x 162 + 5 x 161 + 15 x 160 = (46,687)10
5. PAGE 1 5
Number Systems (3)
• Important Number Systems (Table 1.1)
Decimal Binary Octal Hexadecimal
0 0 0 0
1 1 1 1
2 10 2 2
3 11 3 3
100 4 4
5 101 5 5
6 110 6 6
7 111 7 7
8 1000 10 8
9 1001 11 9
10 1010 12 A
11 1011 13 B
12 1100 14 C
13 1101 15 D
14 1110 16 E
15 1111 1 F
16 10000 20 10
10. PAGE 1 10
Arithmetic (5)
• Hexadecimal Arithmetic (Use Table 1.5)
– Addition
1 0 1 1 Carries
5 B A 9 Augend
+ D 0 5 8 Addend
1 2 C 0 1 Sum
– Subtraction
9 10 A 10 Borrows
A 5 B 9 Minuend
+ 5 8 0 D Subtrahend
4 D A C Difference
12. PAGE 1 12
Base Conversion (1)
• Series Substitution Method
– Expanded form of polynomial representation:
N = an-1rn-1 + … + a0r0 + a-1r-1 + … + a-mr-m (1.3)
– Conversation Procedure (base A to base B)
• Represent the number in base A in the format of Eq. 1.3.
• Evaluate the series using base B arithmetic.
– Examples:
• (11010)2 ( ? )10
N = 124 + 123 + 022 + 121 + 020
= (16)10 + (8)10 + 0 + (2)10 + 0
= (26)10
• (627)8 ( ? )10
N = 682 + 281 + 780
= (384)10 + (16)10 + (7)10
= (407)10
13. PAGE 1 13
Base Conversion (2)
• Radix Divide Method
– Used to convert the integer in base A to the equivalent base B integer.
– Underlying theory:
• (NI)A = bn-1Bn-1 + … + b0B0 (1.4)
Here, bi’s represents the digits of (NI)B in base A.
• NI / B (bn-1Bn-1 + … + b1B1 + b0B0 ) / B
= (Quotient Q1: bn-1Bn-2 + … + b1B0 ) + (Remainder R0: b0)
• In general, (bi)A is the remainder Ri when Qi is divided by (B)A.
– Conversion Procedure
1. Divide (NI)B by (B)A, producing Q1 and R0. R0 is the least significant
digit, d0, of the result.
2. Compute di, for i = 1 … n - 1, by dividing Qi by (B)A, producing Qi+1
and Ri, which represents di.
3. Stop when Qi+1 = 0.
15. PAGE 1 15
Base Conversion (4)
• Radix Multiply Method
– Used to convert fractions.
– Underlying theory:
• (NF)A = b-1B-1 + b-2B-2 + … + b-mB-m (1.5)
Here, (NF)A is a fraction in base A and bi’s are the digits of (NF)B in
base A.
• B NF = B (b-1B-1 + b-2B-2 + … + b-mB-m )
= (Integer I-1: b-1) + (Fraction F-2: b-2B-1 + … + b-mB-(m-1))
• In general, (bi)A is the integer part I-i, of the product of F-(i+1) (BA).
– Conversion Procedure
1. Let F-1 = (NF)A.
2. Compute digits (b-i)A, for i = 1 … m, by multiplying Fi by (B)A,
producing integer I-i, which represents (b-i)A, and fraction F-(i+1).
3. Convert each digits (b-i)A to base B.
17. PAGE 1 17
Base Conversion (6)
• General Conversion Algorithm
• Algorithm 1.1
To convert a number N from base A to base B, use
(a) the series substitution method with base B arithmetic, or
(b) the radix divide or multiply method with base A arithmetic.
• Algorithm 1.2
To convert a number N from base A to base B, use
(a) the series substitution method with base 10 arithmetic to convert N
from base A to base 10, and
(b) the radix divide or multiply method with decimal arithmetic to convert
N from base 10 to base B.
• Algorithm 1.2 is longer, but easier and less error prone.
18. PAGE 1 18
Base Conversion (7)
• Example
(18.6)9 = ( ? )11
(a) Convert to base 10 using series substitution method:
N10 = 1 91 + 8 90 + 6 9-1
= 9 + 8 + 0.666…
= (17.666…)10
(b) Convert from base 10 to base 11 using radix divide and multiply
method:
7.326 0.666 11
3.586 0.326 11
6.446 0.586 11
N11 = (16.736 …)11
17
11
1
11
0
6
1
.
19. PAGE 1 19
Base Conversion (8)
• When B = Ak
• Algorithm 1.3
(a) To convert a number N from base A to base B when B = Ak and k is a
positive integer, group the digits of N in groups of k digits in both directions
from the radix point and then replace each group with the equivalent digit in
base B
(b) To convert a number N from base B to base A when B = Ak and k is a
positive integer, replace each base B digit in N with the equivalent k digits in
base A.
• Examples
– (001 010 111. 100)2 = (127.4)8 (group bits by 3)
– (1011 0110 0101 1111)2 = (B65F)16 (group bits by 4)
20. PAGE 1 20
Signed Number Representation
• Signed Magnitude Method
– N = (an-1 ... a0.a-1 ... a-m)r is represented as
N = (san-1 ... a0.a-1 ... a-m)rsm, (1.6)
where s = 0 if N is positive and s = r -1 otherwise.
– N = -(15)10
– In binary: N = -(15)10= -(1111)2 = (1, 1111)2sm
– In decimal: N = -(15)10 = (9, 15)10sm
• Complementary Number Systems
– Radix complements (r's complements)
[N]r = rn - (N)r (1.7)
where n is the number of digits in (N)r.
– Positive full scale: rn-1 - 1
– Negative full scale: -rn - 1
– Diminished radix complements (r-1’s complements)
[N]r-1 = rn - (N)r - 1