Chapter 1 Number Systems and Codes
Chapter 1
1
Number Systems (1)
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)
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)
Chapter 1
2
Number Systems (2)
= (26.75)10
1G (giga) = 230 = 1,073,741,824
Chapter 1
3
Number Systems (3)
Chapter 1
4
Arithmetic (1)
111011 Carries
101011 Augend
+ 11001 Addend
1000100
0 1 10 0 10 Borrows
1 0 0 1 0 1 Minuend
- 1 1 0 1 1 Subtrahend
1 0 1 0
Chapter 1
5
Arithmetic (2)
1 1 0 1 0 Multiplicand
x 1 0 1 0 Multiplier
0 0 0 0 0
1 1 0 1 0
0 0 0 0 0
1 1 0 1 0
1 0 0 0 0 0 1 0 0 Product
Chapter 1
6
Arithmetic (3)
1 1 1 Carries
5 4 7 1 Augend
+ 3 7 5 4 Addend
11445 Sum
6 10 4 10 Borrows
7 4 5 1 Minuend
- 5 6 4 3 Subtrahend
1 6 0 6 Difference
Chapter 1
7
Arithmetic (4)
326 Multiplicand
x 67 Multiplier
2732 Partial products
2404
26772 Product
Chapter 1
8
Arithmetic (5)
1 0 1 1 Carries
5 B A 9 Augend
+ D 0 5 8 Addend
1 2 C 0 1 Sum
9 10 A 10 Borrows
A 5 B 9 Minuend
+ 5 8 0 D Subtrahend
4 D A C Difference
N = an-1rn-1 + … + a0r0 + a-1r-1 + … + a-mr-m (1.3)
Chapter 1
9
Arithmetic (6)
B9A5 Multiplicand
x D50 Multiplier
3A0390 Partial products
96D61
9A76490 Product
Chapter 1
10
Base Conversion (1)
N = an-1rn-1 + … + a0r0 + a-1r-1 + … + a-mr-m (1.3)
N = 1×24 + 1×23 + 0×22 + 1×21 + 0×20
= (16)10 + (8)10 + 0 + (2)10 + 0
= (26)10
N = 6×82 + 2×81 + 7×80
= (384)10 + (16)10 + (7)10
= (407)10
Chapter 1
11
Base Conversion (2)
Here, bi’s represents the digits of (NI)B in base A.
= (Quotient Q1: bn-1Bn-2 + … + b1B0 ) + (Remainder R0: b0)
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.
Chapter 1
12
Base Conversion (3)
Chapter 1
13
Base Conversion (4)
Here, (NF)A is a fraction in base A and bi’s are the digits of (NF)B in base A.
= (Integer I-1: b-1) + (Fraction F-2: b-2B-1 + … + b-mB-(m-1))
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.
Chapter 1
14
Base Conversion (5)
MSD 3.832 ← 0.479 × 8
6.656 ← 0.832 × 8
5.248 ← 0.656 × 8
LSD 1.984 ← 0.248 × 8
…
MSD 0.9580 ← 0.479 × 2
1.9160 ← 0.9580 × 2
1.8320 ← 0.9160 × 2
LSD 1.6640 ← 0.8320 × 2
…
Chapter 1
15
Base Conversion (6)
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.
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.
Chapter 1
16
Base Conversion (7)
(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
Chapter 1
17
Base Conversion (8)
(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.
Chapter 1
18
Signed Number Representation
N = (san-1 ... a0.a-1 ... a-m)rsm, (1.6)
where s = 0 if N is positive and s = r -1 otherwise.
[N]r = rn - (N)r (1.7)
where n is the number of digits in (N)r.
[N]r-1 = rn - (N)r - 1
Chapter 1
19
Radix Complement Number Systems (1)
[N]2 = 26 - (101001)2 = (1000000)2 - (101001)2 = (010111)2
If we discard the carry, (N)2 + [N]2 = 0.
Hence, [N]2 can be used to represent -(N)2.
[N]2 = (1000000)2 - (1010)2 = (110110)2.
[N]10 = (100000)10 - (72092)10 = (27908)10.
Chapter 1
20
Radix Complement Number Systems (2)
Chapter 1
21
Radix Complement Number Systems (3)
N = 01100101
10011010 Complement the bits
+1 Add 1
[N]2 = (10011011)10
N = 40960
59039 Complement the bits
+1 Add 1
[N]2 = (59040)10
Chapter 1
22
Radix Complement Number Systems (4)
where .
where .
when (N)2 = (1011001)2 for n = 8:
Chapter 1
23
Radix Complement Number Systems (5)
Chapter 1
24
Radix Complement Arithmetic (1)
, where n is the number of bits.
(where B ≥ 0 and C ≥ 0.)
Chapter 1
25
Radix Complement Arithmetic (2)
Chapter 1
26
Radix Complement Arithmetic (3)
= +(0101)2 = +(5)10
Chapter 1
27
Radix Complement Arithmetic (4)
= -(0101)2 = -(5)10
= (0, 1010)2cns
= (0, 1110)2cns = +(1110)2 = +(14)10
Chapter 1
28
Radix Complement Arithmetic (5)
= -(1111)2 = -(15)10
Chapter 1
29
Radix Complement Arithmetic (6)
= (0, 1000111)2cns = +(71)10
= (1, 0111001)2cns + carry = -(0, 1000111)2cns = -(71)10
= (0, 0010101)2cns + carry = +(21)10
Chapter 1
30
Radix Complement Arithmetic (7)
Chapter 1
31
Diminished Radix Complement Number systems (1)
[N]r-1 = rn - (N)r - 1 (1.10)
[N]2-1 = 2n - (N)2 - 1 (1.11)
[N]2-1 = 28 - (01100101)2 - 1
= (100000000)2 - (01100101)2 - (00000001)2
= (10011011)2 - (00000001)2
= (10011010)2
Chapter 1
32
Diminished Radix Complement Number systems (2)
[N]2-1 = 105 - (40960)10 - 1
= (100000)10 - (40960)10 - (00001)10
= (59040)10 - (00001)10
= (59039)10
Replace each digit ai of (N)r by r - 1 - a. Note that when r = 2, this simplifies
to complementing each individual bit of (N)r .
[N]r = [N]r-1 + 1 (1.12)
Chapter 1
33
Diminished Radix Complement Arithmetic (1)
One’s complement of +(1001) = 01001
One’s complement of -(0100) = 11011
01001 + 11011 = 100100 (carry)
Add the carry to the result: correct result is 00101.
One’s complement of +(1001) = 01001
One’s complement of -(1111) = 10000
01001 + 10000 = 11001 (no carry, so this is the correct result).
Chapter 1
34
Diminished Radix Complement Arithmetic (2)
One’s complement of the operands are: 10110 and 11100
10110 + 11100 = 110010 (carry)
Correct result is 10010 + 1 = 10011.
Nine’s complements of the operands are: 075 and 978
075 + 978 = 1053 (carry)
Correct result is 053 + 1 = 054
Nine’s complements of the operands are: 021 and 924
021 + 924 = 945 (no carry, so this is the correct result).
Chapter 1
35
Computer Codes (1)
Chapter 1
36
Computer Codes (2)
Chapter 1
37
Floating Point Numbers (1)
Chapter 1
38
Floating Point Numbers (2)
where be-1 is the sign bit.
N = (SMbe-1be-2 ... b0an-1 ... a-m)r (1.17)
representing N = (1.18)
Chapter 1
39
Floating Point Numbers (3)
N = M × rE (1.19)
= (M ÷ r) × rE+1 (1.20)
= (M × r) × rE-1 (1.21)
M = +(1101.0101)2
= (0.11010101)2 × 24 (1.22)
= (0.011010101)2 × 25 (1.23)
= (0.0011010101)2 × 26 (1.24)
…
Chapter 1
40
Floating Point Numbers (4)
Chapter 1
41
Floating Point Numbers (5)
E = 00110 + 10000 = 10110
So, E = (1, 0110)excess-16
N = (0, 1, 0110, 1011011010)fp
Chapter 1
42
Characters and Other Codes (1)
0: 0000 1: 0001 2: 0010 3: 0011 4: 0100
5: 0101 6: 0110 7: 0111 8: 1000 9: 1001
Chapter 1
43
Characters and Other Codes (2)
Character Binary Code Hexadecimal Code
D 1000100 44
i 1101001 69
g 1100111 67
i 1101001 69
t 1110100 74
a 1100001 61
l 1101100 6C
Chapter 1
44
Characters and Other Codes (3)
Chapter 1
45
Error Detection Codes and Correction Codes(1)
Chapter 1
46
Error Detection Codes and Correction Codes(2)
d(I, J) ≥ dmin
2t + s + 1 ≤ dmin (1.25)
s = t = 1, dmin = 4.
Chapter 1
47
Error Detection Codes and Correction Codes(3)
Chapter 1
48
Error Detection Codes and Correction Codes(4)
Chapter 1
49
Error Detection Codes and Correction Codes(5)
Chapter 1
50
Hamming Codes (1)
an error word with single error: ce
the correct code word for the error word: c
then, d(ce,c) = 1 and d(ce, w) > 1 for all other w ∈ C (see Table 1.15)
Chapter 1
51
Hamming Codes (2)
c = (i3 i2 i1 i0 c2 c1 c0)
c2: i3, i2, i1 c1: i3, i2, i0 c0: i3, i1, i0
(1.26)
c = iG (1.27)
Chapter 1
52
Hamming Codes (3)
(1.28)
HcT = 0 (1.29)
d = c + e (1.30)
Chapter 1
53
Hamming Codes (4)
s = HdT (1.31)
= H(c + e)T
= HcT + HeT
= 0 + HeT
= HeT (1.32)
Chapter 1
54
Hamming Codes (5)
(1.33) (1.34)
Odd-weight-column code:
Chapter 1
55
Hamming Codes (6)
(1.35)
Chapter 1
56
Hamming Codes (7)
(1.36) (1.37)
Chapter 1
57