Priority of Operators

When more than one type of operator appears in an expression, what operation does the language processor do first?
IF (A > 7**B) & (B < 3)

Like the priority of operators for the arithmetic operators, there is an overall priority that includes all operators. The priority of operators is as follows with the highest first.

Table 1. Overall Operator Priority
Operator symbol Operator description
\ or ¬ - + Prefix operators
** Power (exponential)
* / % // Multiply and divide
+ - Add and subtract
blank || abuttal Concatenation operators
== = >< and so on Comparison operators
& Logical AND
| && Inclusive OR and exclusive OR
Thus, given the following values
  • A = 8
  • B = 2
  • C = 10
the language processor would evaluate the previous example
    IF (A > 7**B) & (B < 3)
as follows:
  1. Evaluate what is inside the first set of parentheses.
    1. Evaluate A to 8.
    2. Evaluate B to 2.
    3. Evaluate 7**2.
    4. Evaluate 8 > 49 is false (0).
  2. Evaluate what is inside the next set of parentheses.
    1. Evaluate B to 2.
    2. Evaluate 2 < 3 is true (1).
  3. Evaluate 0 & 1 is 0

Reference Reference

Feedback


Timestamp icon Last updated: Tuesday, 7 January 2014


http://pic.dhe.ibm.com/infocenter/cicsts/v5r1/topic/com.ibm.cics.rexx.doc//dfhrx/rvse019.html