The order of priority for operators is sometimes different for different standards and manufactur-
ers. Special attention is necessary for the priority of exponent operators. We therefore recom-
mend that you use parentheses to ensure that calculations are performed in the intended order.
Example: For X:= -2**3**4; we recommend that you use the following expression:
X:= ((-2)**3)**4;.
Calculations are performed based on the data types. For example, the result of calculations with
integer data will be integer data. Therefore, if the expression A/B is calculated with INT variables
A = 3 and B = 2, the result would not be 1.5 because all values after the decimal point are trun-
cated. In this case, the expression (A/B)*2 would evaluate to 2 instead of 3.
Data Types for Operator Operands
If all the operands for an operator have the same data type, any data type given as “Supported” in
the following table can be set as operands. However, if an operand with a different data type is set
for the operator, an implicit cast is required. Refer to Implicit Casts on page 6-106 for details on
implicit casting.
OK: Possible
---: A building error will occur.
* Do not use operators to compare text string variables. Use instructions (such as EQascii) instead.
Data type
Assign-
ment
operator
Argu-
ment set-
ting
operator
Numeric
opera-
tors
Modulo-
division
operator
Power
operator
Compari-
son
opera-
tors
Equality
opera-
tors
Logic
opera-
tors
Posi-
tive/neg-
ative
signs
:=
:=
=>
+
*
/
MOD **
<
<=
=>
>
=
<>
NOT
AND
&
OR
XOR
+
Boolean OK OK --- --- --- --- OK OK ---
Bit string OK OK --- --- --- --- OK OK ---
Integer OK OK OK OK OK OK OK --- OK
Real num-
ber
OK OK OK --- OK OK OK --- OK
Duration OK OK --- --- --- --- --- --- OK
Date OK OK --- --- --- --- --- --- ---
Time of
day
OK OK --- --- --- --- --- --- ---
Date and
time
OK OK --- --- --- --- --- --- ---
Text string OK OK --- --- --- ---* ---* --- ---
Enumera-
tion
OK OK --- --- --- --- OK --- ---
Structure
parent
OK OK --- --- --- --- --- --- ---
Array par-
ent
OK OK --- --- --- --- --- --- ---