6 Programming
6-82
NJ-series CPU Unit Software User’s Manual (W501)
Operators
The following table gives the operators and their order of priority.
If operators with different priorities are mixed in one expression, the operators with the highest prior-
ities are executed first.
Example: X:=(1+2)3*4; In this case, variable X is assigned a value of 9.
Operation Operator Notation example and evaluated value Priority
Parentheses () (1+2)*(3+4)
Value: 21
1
Function/function
block call
FUN1( FUN2( Var2A, Var2B), Var1B)
When function and function block calls are nested, the func-
tion or function block at the lower level is called first. In the
above example, FUN2 is executed first, and then FUN1 is
executed.
2
Sign +, +100
100
3
NOT NOT NOT TRUE
Value: FALSE
Exponent ** -2**2
Value: 4
A minus sign is given priority over an exponent operator.
Therefore, -2**2 in the above example is the same as (-
2)**2, so the value is 4.
2**3**2
Value: 64
If there is more than one exponent operator, calculations
are performed for them left to right. Therefore, 2**3**2 in
the above example is the same as (2**3)**2, so the value is
64.
4
Multiplication * 100*200
Value: 20,000
5
Division / 100/200
Value: 0.5
Remainder MOD 10 MOD 7
Value: 3
17 MOD 6
Value: 5
17 MOD (6)
Value: 5
17 MOD 6
Value: 5
17 MOD (6)
Value: 5
(1+2)−3*4
3−3*4 3−12
−9
1. The operation in
parentheses (priority
of 1) is performed.
2. The multiplication
(priority of 5) is
performed.
3. The subtraction
(priority of 6) is
performed.