Users Online Now: 2,970 (Who's On?) Visitors Today: 1,270,537 Pageviews Today: 1,708,293 Threads Today: 423 Posts Today: 6,265 12:00 PM

 Back to Forum Back to Thread
Message Subject Math: 6÷2(1+2) = ?
Poster Handle Forgotten
Post Content
The problem with your evaluation has nothing to do with the distributive law. You have the order of operations incorrect; you're not accounting properly for multiplication's associativity.

As written, you have: 6/2*(1+2). (You left the multiplication out in your example, but I think you'll agree it's the same thing.) When deciding how to fully parenthesize this expression, you must take into account that division and multiplication are left-associative.

That means: 6/2*(1+2) = (6/2)*(1+2) NOT 6/(2*(1+2))

Left-associative operators work like this: a1*a2*a3*...*aN = (((a1*a2)*a3)*...)*aN

Since multiplication and division are left-associative, that means when you mix them, you get: a1/a2*a3/...*aN = (((a1/a2)*a3)/...)*aN

The confusion caused by your example is that the importance of the left-associativity of the division operator is obscured by the fact that you left the multiplication operator implied. Once you make it explicit and fully parenthesize the expression according to the precedence and associativity of the operators involved, the confusion lifts.

(Incidentally, if you're interested in an example of a right-associative operator and one of the neatest implications of an operator with this property, see currying.)