1's and 2's Complement


What is 1’s complement?

1’s complement of any binary number is obtained by subtracting each bit of given number by 1. We also can get the 1’s complement of any binary number by interchanging the 1 to 0 and 0 to 1 of the given number. Example:
Find the 1’s complement of 100110.
Solution:

1’s complement of 100110  = 1 1 1 1 1 1 – 1 0 0 1 1 0              
                                                = 0 1 1 0 0 1


What is 2’s complement?
2’s complement of any binary number is the sum of it’s 1’s complement and 1. OR we also can get the 2’s complement of any binary number is interchanging 0 to 1 and 1 to 0 only after the occurrence of 1st 1’s in the number from LSB. Example:
Find the 2’s complement of 100110.

Solution:

2’s complement of 100110  = 1’s complement of 100110 +1
(1 1 1 1 1 1 – 1 0 0 1 1 0) + 1                   
                                                = 0 1 1 0 1 0

            

Subtraction Using 1’s and 2’s complement
i)                    10101-101

Solution:
Subtraction using 1’s Complement
Making equal number of bits in both number
   10101
-  00101 (by inserting 00 to the left side of subtrahend)

1’s complement of 00101 (Subtrahend)
=11111-00101
=11010

Add both number (minuend and the 1’s complement of subtrahend)
   1 0 1 0 1
+ 1 1 0 1 0
1 0 1 0 1 1

Hence, there is carry bit, so answer is positive and sum of carry bit and remaining part.
Therefore, final result is 1000.


Subtraction using 2’s Complement
i)                    10101-101
Making equal number of bits in both number
   10101
-  00101 (by inserting 00 to the left side of subtrahend)

2’s complement of 00101 (Subtrahend)
= 1’s complement of 00101 + 1
= (11111-00101) + 1
= 11011

Add both number (minuend and the 1’s complement of subtrahend)
   1 0 1 0 1
+ 1 1 0 1 1
1 1 0 0 0 0
Hence, there is carry bit, so answer is positive and remaining part ignoring carry bit.
Therefore, final result is 1000.

Post a Comment

0 Comments