Arithmetic operators perform operations on numeric variants. The arithmetic operators arguments are automatically converted to compatible types (for example if you attempt to multiply a float variant with a double variant, the resulting variant will be of type double). The following table summarizes the current set of arithmetic operators:
Syntax | Name | Description | Example | Result |
---|---|---|---|---|
+ | Unary plus | Does nothing - it is defined for completeness with the unary minus. | +10 | 10 |
- | Unary minus | Used to establish a number with a negative sign. | -10 | -10 |
^ |
Exponentiation |
Raises arg1 to the power of arg2. |
10 ^ 2 |
100 |
* |
Multiplication |
Multiplies arg1 by arg2. |
10 * 2 | 20 |
/ |
Division |
Divides arg1 by arg2. |
10 / 2 |
5 |
+ |
Addition |
Adds arg2 to arg1. |
10 + 2 |
12 |
- |
Subtraction |
Subtracts arg2 from arg1. |
10 - 2 |
8 |