Page 28 - computer science (868) class 11
P. 28

Example 3: (10011.11)  + (1111)  + (10.1) 2
                                           2
                                  2
              Answer:                              +1 +1 +1 +1+1 +1 +1
                                                        1   0    0   1   1 . 1    1
                                                            1    1   1   1
                                                    +                1   0 . 1

              (100101.01) 2                         1   0   0    1   0   1 . 0    1

              1.3.2 Binary Subtraction
              Binary subtraction can be done by three different methods which are as follows:
              •  Borrow method
              •  1’s complement method
              •  2’s complement method

              Binary Subtraction by Borrow Method
              The following cases may arise:

                                  Bits         Result       Borrow
                                  0 – 0          0             0
                                  0 – 1          1             1       borrowed from adjacent left digits
                                  1 – 0          1             0
                                  1 – 1          0             0
              Example 1: Subtract 101 from 1001. Both of these numbers are binary numbers.
              Answer:                                       -1
                                                             1    0     0     1
                                               Borrow
                                                         -        1     0     1

                                                                  1     0     0
              (100) 2
              Example 2: Subtract (11)  from (10000) .
                                    2
                                                 2
              Answer:                                     -1  -1    -1   -1
                                                        1     0     0     0    0
                                            Borrow
                                                                          1    1
              (1101) 2                                        1     1     0    1


              Binary Subtraction by 1’s Complement Method
              In 1’s complement method, the complement value of a binary number is obtained by replacing 0 with 1 and 1 with 0.
              For example, 1’s complement of 10011 is 01100. Two cases may arise:

              Case 1: When minuend is greater than subtrahend
              The steps to be followed are:
              1.  Make the number of digits of subtrahend equal to minuend by adding leading 0s in the integer part and trailing 0s
                 in the decimal part if required.
              2.  Find the 1’s complement of the subtrahend by changing 0 with 1 and 1 with 0.
              3.  Add this result to the minuend.
              4.  Add the leftmost carry (MSB) with the rightmost digit (LSB) to get the final result.




                2626  Touchpad Computer Science-XI
   23   24   25   26   27   28   29   30   31   32   33