Associativity (and Commutativity)

Associative means that the order in which operators are applied doesn’t matter. For example:

(a + b) + c = a + (b + c)

This means that it doesn’t matter if we add a and first or if we add b and c first, we still get the same answer.

Commutative means that the order of the operands can change without changing the result. For example:

a * b = b * a

This means that * is commutative. However:

a / b ≠ b / a

Which means that / is not commutative.

Here are some simple examples:

  • 3 * 4 = 12
  • 4 * 3 = 12
  • 6 / 2 = 3
  • 2 / 6 =