Page 28 - ARM 64 Bit Assembly Language
P. 28

Introduction  11

                                                                       0
                                                         14 →    3 →
                                                     4 56    4 14    4 3
                                                        40     12
                                                        16      2
                                                        16
                                                         0


                     Reading the remainders from right to left yields: 320 4 . This result can be double-checked by
                     converting it back to base ten as follows:

                                                             2
                                                                     1
                                               320 4 = 3 × 4 + 2 × 4 + 0 × 4  0
                                                     = 48 + 8 + 0
                                                     = 56 10 .
                     Since we arrived at the same number we started with, we have verified that 56 10 = 320 4 .This
                     conversion procedure works for converting any integer from base ten to any arbitrary base b.
                     Example 2 gives another example of converting from base ten to another base b.
                     Example 2. Converting from base ten to an arbitrary base.


                                    Converting 8341 10 to base seven is accomplished as follows:
                                                                                  0
                                               1191 →    170 →    24 →     3 →
                                           7 8341    7 1191    7 170    7 24   7 3
                                             7000       700      140      21
                                             1341       491       30       3
                                              700       490       28
                                              641          1       2
                                              630
                                               11
                                                 7
                                                 4
                                                       8341 10 = 33214 7


                     1.3.2.3 Bases that are powers-of-two

                     In addition to the methods above, there is a simple method for quickly converting between
                     base two, base eight, and base sixteen. These shortcuts rely on the fact that two, eight, and
                     sixteen are all powers of two. Because of this, it takes exactly four binary digits (bits) to rep-
                     resent exactly one hexadecimal digit. Likewise, it takes exactly three bits to represent an octal
   23   24   25   26   27   28   29   30   31   32   33