1’s Complement : 1’s complement of binary is obtained by
subtracting each bit by 1 . We can get 1’s complement by simply replacing 1 by
0 and 0 by 1. 1’s Complement of 1011 is 0100.
2’s Complement:2’s Complement of binary number is obtained
by adding binary 1 to the 1’s complement of the number.
Example of 2’s complement of 1101101 = ?
1’s complement = 0010010
+1
2’s complement = 10011
Subtraction of binary number using 1’s complement:
Steps:-
i.
Make both the numbers of having the same bit.
ii.
Determine the 1’s complement of the number to be
subtracted.
iii.
Add the first complement to the given number
from which we subtract.
iv.
If there exist any additional bits(carry) in the
result after addition, remove and add to the result else Determine the 1’s
complement of the result and prefix by negative sign to get the final result.
For example : Subtract 1110000
from 1100000 1’s complement of 110000 = 0001111 . Adding it with minuend =
0001111+1100000 = 1101111
Since, there exist no any
additional bit 1’s complement of 1101111 is 0010000.
Hence, Difference will be –
0010000.
Subtraction using 2’s complement.
a)
Make both the number having same number of bit.
b)
Determine the 2’s complement of the number to be
subtracted.
c)
Add the 2’s complement to the given number from
which we subtract(minuend).
d)
If there exist any additional bit(carry) in the
result after addition neglect the carry and the remaining bits is the required
answer else,Determine the 2’s complement of the result and prefix by negative sign
to get the final result.
For example : 111000-110000
2’s complement of 111000 =
0001111+1=0010000
Adding it with minuend = 0010000+1100000 =
1110000
2’s Complement of 1110000=0001111+1 =
-001000
No comments:
Post a Comment