Arithmetic Operators
Expr := Expr "+" Expr
| Expr "-" Expr
| Expr "*" Expr
| Expr "/" Expr
| Expr "%" Expr
| Expr "÷" Expr
| Expr "^" Expr
Arithmetic operators allow you to use conventional infix notation in order to invoke arithmetic relations from the Standard Library.
For example, a - b - c * d
is equivalent to subtract[subtract[a, b], multiply[c, d]]
.
The correspondence between arithmetic operators and Library functions is shown in the following table:
Operator | Library Relation |
---|---|
+ | add |
- | subtract |
* | multiply |
/ | divide |
% | remainder |
÷ | trunc_divide |
^ | power |
The arithmetic operators have conventional precedence with respect to each other.
The exponentiation operator ^
associates to the right, the others associate to the left.
See Precedence for details.
If the right operand of the exponentiation operator ^
is an identifier, you should separate the two with white space.
Write a^ b
or a ^ b
, but not a^b
.
If ^
is immediately followed by a letter, the operator is interpreted as beginning an identifier, so a^b
will be a sequence of two identifiers — a
followed by ^b
.
Next: Underscore