Page 32 - ComputerScience_Class_11
P. 32

Binary Subtraction by 2’s Complement Method
              2’s  complement  is  obtained  by  adding  1  to  1’s  complement.  For  example,  1’s  complement  of  10011  is  01100.
              2’s complement is 01100 + 1, i.e., 01101. Two cases may arise:


              Case 1: When minuend is greater than subtrahend
              The steps to be followed are:
              1.  Make the number of digits in the subtrahend equal to minuend by adding leading 0s in the integer part of the
                 subtrahend and trailing 0s in the fractional part if required.
              2.  Find the 2’s complement of the subtrahend by adding 1 to its 1’s complement.
              3.  Add this answer to the minuend.
              4.  Exclude leftmost carry (MSB) to get the answer.
              Example 1: (1110101)  - (11001)  (using 2’s complement method).       +1   +1           +1  +1   +1
                                           2
                                  2
              Answer: 1110101 has 7 bits and 11001 has 5 bits.                            1   1   1   0    1    0   1
              Adding prefix 0, we get 0011001                                        +    1   1   0   0    1    1   1
              1’s complement of 0011001 is 1100110                                   1    1   0   1   1    1    0   0
              2’s complement is 1100110 + 1 = 1100111                               Discarding MSB 1, we get 1011100
              Adding 1110101 and 1100111, we get 11011100

              (1011100) 2
              Example 2: (1001.01)  - (111.1)  (using 2’s complement method).
                                          2
                                 2
              Answer: 1001 has 4 bits and .01 has 2 bits, whereas, 111 has 3 bits and .1 has 1 bit. So, adding 0’s, we get 0111.10
              1’s complement of 0111.10 is 1000.01                                         +1   1   0  0   1 . 0    1

              2’s complement = 1000.10                                                     +    1   0  0   0 . 1    0
              Adding 1001.01 and 1000.10, we get 10001.11                                  1    0   0  0   1 . 1    1
              (1.11) 2                                                                    Discarding MSB 1, we get 1.11


              Case 2: When minuend is smaller than subtrahend
              The steps to be followed are:
              1.  Make the number of digits in the subtrahend equal to minuend by adding trailing 0’s in the fractional part of the
                 subtrahend if required.

              2.  Find the 2’s complement of the subtrahend by adding 1 to its 1’s complement.
              3.  Add this answer to the minuend.
              4.  Find 2’s complement of the sum and add 1 as the sign bit in MSB or the -ve sign as answer.
              Example 1: (10110)  - (1100010)  using 2’s complement method.                +1   +1   +1   +1
                                2
                                           2
              Answer: 1’s complement of 1100010 is 0011101                                       1    0    1   1   0
                                                                                   +   0    0    1    1    1   1   0
              2’s complement = 0011110
                                                                                       0    1    1    0    1   0   0
              Adding 10110 and 0011110, we get 0110100                            1’s complement of 0110100 is  1001011
              (-1001100) 2                                                        2’s complement of 1001011 is  1001100










                   30  Touchpad Computer Science (Ver. 3.0)-XI
   27   28   29   30   31   32   33   34   35   36   37