Safari Books Online is a digital library providing on-demand subscription access to thousands of learning resources.
When an expression contains multiple operators, precedence and associativity determine the order of their evaluation. Operators with higher precedence execute before operators of lower precedence. If the operators have the same precedence, the operator’s associativity determines the order of evaluation.
The expression 1 + 2 * 3 is
evaluated as 1 + (2 * 3) because
* has a higher precedence than
+.
Binary operators (except for assignment, lambda, and null
coalescing operators) are
left-associative; in other words, they are
evaluated from left to right. For example, the expression 8/4/2 is evaluated as (8/4)/2 due to left associativity. Of
course, you can insert your own parentheses to change evaluation
order.