&abs, &add, &sub, &mul, &div, &mod, &neg, &inc, &dec, &pinc, &pdec - Numeric macro operators
&abs num1
&add num1 num2
&sub num1 num2
&multiply num1 num2
÷ num1 num2
&mod num1 num2
&negate num
&inc variable increment
&dec variable decrement
&pinc variable increment
&pdec variable decrement
The numeric operators operate on variables or integers to perform integer computations, returning the integer result of the operation. The contents of the variables are interpreted as signed integers typically with a dynamic range of 2^31 <= num <= 2^31-1.
The operators may all be abbreviated to their three letter abbreviation (i.e. &multiply may be expressed as &mul). In all cases the first argument is completely evaluated before the second argument.
&abs num1
&add num1 num2
&sub num1 num2
&multiply num1 num2
&div num1 num2
&mod num1 num2
&negate num
Expression evaluation is prefix. Operators may be nested using a pre-fix ordering, there is no concept of brackets (in-fix notation). The expression (2 * 3) + 4 is expressed as:-
&add &mul 2 3 4
conversely 2 * (3 + 4) is expressed as:-
&mul 2 &add 3 4
The pre/post incrementing and decrementing operators provide a mechanism for stepping through indexed information without incurring the overhead of providing multiple statements to perform assignment operations. The variable argument MUST be the name of a variable, it cannot be an expression or an indirection. The increment may be any integer expression (including another auto (dec)increment). Note that variable is re-assigned with it's new value within the operator, therefore use with care when performing multiple (dec)increments within the same statement line. The four operators are defined as follows:
&inc variable increment
&dec variable decrement
&pinc variable increment
&pdec variable decrement
Add two numbers together and assign to a variable:-
set-variable %result &add %num1 %num2
Increment %result by 1 and add to %result2
set-variable %result &add %result 1 set-variable %result2 &add %result2 %result
The previous example could have used the increment operators to achieve the same result in a single operation e.g.
set-variable %result2 &add %result2 &inc %result 1
(c) Copyright JASSPA 1999
Last Modified: 1998/09/02
Generated On: 1999/12/01