Page 33 - ARM 64 Bit Assembly Language
P. 33

16 Chapter 1

                                   Nine’s Complement
                                        Table
                                        0   9
                                        1   8
                                        2   7                       One’s Complement
                                        3   6                            Table
                                        4   5                            0   1
                                        5   4                            1   0
                                        6   3
                                        7   2
                                        8   1
                                        9   0
                                  Figure 1.5: Complement tables for base ten and base two.



                  the complement is obtained in bases ten and two respectively. Example 6 and Example 7 show
                  additional conversions between binary and decimal.


                  Example 4. The nine’s and ten’s complements.

                   The nine’s complement of the base ten number 593 is found by finding the digit ‘5’ in the
                   complement table, and replacing it with its complement, which is the digit ‘4.’ The digit ‘9’
                   is replaced with ‘0,’ and ‘3’ is replaced with ‘6.’ Therefore the nine’s complement of 593 10
                   is 406. Likewise, the nine’s complement of 1000 10 is 8999 10 and the nine’s complement of
                   0999 10 is 9000 10 .

                   The ten’s complement is the nine’s complement plus one, so the ten’s complement of 726 10
                   is 273 10 + 1 = 274 10 .



                  Example 5. The one’s and two’s complements.

                   The one’s complement of a binary number is found in the same way as the nine’s com-
                   plement of a decimal number, but using the one’s complement table instead of the nine’s
                   complement table. The one’s complement of 01001101 2 is 10110010 2 and the one’s com-
                   plement of 0000000010110110 is 1111111101001001 2 . Note that the one’s complement of
                   a base two number is equivalent to the bit-wise logical “not” (Boolean complement) opera-
                   tor. This operator is very easy to implement in digital hardware.


                   The two’s complement is the one’s complement plus one. The two’s complement of
                   1010100 2 is 0101011 2 + 1 = 0101100 2 .
   28   29   30   31   32   33   34   35   36   37   38