## #1,073 – Arithmetic Binary Operators are Left-Associative

All arithmetic binary operators (+, -, *, /, %) are left-associative.  This means that when there are multiple operators having the same precedence, the expression is evaluated from left to right.  Below are some examples.

```            // Multiplicative, left-right

// (10 / 5) * 2 = 4
// [result would be 1 if right-associative]
int i = 10 / 5 * 2;

// (40 % 12) * 2 = 8
// [result would be 16 if right-associative]
int i2 = 40 % 12 * 2;

// (4 - 3) + 5 = 6
// [result would be -4 if right-associative]
int i3 = 4 - 3 + 5;
```

Note that the multiplicative operators (*, /, %) have a higher precedence than the additive (+, -).  This means that if there are no parentheses, the multiplicative operators are evalated before the arithmetic.

```            // 1 + (2 * 3) = 7
int i4 = 1 + 2 * 3;

// Equivalent to 1 + ((10 / 5) * 2) = 5
int i5 = 1 + 10 / 5 * 2;
```

## #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);
```