Specifications
80
6.3 Operators
6.3.1 Arithmetic Operators
Arithmetic operators include a negative sign (-) and operators for multiplication (*), division (/),
addition (+), and subtraction (-). They also include modulo operator
MOD.
■
Modulo Operation (MOD)
The MOD operator executes the modulo operation; that is, it divides expression 1
by expression 2 (see the format below) and returns the remainder.
Syntax:
expression1 MOD expression2
Where one or more spaces or tab codes should precede and follow the MOD.
If these expressions include real values, the
MOD first rounds them off to integers and
then executes the division operation. For example, the
MOD treats expression 8 MOD
3.4
as 8 MOD 3 so as to return the remainder "2".
■
Overflow and Division by Zero
Arithmetic overflow resulting from an operation or division by zero will cause a run-time
error. Such an error may be trapped by error trapping.
Operations Arithmetic Operators Precedence
Examples
Negation
-
1
-a
Multiplication and division
* and /
2
a*b, a/b
Modulo arithmetic
MOD
3
a MOD b
Addition and subtraction
+ and –
4
a+b, a-b