Number System and Codes
Number System and Codes
TM
5 6 7 8 . 9
3 2 1 0 –1
In power of 10 5 10 6 10 7 10 8 10 9 10
MSD LSD
1101.101
®
TM
MSB LSB
Binary
point
3 2 1 0 –1 –2 –3
2 2 2 2 2 2 2
N = 1 1 0 1 . 1 0 1
3 2 1 0 –1 –2 –3
12 12 02 12 12 02 12
3 2 1 0 –1 –2 –3
N = 12 + 12 + 02 + 12 + 12 + 02 + 12 = (13.625)10
2 1 0 –1 –2
8 8 8 8 8
N = 4 7 5 . 2 5
2 1 0 –1 –2
48 78 58 28 58
2 1 0 –1 –2
N = 48 + 78 + 58 + 28 +58 = (317.328125)10
®
TM
b31 b30 b29 b28 b27 b26 b25 b24 b23 b22 b21 b20 b19 b18 b17 b16 b15 b14 b13 b12 b11 b10 b9 b8 b7 b 6 b 5 b 4 b3 b2 b 1 b 0 Bit
Word 1 Word 0
Double word
®
TM
®
TM
(10101101.0111) 2 (255.34) 8
1 2 5 6 2 Octal (Base 8)
Step 1. 0 0 1 0 1 0 1 0 1 1 1 0 0 1 0
Step 2. 1 0 1 0 1 0 1 1 1 0 0 1
(125.62) 8 (1010101.11001) 2
®
TM
Step 1. 0 0 1 1 0 1 1 0 1 1 1 0 1 0 0 1 1 0 1 0
Step 2. 3 6 E 9 A
(
1101101110.1001101) 2 (36E.9A) 16
(549. B4)16
5 4 9 B 4
Step 1. 0 1 0 1 0 1 0 0 1 0 0 1 1 0 1 1 0 1 0 0
Step 2. 0 1 0 1 0 1 0 0 1 0 0 1 1 0 1 1 0 1
Trailing zeros
(615.25)8
®
TM
BC66. AF)16
A n 1 r n 1 A n 2 r n 2 ... A 1 r 1 A 0 r 0 A 1 r 1 A 2 r 2 ... C m r m
®
TM
(193) x
(193) x
(193) x 1 x2 + 9 x + 3 x0
x2 + 9x + 3
Q R Q R
LSD
12 2 = 6 0 2 12 0 LSD
6 2 = 3 0 2 6 0
3 2 = 1 1 2 3 1
1 2 1 1 MSD
1 2 = 0
0
MSD 1 1 0 0
(12)10 = (1 1 0 0) 2
®
TM
0
0.25 2 0 . 50
1 LSD
0.50 2 1 . 00
Q R Q R
LSD
658 8 = 82 2 8 658 2 LSD
82 8 = 10 2 8 82 2
10 8 = 1 2 8 10 2
1 8 1 1 MSD
1 8 = 0
0
MSD 1 2 2 2
(658)10 = (1222) 8
4
0.6 × 8 = 4 . 8
6 LSD
0.8 × 8 = 6 . 4
®
TM
336 16 = 21 0 16 336 0
21 16 = 1 5 16 21 5
1 16 1 1 MSD
1 16 = 0
0
MSD 1 5 0 A
(5386)10 = (150A) 16
8
0.52 × 16 = 8 . 32
5 LSD
0.32 × 16 = 5 . 12
®
TM
b 3 2 b2 4
1 b2 0 b1 0 b0 b2
0 0 1 0 1 1 0 1 . 1 1 0 1 Binary number
2 D . D Hex number
(101101.1101) 2 (45.8125) 10
(65.342)8 (1144 .3042)7
(153.513)10
(231.4065)8
(11010100)2
®
TM
NOT operation
(11000100)2
1 1 0 0 0 1 0 0 Number
1 1 Carry
0 0 1 1 1 0 1 1 1's complement of number
+ 1 Add 1
0 0 1 1 1 1 0 0 2's complement of number
+ 200 = 0 1 1 0 0 1 0 0 0
B7 B6 B5 B4 B3 B2 B1 B0
Sign Magnitude
®
TM
Sign Magnitude
Cout
(11001100)2 (11011010)2
1 1 1 1 Carry
1 1 0 0 1 1 0 0 Number 1
+ 1 1 0 1 1 0 1 0 Number 2
1 1 0 1 0 0 1 1 0 Result (S)
(28)10 (15)10
®
TM
1 1 1 Carry (28)10
0 0 1 1 1 0 0 Binary equivalent of (28)10 + (15)
Sign Extension + 10
0 0 0 1 1 1 1 Binary equivalent of (15)10
Sign (43)10
0 1 0 1 0 1 1 Result : Binary equivalent of (43)10
(11101100)2 (00110010)2
10
0 0 10 0 10
1 1 1 0 1 1 0 0 Number 1
0 0 1 1 0 0 1 0 Number 2
1 0 1 1 1 0 1 0 Result
(11010) 2 (10000) 2
®
TM
(15)10 (28)10
(15) 10 (01111) 2
(28) 10 (11100) 2
1 1 1 0 0 Binary equivalent of (28)10
1 1 1 1 Carry
(15)10
0 1 1 1 1 Binary equivalent of (15)10 +
+ (–28)10
0 0 0 1 1 1's complement of (28)10
1 0 0 1 0 Result = Binary equivalent of (–13)10 (–13)10
®
TM
1 1 1 Carry
0 1 0 1 0 1 0
+ 0 1 1 1 1 0 0
1 1 0 0 1 1 0
1 1 0 0 1 1 0 Number
0 0 1 1 0 0 1 1's complement
+ 0 0 0 0 0 0 1 2's complement
0 0 1 1 0 1 0 = 2610
(101.11)2 (110.01)2
®
TM
1 0 0 1 0 0
1 1 0 1 1 0 1 1 0 1 1
– 1 1 0
0 0 0 1 1 0
– 1 1 0
0 0 0 1 1
®
TM
Decimal number 9 3 9 3
®
TM
®
TM
1 1 Carry
®
TM
6 0 1 1 0 BCD for 6
+
8 1 0 0 0 BCD for 8
14 1 1 Carry
1 1 1 0 Invalid BCD number
+ 0 1 1 0 Add 6 for correction
Carry 1 0 1 0 0
0 0 0 1 0 1 0 0 BCD for 14
1 4 Decimal
8 1 Carry
+
9 1 0 0 0 BCD for 8
17 1 0 0 1 BCD for 9
1 0 0 0 1
Carry Incorrect BCD result
0 0 0 1 0 0 0 1
1 1
8 1 0 0 0 BCD for 8
+9 1 0 0 1 BCD for 9
17 0 0 0 1 0 0 0 1 Incorrect BCD result
+
0 0 0 0 0 1 1 0 Add 6 for correction
0 0 0 1 0 1 1 1 BCD for 17
1 7
(137)10
®
TM
a) 24 0 0 1 0 0 1 0 0
+ 18 + 0 0 0 1 1 0 0 0
42 1 1 1 Carry
0 0 1 1 1 1 0 0 Invalid BCD number 1 1 0 0 > 9
+ 0 1 1 0 Add 6 for correction
0 0 1 1 1 0 0 1 0
+ 1 Propagate carry to next higher digit
0 1 0 0 0 0 1 0 BCD for 42
4 2
1 1
b) 48 0 1 0 0 1 0 0 0
+ 58 + 0 1 0 1 1 0 0 0
106 1 Carry
1 0 0 1 1 0 0 0 0 Propagate carry and
Add 6 for correction
+ 1 0 1 1 0 1 0 1 0 > 9 so add 6 for correction
1 1 1 Carry
1 0 1 0 0 1 1 0
+
0 1 1 0
1 0 0 0 0 0 1 1 0 Corrected sum
1 0 6
(3497)BCD
9 9 9 9
–
3 4 9 7 (3497)BCD
6 5 0 2 9’s complement of (3497)BCD
®
TM
1 1 1 Carry
0 1 0 0 0 1 1 0 (46) BCD
+ 0 1 1 1 0 1 1 1 (77) 9's complement of (22) BCD
1 0 1 1 1 1 0 1
1 1 1 1 1 1
1 0 1 1 1 1 0 1 Invalid BCD numbers
+ 0 1 1 0 0 1 1 0 Add 6 in each digit
1 0 0 1 0 0 0 1 1
+ 1 Add end around carry
0 0 1 0 0 1 0 0
2 4 Result
Carry
0 0 1 0 0 1 0 0 (24) BCD
+ 0 1 0 0 0 0 1 1 9's complement of (56) BCD
Carry 0 0 1 1 0 0 1 1 1 (67) BCD
( 32) 10
(3497)BCD
®
TM
(46)10 (22)10
1 Carry
46 0 1 0 0 0 1 1 0 (46)BCD
+ +
–22 0 1 1 1 1 0 0 0 (78)10's complement of (22)BCD
24 1 0 1 1 1 1 1 0
1 1 1 1 1 1 Carry
1 0 1 1 1 1 1 0 Invalid BCD numbers
+ 0 1 1 0 0 1 1 0 Add 6 in each digit
Discard carry 1 0 0 1 0 0 1 0 0
2 4 Result
1 Carry
24 0 0 1 0 0 1 0 0 (24)BCD
– 56 + 0 1 0 0 0 1 0 0 10's complement of (56)BCD
– 32 Carry 0 0 1 1 0 1 0 0 0 (68)BCD
1 1 1 Carry
0 0 0 1 1 0 0 0 (18) BCD
+ 0 1 1 1 0 1 1 0 (76) BCD
1 0 0 0 1 1 1 0
+ 0 1 1 0 1110 > 9 so add 6
1 0 0 0 1 0 1 0 0
+ 0 0 0 1
1 0 0 1 0 1 0 0 Final carry is 0, so result
is negative and it is in 10's
complement form
0 0 0 0 0 1 1 0
®
TM
0 0 0 0
0
1 1 1 1 9
0 0 0 1
1
1 1 1 0 8
0 0 1 0
2
1 1 0 1 7
0 0 1 1
3
1 1 0 0 6
0 1 0 0
4
1 0 1 1 5
®
TM
7 4 2 1
®
TM
40310 = 0 1 1 1 0 0 1 1 0 1 1 0 Complement of
each other
9’s complement of 40310 = 1 0 0 0 1 1 0 0 1 0 0 1
a) 8 + 6 1 1 1 Carry b) 1 + 2 Carry
1
1 0 1 1 Excess-3 for 8 0 1 0 0 Excess-3 for 1
+ 1 0 0 1 Excess-3 for 6 + 0 1 0 1 Excess-3 for 2
1 0 1 0 0 Carry = 1, hence Carry 0 Carry = 0, hence
1 0 0 1
0 0 1 1 0 0 1 1 Add 3 – 0 0 1 1 Sub 3
0 1 0 0 0 1 1 1 Excess-3 for 14 0 1 1 0 Excess-3 for 3
1 4 Result in decimal 3 Result in decimal
( 0 0 1 1) 2
1 1 1 1
1 0 1 1 Excess-3 for 8
+
0 1 1 1 Complement of 5 in excess-3
1 0 0 0 Excess-3 for 5
Carry 1 0 0 1 0 +
0 1 0 0 Complement of 8 in excess-3
0 0 1 1 Add 3 Carry 0 1 1 0 0
0 1 0 1 – 0 0 1 1 Subtract 3
1 Add end-around carry
1 0 0 1 Excess-3 for – 3
0 1 1 0 Excess-3 for 3
®
TM
1 1 Carry
a) 16 0 1 0 0 1 0 0 1 Excess-3 for 16
+
+ 29 0 1 0 1 1 1 0 0 Excess-3 for 29
45 0 1 0 0 1 1 0 1 0 1
1 Propagate carry
1 1 1 Carry
0 1 0 1 0 0 1 0 1
+ 0 0 1 1 Add 3 to correct 0 1 0 1
1 0 1 0 1 0 0 0
–
0 0 1 1 Subtract 3 to correct 1 0 1 0
0 1 1 1 1 0 0 0 Excess-3 for 45
4 5 Result
1 1 1 1 Carry
b) 21 0 1 0 1 0 1 0 0 Excess-3 for 21
– 12 1 0 1 1 1 0 1 0 Complement of 12 in excess-3
9 Carry 1 0 0 0 0 0 1 1 1 0
+ 0 0 1 1 – 0 0 1 1 Add 3 and subtract 3
0 0 1 1 1 0 1 1
+ 1 Add end-around carry
0 0 1 1 1 1 0 0
0 9 Excess-3 for 9
®
TM
1 0001
2 0011
3 0010
4 0110
5 0111
6 0101
7 0100
8 1100
9 1101
10 1111
11 1110
12 1010
13 1011
14 1001
2n 1
1
1000
2n 1
®
TM
Shaft
Brush
(a) Shaft position encoder
Rotating disk
101
1
0
111
10
11
0
1
10
11
01 01
1 000 0 000
Indicates 1
010
011
001
001
Indicates 0
MSB LSB(G0)
Gray code : 1 0 1 0 1 1
+ + + + +
Binary code : 1 1 0 0 1 0
(B0)
(1 0 1 0 1 1) gray (1 1 0 0 1 0) 2
®
TM
Bn 1 Bn G n 1 B1 B2 G 1
Bn 2 Bn 1 G n 2 B0 B1 G 0
MSB LSB(B0)
Binary code : 1 + 0 + 1 + 1 + 1 + 0 + 1 + 1
Gray code : 1 1 1 0 0 1 1 0
(G0)
(1 0 1 1 1 0 1 1) 2 (1 1 1 0 0 1 1 0) gray
G n (MSB) B n (MSB) G2 B 3 B2
Gn 1 Bn Bn 1 G1 B2 B1
Gn 2 Bn 1 Bn 2 G0 B1 B0
Binary code : 1 + 0 + 1 + 1 + 1 + 0 + 0 + 0 + 1 + 0
Gray code : 1 1 1 0 0 1 0 0 1 1
®
TM
®
TM