# Operator precedence [duplicate]

Possible Duplicate:
What is 48÷2(9+3)?

Hi all

I don't know if anyone has seen this question floating around Facebook, but me and a friend are a little conflicted.

The question is: $6 \div 2(1+2) = ?$

Should this be interpreted as $\frac{6}{2(1+2)} = 1$, or $\frac{6}{2} \times (1+2) = 9$?

I went with the first, using programming operator precedence. My friend, however, went for the second, saying "In algebra, bracket multiplication binds more tightly than explicit multiplication".

What I'd like to know is, what is the answer to this simple equation in programming terms and algebra terms, or are they exactly the same?

Thanks very much,

James

-

## marked as duplicate by Hans Lundmark, Rahul, J. M., t.b., Qiaochu YuanApr 29 '11 at 11:43

It should be interpreted as ambiguous and sent back for clarification. Whoever wrote it should write $(6\div2)(1+2)$ if that's what's meant, $6\div(2(1+2))$ if that's what's meant.

-
So there is no defined way to interpret it? – Eric Apr 29 '11 at 10:42
I know it's possible to write it like that, but the whole point of this puzzle is to work out which order the operators are used in, not how it should be written. – Bojangles Apr 29 '11 at 10:51
@JamWaffles: That's a problem of mindreading, not of mathematics. – Hans Lundmark Apr 29 '11 at 11:06
@Hans: Would you mind doing it for me? I'm still learning and it's hard :-( I think the definitive answer to this question is that there isn't one? – Bojangles Apr 29 '11 at 11:14
@JamWaffles, to me the whole point of the "puzzle" is that one person (or piece of software) will have a good reason for following one convention and another will have an equally good reason for following the other convention so the only way to work out the order in which the operators are used is to ask the idiot, excuse me, the person who wrote the silly thing in the first place. Or, as Hans says, it's a problem of mindreading. See also the discussion of the other question which has been deemed to be duplicated by yours. – Gerry Myerson Apr 29 '11 at 11:59