# Operators

Blackey Script’s Operator Precedence is mostly like C language,
the following table lists the precedence and associativity of operators.
Operators are listed top to bottom, in descending precedence.

For example, the expression below:

x = 5;
y = z = 1 * -2 + 3 * 4 – -x;

The unary minus operator is in Group 2, much higher than other operators.
Then, the multiplication operator (Group 3),
which is much higher than the addition and subtraction operator (Group 4).
After the addition and subtraction, finally is the simple assignment operator. (Group 9, from Right to Left)

So the calculated result will be y equals to z equals to 15.

Group 1

 Function Operator Example Function call () print(x);

Group 2，Right-to-left

 Function Operator Example Unary minus – x = -1; y = 1 * -3;

Group 3

 Function Operator Example Multiplication * x = 1 * 2; Division / x = 6 / 2; Remainder % x = 5 % 3;

Group 4

 Function Operator Example Addition + x = 1 + 2; Subtraction – x = 1 – 2;

Group 5

 Function Operator Example Less < x < 1 Larger > x > 1 Less or equal <= x <= 1 Larger or equal >= x >= 1

Group 6

 Function Operator Example Equal == x == 1 Not euqal != x != 1

Group 7

 Function Operator Example Logical AND && x && y

Group 8

 Function Operator Example Logical OR || x || y

Group 9，Right-to-Left

 Function Operator Example Simple assignment = x = 1; x = y = z = 1;

Group 10

 Function Operator Example Comma , x = 1, y = 2; print(x, y);