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

Diminished Radix Complement
                  Given a number N in base r having n digits, the (r - 1)’s complement of N is defined as (r - 1) - N. For decimal numbers, r = 10 and
                  r - 1 = 9, so the ninth complement of N is (10n - 1) - N. Now, 10n represents a number that consists of a single 1 followed by n
                  0s. 10n - 1 is a number represented by n 9’s.



                 Example 1: (1110101)  - (11001)  (using 1’s complement method).
                                    2         2                                            +1 +1           +1
                 Answer: Minuend 1110101 has 7 bits and subtrahend 11001 has 5 bits.            1   1   1  0   1   0  1
                 Adding preceding 0s, we get 0011001                                        +   1   1   0  0   1   1  0
                 1’s complement of 0011001 is 1100110                                       1   1   0   1  1   0   1  1
                 Adding 1110101 and 1100110, we get                                                                   1

                 (1011100) 2                                                                    1   0   1  1   1 0    0
                 Example 2:  (1001.01)  - (111.1)  (using 1’s complement method).            +1                   +1
                                             2
                                    2
                 Answer: Integer part of 1001.01 has 4 bits and fractional part 2 bits           1   0   0   1 . 0    1
                 Prefix 0 is added to 111 and suffix 0 is added to fractional .1 to get 0111.10  +  1  0  0  0 . 0    1
                 1’s complement of 0111.10 is 1000.01                                        1   0   0   0   1 . 1    0
                 Adding 1001.01 and 1000.01, we get                                                                   1
                 (1.11)                                                                                      1 . 1    1
                      2
                 Case 2: When minuend is smaller than subtrahend
                 The steps to be followed are:
                 1.  Make the number of digits in the fractional part of subtrahend equal to minuend by adding trailing 0s if required.
                 2.  Find the 1’s complement of the subtrahend.
                 3.  Add this answer to the minuend.
                 4.  Find 1’s complement of sum and write 1 as sign bit in MSB or -ve sign as the answer.

                 Example 1: (10110)  - (1100010)  (using 1’s complement method).        +1    +1    +1
                                            2
                                 2
                 Answer: 1’s complement of 1100010 is 0011101                                 1     0     1     1     0
                                                                             +    0     0     1     1     1     0     1
                 Adding 10110 and 0011101, we get
                                                                                  0     1     1     0     0     1     1
                 (-1001100) 2                                               1’s complement of 0110011 is 1001100

                 Example 2: (111.1)  - (1001.01)  (using 1’s complement method).            +1   +1   +1   +1
                                 2          2
                 Answer: 1’s complement of 1001.01 is 0110.10                                    1    1    1   . 1    0

                 Adding 111.10 and 0110.10, we get                                     +    0    1    1    0   . 1    0
                 (-1.11)                                                                    1    1    1    0   . 0    0
                       2
                                                                                       1’s complement of 1110.00 is 0001.11
                 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 of 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.



                                                                                                                        27
                                                                                                            Numbers     27
   24   25   26   27   28   29   30   31   32   33   34