## #515 – Binary Operators Are Left-Associative

When an expression contains more than one binary operators, where the operators are identical or have the same precedence, the operators are left-assocative.  This means that the expression is evaluated from left to right.

For example, the result of the expression shown below is 5, rather than 20.  80 is divided by 8 to get an intermediate result of 10.  10 is then divided by 2 to get a result of 5.

```            double result = 80 / 8 / 2;
```

This means that the above expression is equivalent to:

```            double result = (80 / 8) / 2;
```

If you want to force the division of the 2nd and 3rd operands to happen first, you could use parentheses around them:

```            // result = 20
double result = 80 / (8 / 2);
```

## #514 – Examples of Operator Precedence

Each operator has an associated precedence, which indicates the order in which the operators are evaluated when evaluating the  expression.

For example, because multiplicative (*, /, %) operators have a higher precedence than additive (+, -) operators, the multiplication in the expression below happens before the addition, so the answer is 34.

```int result = 4 + 5 * 6;
```

If we want the addition to happen first, we can change the precedence by using parentheses.

```// Result = 54
int result = (4 + 5) * 6;
```

Here are some other examples of operator precedence.

```            // Negation operator has higher precedence than conditional operators
bool res = !false || true;    // true  (negation operator evaluated first)
res = !(false || true);       // false (conditional OR evaluated first)

// && has higher precedence than ||
bool res = true || false && false;    // true
res = (true || false) && false;       // false
```