The following example shows how the compiler performs an exponentiation to a nonzero integer power as a succession of multiplications, storing intermediate results as needed.
COMPUTE Y = A ** B
If B is equal to 4, the result is computed as shown below. The values of i and d that are used are calculated according to the multiplication rules for fixed-point data and intermediate results (referred to below).
ir4 has dmax decimal places. Because B is positive, ir4 is moved to Y. If B were equal to -4, however, an additional fifth step would be performed:
ir5 has dmax decimal places, and would then be moved to Y.