
Chapter 12 Device Logic (Pawn)
12.5.5 Operators and expressions
12.5.5.1 Notational conventions
The use of some operators is dependent on the relevant type of operand. The following notations are
therefore used in this chapter:
e
Any expression
v
Any expression that can be assigned a value ("lvalue" expression - variable)
a
An array
f
A function
s
A symbol - this can be a variable, a constant or a function
12.5.5.2 Expressions
An expression consists of one or several operands with an operator. The operand can be a variable, a
constant or another expression. An expression followed by a semicolon is a statement.
Examples of expressions:
v++ f(a1, a2)
v = (ia1 * ia2) / ia3
12.5.5.3 Arithmetic
Operator Example
Explanation
+
e1 + e2
Result of adding e1 and e2
-
e1 - e2
Result of subtracting e2 from e1
-e
Result of the arithmetic negation of e (two's complement)
*
e1 * e2
Result of multiplying e1 with e2
/
e1 / e2
Result of dividing e1 by e2. The result is truncated to the closest whole number that is
less or equal to the quotient. Positive and negative values are rounded down (negative
infinity).
%
e1 % e2
Result is the remainder of the division of e1 by e2. The prefix is the same as that of e2
++
v++
Increases v by 1. The result of the expression is the value before the increase.
++v
Increases v by 1. The result of the expression is the value following the increase.
--
v--
Decreases v by 1. The result of the expression is the value before the decrease.
--v
Decreases v by 1. The result of the expression is the value following the decrease.
Note:
The unary + is not defined in the pawn. The ope+ and -- change the operand. The
operand must be a "lvalue".
Rev. 01
169