0

This one is a classic, but never-the-less, it's been bothering me since I've read several contradicting answers, yet none of them has convinced me completely. So, how do I properly and correclty calculate functions like this?

So: % refers to division,

6%2(2+1) or 6/2(2+1).

Tohveli
  • 103
  • 1
    Where did you see those answers? Does % mean "modulo"? And how do you define the order of operations for these operations? – Trevor Wilson May 13 '14 at 17:08
  • 2
    Terve! I'm afraid I don't expect this question to live long and prosper here. This is a smaller brother of the near-memetic 48:2(9+3) thread that no self-respecting mathematician will rule on. A quick summary. It is ambiguous. If you have been assigned the task of coding a parser for inline formulas, then you have to do it one way or the other. There is no unanimous correct interpretation. If your teacher gives you this, they should lose their license to teach. – Jyrki Lahtonen May 13 '14 at 17:19
  • 2
    The ÷ symbol needs to be taken out back and shot. – Emily May 13 '14 at 17:35
  • @Arkamis, most indeed! – Tohveli May 13 '14 at 17:38

2 Answers2

2

Taking your expression $6/2(2+1)$, it is clear to do the $2+1$ first because of the parentheses. It is not clear whether the $(2+1)$ belongs in the denominator or the numerator. All the programming languages I have seen would do this as $\frac 62 \cdot (2+1)=3\cdot 3=9$, but we get posts here that clearly intend that it be read as $\frac 6{2(2+1)}=1$. It is not clear without additional parentheses. You should either complain to whoever sent you the expression, or try to determine from context what is meant.

Ross Millikan
  • 374,822
0

$$6 \,\% \,2 \cdot (2+1)= 6 \,\% \, 2 \cdot 3= 3 \cdot3=9$$ $\checkmark$ order of operations

afedder
  • 2,102