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

#### 6.3.3 Binary Arithmetical Operators

Binary arithmetical operators are defined for `scalar`s (both real and complex), `array`s (real and complex), and `range`s (if the range elements are numerical), and addition is also defined for `string`s. 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 G```s). For instance, `'alpha' + 'bet'` equals `'alphabet'`.

Subtraction

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

Multiplication

`x * y` multiplies the values of `x` and `y`.

Matrix multiplication

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

Division

`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.

Power-taking

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

Modulus

`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]