

Arithmetic Expressions › Evaluation Of Arithmetic Expressions
Evaluation Of Arithmetic Expressions
Evaluation of Arithmetic Expressions
Arithmetic expressions are evaluated according to the following rules:
- Expressions within parentheses are evaluated first. Within nested parentheses, evaluation proceeds from the innermost to the outermost set of parentheses.
- If the order of evaluation of an expression or of an embedded expression is not specified explicitly by parentheses, the following order of evaluation is implied:
- Unary plus, unary minus, and built-in functions, from left to right
- Multiplication and division, from left to right
- Addition and subtraction, from left to right
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:
- The absolute value of VALUE2 is calculated.
- Unary minus is applied to 5.
- The result of step 2 is divided by VALUE3.
- The result of step 3 is added to the result of step 1.
- VALUE1 is divided by the result of step 4.
- The result of step 5 is subtracted from 4.
- The result of step 6 is added to VALUE4.
- 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:
- Expressions within parentheses are evaluated first. Within nested parentheses, evaluation proceeds from the innermost to the outermost set of parentheses.
- If the order of evaluation of an expression or of an embedded expression is not specified explicitly by parentheses, the following order of evaluation is implied:
- Unary plus, unary minus, and built-in functions, from left to right
- Multiplication and division, from left to right
- Addition and subtraction, from left to right
Copyright © 2014 CA.
All rights reserved.
 
|
|