User Guide

Table Of Contents
Program Methodology—Order of Precedence
Siemens Building Technologies, Inc. 1-43
Statements containing relational and logical operators are also
assigned a precedence level.
Note that in problems comparing values using relational operators
(.EQ. and .NE.), the result of the comparison can change the output
of the statement.
Example 2
If (value1 .EQ. value2 .AND. value1 .NE. value3) then...
This equation is solved as follows:
1. The relational operators (.EQ. and .NE.) have the highest
precedence level in the formula. Since these two operators have
the same precedence level, they are evaluated from left to right.
In this example, assume that both comparisons (condition1 and
condition2) are true.
value1 .EQ. value2 (condition1 = true)
value1 .NE. value3 (condition2 = true)
After the first level of operators has been evaluated, the equation
now looks like the following:
If (condition1 .AND. condition2) then...
2. The logical operator .AND. is then evaluated.
3. Since .AND. requires both conditions to be true, the solution to
this problem will also be true.
Changing Precedence Levels with Parentheses
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.
APOGEE PPCL User’s Manual
1-44 Siemens Building Technologies, Inc.
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:
1. 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
2. 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.