Airscript supports the standard arithmetic operators: addition (+), subtraction (-), multiplication (*) , and division (/), as well as remainder (%).
Unlike Airscript functions, Airscript operators not placed before the variables they are operating on, but rather between them, analogous to how operators are written in simple arithmetic equations. For instance, the following example shows you the addition operator (+) would be used to compute 2 plus 2:
2 + 2 -> 4
All arithmetic operators are capable of operating on Numbers and likewise returning Numbers as output. Some arithmetic operators are also capable of operating on variables of other Data Types. See documentation on individual operators for details.
Order of Operations
Airscript arithmetic operators are performed according to mathematical conventions. That is, an expression that contains multiple arithmetic operators will perform operations in the following order:
- Parentheses - Operations grouped into parenthesis are resolved first.
- Multiplication, Division, and Remainders - Multiplication, division, and remainder operations are resolved next. They are resolved from left to right.
- Addition and Subtraction - Addition and subtraction operations are resolved next. They are resolved from left to right.
Examples
In the absence of parenthesis, multiplication, division, and remainders are resolved before addition and subtraction, such as in the following example:
1 + 1 * 2 -> 3
When parenthesis are included, the operations within them are performed first, such as in the following example:
(1 + 1 )* 2 -> 4