4. Operators
Operators are grouped by precedence, highest first.
Operators in the same section (4.x) have equal precedence.
Most operators may only be used on numeric (integer or floating) values.
Operators that may be used on string values are noted to that effect.
4.1 Unary Operators
4.1.1 -
Multiplies the following object by -1
4.1.2 NOT
1 if the following object is 0, 0 otherwise
4.2 Power
4.2.1 ^
Returns x^y.
Note that if y is integral, this is achieved by repeated multiplication.
If y is non-integral, x^y is equivalent to exp(y ln(x)).
4.3 Multiply and Divide
4.3.1 *
Returns x*y.
Note that if both x and y are integers, x*y is an integer.
Otherwise x*y is a floating value
4.3.2 /
Returns x/y.
Note that this value is always floating.
4.4 Add and Subtract
4.4.1 +
Returns x+y.
Note that if y is integral, this is achieved by repeated multiplication.
Note also that this operator may be used on strings.
4.4.2 -
Returns x-y.
Note that if y is integral, this is achieved by repeated multiplication.
4.5 Comparison
All these operators return 1 if the expression is true, 0 otherwise.
All may be used on numeric or string values.
String comparison is case sensitive.
4.5.1 =
4.5.2 <>
4.5.3 <
4.5.4 <=
4.5.5 >
4.5.6 >=
4.6 Boolean operators
These final operators are commonly used for grouping comnparison operators.
For example, if you wish to perform an action only if two comparisons are true, you might write:
if a=1 and b=2 then ...
4.6.1 AND
x AND y is 1 if both x and y are non-zero. Otherwise it is 0.
4.6.2 OR
x OR y is 1 if either x or y or both are non-zero. Otherwise it is 0.
4.6.3 XOR
x XOR y is 1 if x is non-zero, or y is non-zero, but 0 if both are non-zero or both are zero.
(XOR stands for exclusive o, meaning x or y but not both.)