An operator has three kinds of properties; number of operands it takes, when it takes more than one operand, it has association property, and when multiple kinds of operators are in an expression, the evaluation order of the expression is governed by operators' precedence.
Operator symbol |
Number of
|
Association |
Precedence |
Description |
. |
2 |
Left to Right |
1 |
Member access operator |
^ |
2 |
Right to Left |
2 |
Power operator |
-, + |
1 |
Left side of an operand |
3 3 3 3 3 3 3 |
Unary -/+ operators |
++ |
1 |
Either left or right side of an operand |
Increment operator | |
-- |
1 |
Either left or right side of an operand
|
Decrement operator | |
~ |
1 |
Left side of an operand |
Complex conjugate operator when use with a complex number, or unit vector operator when use with a vector | |
! |
1 |
Right side of an operand |
Factorial with an integer operand | |
# |
1 |
Left side of an operand |
Returns minimum element of an array | |
@ |
1 |
Left side of an operand |
Returns maximum element of an array, when applied to a complex number, it returns argument of a complex number. | |
* |
2 |
Left to Right |
4 4 4 |
Multiplication operator for integer, real, complex numbers. When the operands are vector, it is scalar product operator |
/ |
2 |
Left to Right |
Division operator for integer, real, and complex numbers. This operator is not defined for vectors | |
% |
2 |
Left to Right |
Modulo (or remainder) operator with integer operands. When the operands are vectors, it is cross product operator. | |
+ |
2 |
Left to Right |
5 5 |
Addition operator |
- |
2 |
Left to Right |
Subtraction operator | |
# |
2 |
Left to Right |
6 6 |
Minimum operator |
@ |
2 |
Left to Right |
Maximum operator | |
< |
2 |
Left to Right |
7 7 7 7 7 7 |
Less than |
> |
2 |
Left to Right |
Greater than | |
<= |
2 |
Left to Right |
Less than or equal to | |
>= |
2 |
Left to Right |
Greater then equal to | |
!= |
2 |
Left to Right |
Not equal to | |
== |
2 |
Left to Right |
Equal to | |
&& |
2 |
Left to Right |
8 8 |
Logical AND |
|| |
2 |
Left to Right |
Logical OR | |
? |
3 |
|
9 |
Ternary operator |
?? |
3 |
|
10 |
Numerical method operator |
+= |
2 |
Right to Left |
11 |
Add then assign to |
-= |
2 |
Right to Left |
Subtract then assign to itself | |
*= |
2 |
Right to Left |
Multiply then assign to itself | |
/= |
2 |
Right to Left |
Divide than assign to itself | |
= |
2 |
Right to Left |
Assignment operator | |
<- |
2 |
Right to Left |
Functional expression operator | |
, |
2 |
Left to Right |
12 |
Statement concatenation operator |
; |
1 |
|
13 |
Statement termination operator |