Previous Topic: SyntaxNext Topic: Coding Considerations


Evaluation Of Arithmetic Expressions

Evaluation of Arithmetic Expressions

Arithmetic expressions are evaluated according to the following rules:

Variable data fields specified in an arithmetic expression are not changed during the evaluation of the expression. All intermediate results in an expression are stored in separate internal data fields.

Example

The following example illustrates the order of evaluation of arithmetic expressions in process commands:

MOVE -(4 - VALUE1 / (ABS(VALUE2) + -5 / VALUE3) + VALUE4)
  TO RESULT.

The expression is evaluated in the following order:

  1. The absolute value of VALUE2 is calculated.
  2. Unary minus is applied to 5.
  3. The result of step 2 is divided by VALUE3.
  4. The result of step 3 is added to the result of step 1.
  5. VALUE1 is divided by the result of step 4.
  6. The result of step 5 is subtracted from 4.
  7. The result of step 6 is added to VALUE4.
  8. Unary minus is applied to the result of step 7.

The result of the expression is moved to RESULT.

Evaluation of Arithmetic Expressions

Arithmetic expressions are evaluated according to the following rules: