Table 4-4. operators in order of precedence – Micromod Micro-PWC: 53PW6000 MicroPWC Configuration Guide User Manual

Page 143

Advertising
background image

Micro-PWC CONFIGURATION GUIDE

Grafx Editor 123

(The example for the logical "OR" is True if the values of the PV and SP atoms of controller point "tcon01"
are within 0.5 of each other.)

Because expressions can be complex, and often include multiple operators and operands, a set of rules
exists to determine which operators get performed first, which get performed second, third, and so on. This
order is known as precedence. Some operators, such as * (multiply) and / (divide) have equal precedence.
If operators of equal precedence are used in an expression, they are performed according to the order in
which they appear in the expression, left-to-right. (The unary operators ! (logical not) and - (minus) are
exceptions to this rule and are evaluated right-to-left; unary operators act on just one operand. All other
operators which can be used in a Dynamics expression are binary operators, and act on two operands.)

Precedence is an important concept to remember, as its effects on the evaluation of an expression can
confuse the unwary. For example, consider the following expression:

2 + 3 * 4

The resulting value of this expression is 14, not 20. Because the* (multiplication) operand has a higher pre-
cedence than the + (addition) operand, the multiplication portion of the expression (3k4) is performed first.
If the expression were written:

(2 + 3) * 4

the value of the expression would be 20, because expressions contained within parentheses are evaluated
first.

Table 4-4

contains a list of the operators which can be used in a Dynamics expression on the Micro-DCI

system; in this table, the operators with equal precedence are grouped together. Operator groups with
higher precedence are located higher in the table.

&&

logical "and"

Evaluates two expressions
and is true if and only if both
are true.

ani01.PA && !ani01.AIH

||

logical "or"

Evaluates two expressions
and is true if either one or both
are true.

tcon01.PV - tcon01.SP < 0.5 ||
tcon01.SP - tcon01.PV < 0.5

Note

A single tagname.atom, with no operators, is also a valid
expression; this is useful with bit-type atoms which can have a
value of 1 or 0.

Table 4-4. Operators in Order of Precedence

SYMBOL

DESCRIPTION

( )

parentheses

!

logical not (unary)

-

minus (unary)

*

multiply

Table 4-3. Operator Usage - Description And Examples (Continued)

OPERATOR DESCRIPTION

USAGE

EXAMPLE

Advertising