1's Complement and 2's Complement

1's Complement and 2's Complement

1's Complement:

To find 1's complement we have to just replace 0 by 1 and 1 by 0.
e.g:
1101010110
1's complement of above number is: 0010101001

10101
1's complement of above number is: 01010

11101
1's complement of above number is: 00010

2's Complement:

2's Complement of any number is 1's complement + 1
e.g:
1101010110
1's complement of above number is: 0010101001  
2's complement = 1's complement +1
Thus,  2's complement = 0010101001 + 1
Thus,  2's complement = 0010101010

e.g:
10101
1's complement of above number is: 01010
2's complement = 1's complement +1
Thus,  2's complement = 01010 + 1
Thus,  2's complement = 01011

e.g:
11101
1's complement of above number is: 00010
2's complement = 1's complement +1
Thus,  2's complement = 00010 + 1
Thus,  2's complement = 00011

Note:
Processor does subtraction by 2's complement method.

No comments:

Post a Comment