L1 - Binary Arithmatic and Complements
L1 - Binary Arithmatic and Complements
3+5 =8
1 1 0
0 0 0...... 0 1 1 1 two = 7ten
+ 0 0 0...... 0 1 1 0 two = 6ten
= 0 0 0 . . . . . . 1 (1)1 (1)0 (0)1 two = 13ten
Binary Subtraction
• Bitwise:
• 0-0= 0
• 0 - 1 = (1)1
• 1-0= 1
• 1-1= 0
• Direct Subtraction:
1000
0000 partial products
0000
1000
____________
1 0 0 1 0 0 0two = 72ten
Binary Division
• Bitwise:
• 0/0= not defined
• 0/1= 0
• 1/0= not defined
• 1/1= 1
• Direct Division:
Exercise
• 1111 + 1010 Ans: 11001
• 1101 – 1001 Ans: 0100
• 1001 – 0111 Ans: 0010
• 1011 * 1101 Ans: 10001111
• 11001 / 101 Ans: 101
Complements
• Why Complements ….?
• To simplify the subtraction operation and for logical
manipulation
• Computer does not directly subtract, it adds…
(rn - 1) - N
• Hence in computing system: there exists
• 9’s complement
• 7’s complement
• 1’s complement
• 15’s complement
(r-1)’s Complements
• Example (rn - 1) - N
For r = 10, N = 123410, n = 4 (4 digits),we have:
(rn - 1) = 10,000 -1 = 999910
The 9's complement of 123410 is then:
999910 - 123410 = 876510
r’s Complements
• Given a number ‘N’ in base ‘r’ having ‘n’ digits
• The r’s complement is given by:
rn - N for N 0 and
0 for N = 0