Rational Developer for System z
COBOL for Windows, Version 7.5, Programming Guide


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

related references
Terminology used for intermediate results


Terms of use | Feedback

Copyright IBM Corporation 1996, 2008.
This information center is powered by Eclipse technology. (http://www.eclipse.org)