GOOC - Game Oriented Object C
GOOC - Game Oriented Object C
7.13. Operator Precedence
7.13. Operator Precedence
When an expression contains multiple operators, such as a + b * c >> 8, the operators are grouped based on rules of precedence. For instance, the meaning of that expression is to multiply b by c, right shift the result by 8, then add that result to a. The rules of operator precedence determine the order of this expression.
The following is a list of types of expressions, presented in order of highest precedence first. Sometimes two or more operators have equal precedence; all those operators are applied from left to right unless stated otherwise.
- Operators with operands enclosed in separators such as parenthesis, and field access operator ->.
- Unary operators: +, -, !, ~, &.
- Multiplication, division, and modular division: *, /, %.
- Addition and subtraction expressions: +, -. These expressions are evaluated right-to-left.
- Bitwise shifting expressions: <<, >>.
- Greater-than, less-than, greater-than-or-equal-to, and less-than-or-equal-to expressions: >, <, >=, <=.
- Equal-to and not-equal-to expressions: ==, !=.
- Bitwise TEST expressions: \.
- Bitwise AND expressions: &.
- Bitwise XOR expressions: ^.
- Bitwise OR expressions: |.
- Logical AND expressions: &&. These expressions are evaluated right-to-left.
- Logical OR expressions: ||. These expressions are evaluated right-to-left.
- Conditional expressions: ?:.