Академический Документы
Профессиональный Документы
Культура Документы
Section 1:
NUMBERING SYSTEMS
i.
ii.
iii.
iv.
Decimal system
Binary system
Octal system
Hexadecimal system
Decimal System
Any
101
100
100
10
MSD
.
Radix
point
10-1
10-2
0.1
0.01
LSD
4
Binary System
Any
21
20
MSB
.
Radix
point
2-1
2-2
0.5
0.25
LSB
6
Decimal
23
22
21
20
10
11
12
13
14
15
1
8
Octal System
Any
81
80
64
MSD
.
Radix
point
8-1
8-2
1/8
1/64
LSD
9
Hexadecimal System
Any
161
160
256
16
MSD
.
Radix
point
16-1
16-2
1/16
1/256
LSD
10
Decimal
Binary
Octal
Hexadecimal
0000
0001
0010
0011
0100
0101
0110
0111
1000
10
1001
11
10
1010
12
11
1011
13
12
1100
14
13
1101
15
14
1110
16
15
1111
17
F
11
Base Conversion
Convert a number from one number
system to another system
Integral Part
Fraction Part
12
i. Binary-to-Decimal Conversion
Summing the weight of all positions that
contain a 1
100112
= 2 4 + 21 + 2 0
= 16 + 2 + 1
= 1910
101110012
= 2 7 + 25 + 24 + 23 + 20
= 128 + 32 +16 + 8 + 1 = 18510
13
10.37510
= 8 + 2 + 0.25 + 0.125
= 23 + 21 + 2-2 + 2-3 = 1010.0112
14
Integral Part
2|10
2| 5 R = 0
2| 2 R = 1
2| 1 R = 0
0 R=1
Fraction Part
0.375 x 2 = 0.75
0.75 x 2 = 1.5
0.5 x 2 = 1.0
15
Binary
000
001
010
011
100
101
110
111
5638
= 101 110 0112
16
1101101110.0010101102
1.
2.
3.
4.
17
v. Decimal-to-Octal Conversion
Repeated Division and Multiplication
Method
170.3812510
= 252.303148
Integral Part
8|170
8| 21 R = 2
8| 2 R = 5
0 R=2
Fraction Part
0.38125 x 8 = 3.05
0.05 x 8 = 0.4
0.4 x 8 = 3.2
0.2 x 8 = 1.6
0.6 x 8 = 4.8
18
50.078
= 5x81 + 7x8-2
= 40 + 0.109375
= 40.10937510
19
vii. Hexadecimal-to-Decimal
Conversion
Summing the weight of all positions that
contain a nonzero digit
50EF.0A16
= 5x163 + Ex161 + Fx160 + Ax16-2
= 5x163 + 14x161 + 15x160 + 10x16-2
= 20480 + 224 + 15 + 0.039
= 20719.03910
20
viii. Decimal-to-Hexadecimal
Conversion
Repeated Division and Multiplication
Method
400.53410
= 190.88B16
Integral Part
16|400
16| 25 R = 0
16| 1 R = 9
0 R=1
Fraction Part
0.534 x 16 = 8.544
0.544 x 16 = 8.704
0.704 x 16 = 11.264
21
ix. Hexadecimal-to-Binary
Conversion
Also
Binary
0000
0001
0010
0011
0100
0101
0110
0111
Hexad
ecimal
Binary
1000
1001
1010
1011
1100
1101
1110
1111
56316
= 0101 0110 00112
22
x. Binary-to-Hexadecimal
Conversion
11011011102
= 0011 0110 11102 = 36E16
0.0010101112
= 0.0010 1011 10002 = 0.2B816
1101101110.0010101112
1.
2.
3.
4.
23
xi. Hexadecimal-to-Octal
Conversion
Method 1 (Faster): Convert to binary and
followed by octal
Method 2 (Slower): Convert to decimal
and followed by octal
12EF16
= 0001 0010 1110 11112
= 113578
24
Exercise
Convert (34567.12)8 to decimal
Convert (1234.687)10 to binary
Convert (F80B)16 to octal
25
Section 2:
BINARY ARITHMETIC
26
Binary Arithmetic
i.
Binary Addition
Binary Subtraction
Binary Multiplication
Binary Division
ii.
iii.
iv.
27
Binary Addition
Addition
table
0+0=0
0+1=1
1+0=1
1 + 1 = 0 carry 1
11012
+ 10112
-------110002
1310
+ 1110
------2410
Checking/Not steps
augend
addend
sum
28
Binary Subtraction
Subtraction table
0-0=0
0 - 1 = 1 borrow 1
1-0=1
1-1=0
111012
100112
-------010102
2910
- 1910
------1010
Checking/Not steps
minuend
subtrahend
difference
29
Binary Multiplication
Multiplication table
0x0=0
0x1=0
1x0=0
1x1=1
30
Binary Multiplication
Checking/Not steps
1101
x 1011
-----1101
1101
0000
1101
-----------10001111
1310
1110
-----1310
1310
------14310
multiplicand
multiplier
partial products
final product
31
Binary Division
Checking/Not steps
dividend
remainder
32
Exercise
Perform (56)10+(95)10 in binary
Perform (1101)2 X (1011)2 in binary
Perform (1001)2 (0111)2 in binary
Perform (1100)2 / (101)2 in binary
33
Example: 910
MSB: most significant bit
(left most bit)
4-bit representation:
1001 2 (bit position 3 to 0)
5-bit representation:
0 1001 2 (bit position 4 to 0)
6-bit representation:
00 1001 2 (bit position 5 to 0)
7-bit representation: 000 1001 2 (bit position 6 to 0)
8-bit representation: 0000 1001 2 (bit position 7 to 0)
34
36
2510 = 000110012
-2510 = 1111 11112 000110012
= 111001102
37
2510 = 000110012
-2510 = 111001102
38
2510 = 000110012
-2510 = 1000000002 000110012
= 111001112
39
2510 = 000110012
-2510 = 111001112
Another
Remark
To
To
Example
Find the negative integer represented in
1s complement as 111011002
11101100
1s complement:
00010011 = 1910
42
Example
Find the negative integer represented in
2s complement as 111011002
11101100
2s complement:
00010100 = 2010
43
Exercise
Express number -16324010 in 2s
complement using 20 bits.
44
A B = A + (-B)
Any carry from sign position is ignored such
that an addition of two n-bit numbers will result
an n-bit output
An
overflow happens if the correct
representation of the sum (including sign)
requires more than n bits, i.e.,
Addition of two positive numbers gives a negative
output
Addition of two negative numbers gives a negative
45
output
2s Complement: Addition
CASE 1: Addition of 2 positive numbers, sum < 2n 1
46
2s Complement: Addition
CASE 3: Addition of positive and negative numbers
(negative number has greater magnitude).
+5
0101
-6
1010
-----------------1
1111 (correct answer)
2s Complement: Addition
CASE 5: Addition of two negative numbers,
|sum| 2n 1.
-3
1101
-4
1100
----------------- 7 (1)1001 correct answer when last carry is
ignored (this is not an overflow)
48
1s Complement: Addition
CASE 1: Addition of 2 positive numbers, sum < 2n 1.
49
51
Exercise
Add
a)
b)
c)
d)
25 + 15
25 + (-15)
-25 + 15
-25 + (-15)
52
2510 = 0110012
-2510 = 1001112
1510 = 0011112
-1510 = 1100012
53
Exercise
Add
a)
b)
c)
d)
25 + 15
25 + (-15)
-25 + 15
-25 + (-15)
54
2510 = 0110012
-2510 = 1001102
1510 = 0011112
-1510 = 1100002
55
Section 3:
BINARY CODES
56
Binary Codes
All
57
58
Decimal Digit
BCD/8421 Code
0000
0001
0010
0011
0100
0101
0110
0111
1000
1001
9 3 7. 2 5
BCD
Decimal
0
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
Binary
0000
0001
0010
0011
0100
0101
0110
0111
1000
1001
1010
1011
1100
1101
1110
1111
BCD
0000
0001
0010
0011
0100
0101
0110
0111
1000
1001
0001 0000
0001 0001
0001 0010
0001 0011
0001 0100
0001 0101
60
BCD Addition
Only 0000 to 1001 are valid
Any addition output larger than 1001,
add 0110 to correct it
Example:
4
+5
--9
0100
+ 0101
------1001
No Correction Needed
61
0101
+ 1001
------1110 Invalid Code
+ 0110 Correction
Add 6
------1 0100= 14
8
+9
--17
1000
+ 1001
------1 0001 Invalid Code
+ 0110 Correction
Add 6
--------1 0111 = 17
62
184
+ 576
------
1
1
Carry
0001 1000 0100
+ 0101 0111 0110
----------------------0111 10000 1010 Invalid
+
0110 0110 Add 6
----------------------0111 0110 0000
= 760
63
Exercise
Add the BCD numbers: 0001 0110 + 0001 0101
64
Gray Code
0000
0000
0001
0001
0010
0011
0011
0010
0100
0110
0101
0111
0110
0101
0111
0100
1000
1100
1001
1101
65
Gray Code
An
unweighted code
Two successive codes
differ in 1 bit only
Applicable to prevent
more than one bit
changes at a time
The only change
0010
0110
Decimal
Binary
Gray code
0
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
0000
0001
0010
0011
0100
0101
0110
0111
1000
1001
1010
1011
1100
1101
1110
1111
0000
0001
0011
0010
0110
0111
0101
0100
1100
1101
1111
1110
1010
1011
1001
1000
66
Example: 10111012 = ?
1 0 1 1 1 0 1
Binary
1 1 1 0 0 1 1
Gray code
67
Example: 11010110Gray = ?
1 1 0 1 0 1 1 0
Gray Code
1 0 0 1 1 0 1 1
Binary
68
Data = 1000001
Even parity
01000001
Odd parity
11000001
69