-1
$\begingroup$

According to order of operations the answer should be $\mathbf{2}$ But Google and Wolfram calculates as 8

This is last proccess: $5-0+3$

This is how I think: $5-(0+3)$

This is how Google answers: $(5-0)+3$

So, question is which operation is first $+$ or $-$?

$\endgroup$
2
  • 4
    $\begingroup$ Why is there a vote to close as not a real question? Looks like a question about mathematics to me. $\endgroup$
    – t.b.
    Commented Aug 7, 2012 at 18:02
  • $\begingroup$ Verily, this is a real question about expression parsing, which can be delicate matter of interest. $\endgroup$ Commented Aug 16, 2012 at 0:21

5 Answers 5

9
$\begingroup$

You proceed from left to right down the hierarchy. $$5- 0\cdot3 + 9/3 = 5 - 0 + 3 = 5 + 3 = 8.$$ You make the mistake of distributing the $-$ to two terms in the absence of parentheses.

$\endgroup$
2
  • $\begingroup$ Could be computers automatically removes '-0' someone told me something like that. According to her, -0 represents nothing. $\endgroup$
    – siniradam
    Commented Aug 7, 2012 at 15:47
  • $\begingroup$ That would be an error in the code for their parser. We know $-0 = 0$. $\endgroup$ Commented Aug 7, 2012 at 15:57
4
$\begingroup$

The operations + and - have the same priority, therefore google is right: $a - b + c$ is read as $(a-b) + c$.

$\endgroup$
2
$\begingroup$

$\times$ and $\div$ are higher precedence than $+$ and $-$, but each are associated left-to-right. First, the multiplication and division. Next, the leftmost addition/subtraction. Finally, the last addition. $$ \begin{array}{c} 5-\color{#C00000}{0\times3}+\color{#C00000}{9/3}\\ \color{#C00000}{5-0}+3\\ \color{#C00000}{5+3}\\ 8 \end{array} $$

$\endgroup$
1
$\begingroup$

The $0$ is meant to "confuse" but if you write things in a very explicit $+,\times$ only notation it gets clearer:

$$\begin{align} &5-0\times 3+9/3 =\\ &5 + (-1)\times 0\times 3 + 9/3 =\\ & 5 + 0 + 3 = 8 \end{align}$$

Remember that $a-b$ is actually $a+(-1)b$, and multiplication takes precedence over addition, so $(-1)\times 0 + 3$ is not the same as $(-1)\times(0+3)$.

$\endgroup$
0
$\begingroup$

$$5-(0+3)=5-0-3=2$$ but $$(5-0)+3=5-0+3=8$$ There's no priority between $+$ and $-$, but most people prefer to start from right to do the calculation.

$\endgroup$
1
  • 2
    $\begingroup$ As far as I always knew (and I haven't taught this stuff since my last kid was in junior high), the order between product/division and sum-substraction gets determined from left to right. $\endgroup$
    – DonAntonio
    Commented Aug 19, 2012 at 17:49

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .