OpenUtilities Substation Help

Operator Precedence

You can combine all of the operators described above to form complex expressions. In some cases, different results can be obtained depending on the order of evaluation of the expression. For example, the expression

color + 3 * 5

is ambiguous. It could be interpreted as

(color + 3) * 5


color + (3 * 5)

To resolve this ambiguity, each operator has a relative precedence. When there are no parentheses to directly indicate the order of evaluation, operators with a higher precedence are evaluated before an operator of lower precedence. Operators of the same precedence are evaluated from left to right. The following list contains operators in order of precedence from highest to lowest. Operators of the same precedence are listed on the same line.

/ *
+ -
.EQ. EQ == .NE. NE <> .GE. GE > = .LE. LE< = .GT. GT> .LT. LT<
.OR. OR || .AND. AND &&

It is generally a good practice to use parentheses with expressions that can be ambiguous instead of depending on precedence rules. Parentheses also make the design script program easier to understand.