Take the 2-minute tour ×
Mathematics Stack Exchange is a question and answer site for people studying math at any level and professionals in related fields. It's 100% free, no registration required.

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 $-$?

share|improve this question
4  
Why is there a vote to close as not a real question? Looks like a question about mathematics to me. –  t.b. Aug 7 '12 at 18:02
    
Verily, this is a real question about expression parsing, which can be delicate matter of interest. –  ncmathsadist Aug 16 '12 at 0:21

5 Answers 5

up vote 9 down vote accepted

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.

share|improve this answer
    
Could be computers automatically removes '-0' someone told me something like that. According to her, -0 represents nothing. –  siniradam Aug 7 '12 at 15:47
    
That would be an error in the code for their parser. We know $-0 = 0$. –  ncmathsadist Aug 7 '12 at 15:57

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

share|improve this answer

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)$.

share|improve this answer

$\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} $$

share|improve this answer

$$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.

share|improve this answer
1  
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. –  DonAntonio Aug 19 '12 at 17:49

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.