Operators
Symbol | Description | Priority |
---|---|---|
( ) | Parenthesis - controls the order of evaluation of sub-expressions. | 6 |
^ | Raise to the power - number to the left is multiplied by itself according to the number on the right (i.e. 5^2 = 5 squared, or 25) | 5 |
* | Times - number to the left is multiplied by the number to the right (i.e. 4*3 = 4 times 3, or 12) | 4 |
/ | Divide - number to the left is divided by the number to the right (i.e. 6/2 = 6 divided by 2, or 3) | 4 |
% | Modulus - number to the left is divided by the number to the right returning the remainder (i.e. 10 % 4 = 10 mod 4, or 2) | 4 |
\ | Integer divide - number to the left is divided by the number to the right without the remainder (i.e. 15 \ 6 = 2) | 4 |
+ | Plus - number to the left is added to the number to the right (i.e. 7+2 = 9) | 3 |
- | Minus - number to the right is subtracted from the number to the left (i.e. 6-2 = 4) | 3 |
> | Greater-than - If the number to the left is greater than the number to the right, the result is 1 (i.e. 5>2 = 1, or True) | 2 |
>= | Greater-than or Equal-to - If the number to the left is greater than or equal to the number to the right, the result is 1 (i.e. 6>=5 = 1, or True) | 2 |
< | Less-than | 2 |
<= | Less-than or Equal-to | 2 |
= | Equal - If the number to the left is exactly the same as the number to the right, the result is 1 (i.e. 5=5 is True) | 2 |
!= | Not-Equal - If the number to the left is different from the number to the right, the result is 1 (i.e. 4 != 5 is True) | 2 |
& | Logical And - If
the number to the left is non-zero and the number to the right is
non-zero, the result is 1 (i.e. 1 & 1 = 1, or True; 1 & 0 = 0, or False; 0 & 0 = 0, or False) |
1 |
| | Logical Or - If
the number to the left is non-zero Or the number to the right is non-zero,
the result is 1 (i.e. 1 | 1 = 1, or True; 1 | 0 = 1, or True; 0 | 0 = 0, or False) |
1 |
~ | Logical Exclusive Or | 1 |