A.2.2.1 Integer, Real, Complex, and Quantity Operators

For the data types Integer, Real, Complex, and Quantity, the basic mathematical operators are supported:


Table A.5: Arithmetic operators.
Operator name Function
+ add
- subtract
* multiply
/ divide
% modulo

The modulo operator (%) is defined for Integers only.

Some examples:

2 * 3 + 4 / 2              // -> 8
-3 + -1                    // -> -4

The type of such arithmetic expressions depends on the types of its operands. If the types of both operands are equal, the result will be of the same type. For instance, the sum of two Integers will again be an Integer. If the types are not equal, the result will be of the stronger type. For instance, the sum of an Integer and a Real will be a Real. The strength of the types are (in increasing order) Integer, Real, Complex, Quantity, and String.

The result of a division of two Integers will again be an Integer. Therefore, the result may be truncated.

For instance:

10 / 4                     //  Integer operation   -> 2
10.0 / 4.0                 //  Real operation      -> 2.5

Robert Klima 2003-02-06