associative property

created by jakohn
(idea) by jakohn (2.5 wk) (print)   ?   (I like it!) 1 C! Fri Apr 28 2000 at 22:59:21
The associative property, or associative law, is a property of many arithmetic and logical functions that says that the order of evaluation does not matter. Example:

Suppose you have the equation:
1 + 2 + 3 + 4 + 5 + 6
You may evaluate it in any order:
((1 + 2) + (3 + 4)) + (5 + 6) = (3 + 7) + 11 = 10 + 11 = 21
or:
1 + (2 + (3 + (4 + (5 + 6)))) = 1 + (2 + (3 + (4 + 11))) = 1 + (2 + (3 + 15)) = 1 + (2 + 18) = 1 + 20 = 21

Or many other ways. While different ways may be quicker, they all lead to the same answer. Addition, Multiplication, AND, OR, XOR are all associative.

Now consider subtraction with the equation:
6 - 5 - 4 - 3 - 2 - 1
If you do:
(6 - 5) - ((4 - 3) - (2 - 1)) = 1 - (1 - 1) = 1 - 0 = 1
Whereas, if you do:
((6 - 5) - (4 - 3)) - (2 - 1) = (1 - 1) - 1 = 0 - 1 = -1

Which are obviously not the same. Subtraction is thus not associative. Neither is division. In order to properly evaluate them we need to have rules of algebraic precedence.

Y'know, if you log in, you can write something here, or contact authors directly on the site. Create a New User if you don't already have an account.