Next: , Previous: , Up: Operators   [Contents][Index]

6.3.3 Binary Arithmetical Operators

Binary arithmetical operators are defined for scalars (both real and complex), arrays (real and complex), and ranges (if the range elements are numerical), and addition is also defined for strings. The operator goes between the two operands. The data type of the result is equal to the highest data type present among the operands, except where noted. There is no implicit conjugation when multiplying or dividing complex numbers.

The available binary operators are:


x + y adds the values of x and y (if they are numerical) or concatenates the values (if they are STRI Gs). For instance, 'alpha' + 'bet' equals 'alphabet'.


x - y subtracts the value of y from the value of x.


x * y multiplies the values of x and y.

Matrix multiplication

x # y multiplies matrix x and matrix y. See mproduct.


x / y divides the value of x by the value of y. If x and y are both integer, then only the integer part of the division is returned.


x ^ y raises x to the power y. The result is always of a floating-point data type.


x MOD y and x % y return x modulus y, i.e., the nonnegative remainder of the division of x by y.

Signed Modulus

x SMOD y return the signed remainder of the division of x by y, i.e., the smallest (in absolute terms) remainder. If x = 3*y - 1 then x MOD y yields y - 1 but x SMOD y yields -1.

Next: , Previous: , Up: Operators   [Contents][Index]