Example: calculation of intermediate results

The following example shows how the compiler performs an arithmetic statement as a succession of operations, storing intermediate results as needed.


COMPUTE Y = A + B * C - D / E + F ** G

The result is calculated in the following order:

  1. Exponentiate F by G yielding ir1.
  2. Multiply B by C yielding ir2.
  3. Divide E into D yielding ir3.
  4. Add A to ir2 yielding ir4.
  5. Subtract ir3 from ir4 yielding ir5.
  6. Add ir5 to ir1 yielding Y.

related tasks  
Using arithmetic expressions