Operators specify a mathematical or logical calculation to be performed between various elements of an expression.
Use the following arithmetic operators to perform basic mathematical operations.
Operator | Description |
---|---|
+ | Addition |
- | Subtraction |
* | Multiplication |
/ | Division |
% | Modulo (this is a binary operator) |
(x, y, z) | Vector where x, y, and z are scalar values |
Use the following operators to compare two values with each other. When two values are compared using these operators, the result is 1 if the comparison is true and 0 if the comparison is false.
Operator | Description |
---|---|
== | Equal to |
!= | Not equal to |
< | Less than |
<= | Less than or equal to |
> | Greater than |
>= | Greater than or equal to |
&& | Boolean AND |
|| | Boolean OR |
! | Boolean NOT |
When you combine several operators in a single expression, the operations are performed in the following order.
Order | Operator | Description |
---|---|---|
1 | ! | Boolean NOT |
2 | - | Negation (as in -1) |
3 | *, / and % | Multiplication, division, and modulus |
4 | + and - | Addition and subtraction |
5 | < , <=, >, and >= | Comparison |
6 | == and != | Equivalence |
7 | && | Boolean AND |
8 | || | Boolean OR |
When operators with the same precedence are encountered, operators are evaluated from left to right. However, when part of a formula is enclosed in parentheses, it is evaluated first.