Page 264 - ARM 64 Bit Assembly Language
P. 264

Non-integral mathematics 253


                               2. 25        00010. 010             11. 125          01011. 001
                            + 1. 50 = + 00001. 100                − 5. 625 = + 11010. 011
                               3. 75        00011. 110               5. 500         00101. 100



                                               −12. 375          10011. 101
                                               + 5. 250 = + 00101. 010

                                               − 7. 125          11000. 111
                                        Figure 8.1: Examples of fixed point signed arithmetic.



                     changing its format, until the radix points are aligned. The choice of which one to shift de-
                     pends on what format we desire for the result. If we desire eight bits of fraction in our result,
                     then we would shift the S(7,4) left by four bits, converting it into an S(7,8). With the radix
                     points aligned, we simply use an integer addition operation to add the two numbers. The result
                     will have it’s radix point in the same location as the two numbers being added.



                     8.4.2 Fixed point multiplication

                     Recall that the result of multiplying an n bit number by an m bit number is an n + m bit num-
                     ber. In the case of fixed point numbers, the size of the fractional part of the result is the sum
                     of the number of fractional bits of each number, and the total size of the result is the sum of
                     the total number of bits in each number. Consider the following example where two U(5,3)
                     numbers are multiplied together:



                                                              00011. 110
                                                           × 00010. 100
                                                           0001. 1110
                                                        000111. 10
                                                  0000001001. 011000



                     The result is a U(10,6) number. The number of bits in the result is the sum of all of the bits
                     of the multiplicand and the multiplier. The number of fractional bits in the result is the sum
                     of the number of fractional bits in the multiplicand and the multiplier. There are three simple
                     rules to predict the resulting format when multiplying any two fixed point numbers.
   259   260   261   262   263   264   265   266   267   268   269