Chapter 7
136
UM10350_PCNC770_Manual_0916A
Programming
7.9.3.1 Binary Operators
Binary operators only appear inside expressions. There are three types of binary operators:
mathemacal, logical, and relaonal.
There are four basic mathemacal operaons: addion (+), subtracon (-), mulplicaon (*), and
division (/). In addion, the modulus operaon (MOD) nds the remainder aer division of one
number by another number. The power operaon (**) of raising the number on the le of the
operaon to the power on the right. There are three logical operaons: non-exclusive or (OR),
exclusive or (XOR), and logical and (AND).
The relaonal operators are equality (EQ), inequality (NE), strictly greater than (GT), greater than or
equal to (GE), strictly less than (LT), and less than or equal to (LE).
Binary operators are divided into several groups according to their precedence.
Binary Operator Precedence
** 1 (highest)
* / MOD 2
+ - 3
EQ NE GT GE LT LE 4
AND OR XOR 5 (lowest)
If operaons in dierent precedence groups are strung together, operaons with a higher precedence
are performed before operaons with a lower precedence. If an expression contains more than one
operaon with the same precedence, the operaon on the le is performed rst.
Example:
[2.0 / 3 * 1.5 - 5.5 / 11.0]
is equivalent to
[[[2.0 / 3] * 1.5] - [5.5 / 11.0]]
which is equivalent to
[1.0 - 0.5]
which is
0.5
The logical operaons and modulus are to be performed on any real numbers, not just on integers.
The number zero is equivalent to logical false, and any non-zero number is equivalent to logical true.