When one line contains many operators, Easytrieve does not read strictly left to right. Order of evaluation—operator precedence—decides which operations bind first. Multiply before add. Arithmetic before greater-than. AND before OR. Exponentiation before multiply. Beginners who write IF A + B * C GT D intending (A + B) * C get silent wrong branches because B * C computed first. Payroll analysts who write IF STATUS EQ A OR STATUS EQ B AND GROSS GT 0 may intend OR across statuses with AND gross guard but precedence groups AND first. This page presents the precedence hierarchy Broadcom documentation implies, shows worked examples, contrasts default rules with parentheses override, and gives shop-safe habits: parenthesize mixed logical lines, split dense formulas to work fields, and trace boundary test cases when auditing legacy programs.
| Rank | Operators | Notes |
|---|---|---|
| 1 (tightest) | Parentheses ( ) | Innermost group first |
| 2 | ** exponentiation | Power before multiply |
| 3 | * / | Multiply divide left to right |
| 4 | + - | Add subtract left to right |
| 5 | EQ NE GT LT GE LE THRU | Relational compare |
| 6 | NOT | Negate condition |
| 7 | AND | Logical and |
| 8 (loosest) | OR | Logical or |
Exact NOT placement may vary by condition form—when uncertain, parenthesize NOT with the condition it negates. Class conditions like NUMERIC behave as atomic units at relational level when combined with AND OR.
RESULT = 10 + 5 * 2 yields 20 not 30—multiply 5 * 2 = 10, then add 10 + 10. RESULT = (10 + 5) * 2 yields 30—parens force add first. RESULT = 100 / 10 / 2 may divide left to right: 10 then 5 depending on associativity—verify with test DISPLAY on your release. RESULT = 2 ** 3 ** 2 may right-associate exponentiation in some languages—test 512 versus 64; parenthesize (2 ** 3) ** 2 when policy demands explicitness.
123WS-A = 10 + 5 * 2 * Result 20 WS-B = (10 + 5) * 2 * Result 30 WS-C = GROSS - DEDUCT * RATE * Multiply before subtract
IF A + B * C GT D evaluates B * C, adds A, compares to D. IF GROSS * 0.10 GT LIMIT computes tax amount before threshold test. IF GROSS - DEDUCT LT 0 subtracts after any implied multiply in more complex form—parenthesize net: IF (GROSS - DEDUCT) LT 0. Relational operators never run before arithmetic operands on same expression line are resolved.
123IF GROSS * TAX-RATE GT MIN-TAX PERFORM APPLY-MIN-TAX END-IF
Logical precedence causes AND groups to form before OR connects groups. IF A OR B AND C parses as IF A OR (B AND C)—true when A alone, or when both B and C. IF STATUS EQ A OR STATUS EQ B AND GROSS GT 0 may parse as STATUS EQ A OR (STATUS EQ B AND GROSS GT 0)— active status always passes; pending requires positive gross. Intended (STATUS EQ A OR STATUS EQ B) AND GROSS GT 0 needs parentheses. Document intended grouping in comment beside line for auditors.
12345* Default binding: IF DEPT EQ 10 OR DEPT EQ 20 AND GROSS GT 0 * Intended both depts require gross: IF (DEPT EQ 10 OR DEPT EQ 20) AND GROSS GT 0
NOT negates the condition that follows or grouped unit IF NOT EOF. IF NOT STATUS EQ A may parse differently than IF STATUS NE A—prefer NE for clarity when equivalent. IF NOT (A GT 0 AND B GT 0) negates entire AND group. Misplaced NOT causes inverted branch logic hard to spot in diff reviews.
Right side of assignment evaluates completely before store into left target. NET = A + B * C computes B * C, adds A, stores into NET. ROUNDED TRUNCATED apply at store step after full right-side evaluation. Multiple assignments on consecutive lines execute top to bottom—no expression across lines unless fields reference prior results.
Operators at same level often associate left to right. 20 - 10 - 2 yields 8 not 12: subtract 10 from 20, then subtract 2. 24 / 6 / 2 yields 2: divide 24 by 6, then by 2. Addition chains left to right similarly. Exponentiation associativity is the common footgun—parenthesize exponents in financial code.
Condition expression on IF or DO WHILE line evaluates once per entry or iteration per statement rules. Short-circuit evaluation—skipping right side when AND left false—do not rely on undocumented for safety-critical guards; test divisor explicitly before divide even inside AND chain.
Line: IF GROSS GT LIMIT + ADJ AND STATUS EQ A OR HOLD EQ Y. Step 1: LIMIT + ADJ add. Step 2: GROSS GT sum compare. Step 3: STATUS EQ A compare. Step 4: HOLD EQ Y compare. Step 5: AND binds STATUS EQ A with prior GT result? Actually AND before OR: group (GROSS GT LIMIT + ADJ AND STATUS EQ A) OR HOLD EQ Y. Trace with test values: GROSS 5000, LIMIT 4000, ADJ 500, STATUS P, HOLD Y—GT true, STATUS false, AND false, HOLD true, OR true—branch taken. Without trace, surprise payments occur.
Order of evaluation is which math sign goes first when no one put parentheses. Times and divide go before plus and minus. Questions like bigger-than go after the math is done. AND is stickier than OR—it groups before OR unless parentheses say otherwise. Parentheses are the boss—they tell everyone what to do first.
1. In A + B * C multiplication runs before addition because:
2. IF A GT 0 AND B GT 0 OR C GT 0 without parens groups as:
3. Exponentiation ** binds:
4. Parentheses in expression:
5. Relational operators GT LT EQ bind: