Translate

Thursday 7 June 2012

Signed Binary Numbers: Two's Complement Representation

If 1 is added to 1's complement of a binary number, the resulting number is known as the two's complement of the binary number. For example, 2's complement of 0101 is 1011. Since 0101 represents (+5)10, therefore, 1011 represents (-5)10 in 2's complement representation. In this representation also, if the MSB is 0 the number is positive, whereas if the MSB is 1 the number is negative.

Exercise
Find the 2's complement of the numbers
  1. 01001110
Solution:

    0 1 0 0 1 1 1 0................Number   

    1 0 1 1 0 0 0 1................1's complement          

                         1................Add 1  
    1 0 1 1 0 0 1 0

From the above example, we observe the following:
  1. If the LSB of the number is 1, its 2's complement is obtained by changing each 0 to 1 and 1 to 0 except the least-significant bit.
  2. If the LSB of the number is 0, its 2's complement is obtained by scanning the number from LSB to MSB bit by bit and retaining the bits as they are up to and including the occurrence of the first 1 and complement all other bits. 

No comments:

Post a Comment