Parentheses can be used to override the normal order of precedence. Placing parentheses around specific values or operations gives the information within the set of parentheses the highest order of precedence. If all the operators within in the parentheses have equivalent precedence levels, then the operators are evaluated from left to right.

When the computer evaluates multiple pairs of parentheses, each pair is evaluated according to how it is positioned in the formula. Multiple parentheses are evaluated as follows:

  • For a pair of parentheses defined within another pair of parentheses, the computer always evaluates the innermost set first.
  • For parentheses defined as individual pairs, each pair is evaluated from left to right.

The following example illustrates how parentheses change the way the computer evaluates equations.

Example

10 - 5 + 2 * 3 = x

This equation uses two levels of precedence: multiplication and addition/subtraction. Following the order of precedence rules, the solution to this equation is 11.

When parentheses are inserted, the same equation produces a different solution.

(10 - 5 + 2) * 3 = x

The equation is now solved as follows:

  • Parentheses give the information within the set of parentheses the highest order of precedence. The operators within the parentheses are evaluated from left to right because they all have the same precedence. The first step in evaluating the equation is as follows:

(10 - 5 + 2) = 7

After the operators within parentheses have been evaluated, the equation appears as follows:

7 * 3 = 21

  • The standard precedence rules now apply to the remaining operators. With only one operation left, the multiplication operator is evaluated and produces a solution of 21.

Table 1-5.  Order of Precedence for PPCL Operators.

Precedence Level

Command

Syntax

1 (Highest)

Parentheses

(expression or value)

 

 

 

 

 

 

 

 

 

2

Alarm priority

ALMPRI(pt1)

Arc-tangent

ATN(value1)

Complement

COM(value1)

Cosine

COS(value1)

Natural antilog

EXP(value1)

Natural log

LOG(value1)

Sine

SIN(value1)

Square root

SORT(value1)

Tangent

TAN(value1)

Totalized value

TOTAL(pt1)

3

Root

(value1.ROOT.value2)

 

4

Multiplication

value1 * value2

Division

value1 / value2

 

5

Addition

value1 + value2

Subtraction

value1 - value2

 

 

 

 

 

6

Equal to

.EQ.

Not equal to

.NE.

Greater than

.GT.

Greater than or equal to

.GE.

Less than

.LT.

Less than or equal to

.LE.

 

7

And

.AND.

Not and

.NAND.

 

8 (Lowest)

Or

.OR.

Exclusive Or

.XOR.