# Math question (order of operations)

**URL:** <https://boards.straightdope.com/t/math-question-order-of-operations/633453>\
**Category:** Factual Questions\
**Created:** [September 2, 2012, 5:06pm UTC](https://boards.straightdope.com/t/math-question-order-of-operations/633453 "2012-09-02T17:06:59Z")\
**Posts on this page:** 20\
**Page:** 3

<div class="post-metadata">

**Author:** ![Bytegeist](https://avatars.discourse-cdn.com/v4/letter/b/9dc877/32.png) [@Bytegeist](https://boards.straightdope.com/u/Bytegeist)\
**Post date:** [September 4, 2012, 3:10am UTC](https://boards.straightdope.com/t/math-question-order-of-operations/633453/41 "2012-09-04T03:10:30Z")

</div>

> [@lisiate](#):
>
> The only other order of operations convention that I know of is [Polish notation](http://en.wikipedia.org/wiki/Polish_notation), where the operators are placed to the left of the operands. So 1+2 in conventional notation is expressed as + 1 2.

There’s the mirror image of that: _Reverse_ Polish Notation, also known as “postfix”, where operators follow their operands. RPN is used by some calculators (most famously from Hewlett-Packard), as well as a few computer programming languages like Forth and Postscript.

---

<div class="post-metadata">

**Author:** ![Indistinguishable](https://avatars.discourse-cdn.com/v4/letter/i/90ced4/32.png) [@Indistinguishable](https://boards.straightdope.com/u/Indistinguishable)\
**Post date:** [September 4, 2012, 5:16pm UTC](https://boards.straightdope.com/t/math-question-order-of-operations/633453/42 "2012-09-04T17:16:42Z")

</div>

> [@lisiate](#):
>
> Oh and I think the equation in the OP expressed in Polish notation would be:
> 
> - 6 \* 1 0 + / 2 2

No, this doesn’t work. - 6 \* 1 0 is perfectly meaningful, but then that + comes out of nowhere (and is only given the one argument / 2 2, rather than the two it needs).

Remember, to create Polish notation, just follow the usual “function(argument1, argument2, etc.)” convention in math, then remove all the (superfluous) parentheses and commas. (Or, in other words, write the expression tree, and then transcribe it in preorder traversal)

So the OP’s 6-(1\*0)+(2/2) would become +(-(6, \*(1, 0)), /(2, 2)) = + - 6 \* 1 0 / 2 2.

And the OP’s (6-1)_0+2/2 would become +(_(-(6, 1), 0), /(2, 2)) = + \* - 6 1 0 / 2 2.

[For reverse Polish notation, you do the same thing, but with function names coming _after_ their arguments (i.e., the expression tree in postorder traversal). This is natural in programming because this reflects how computation actually proceeds: first you evaluate the arguments, then you apply the function to them, eventually evaluating the whole expression this way from the bottom-up.

So in reverse Polish notation, the OP’s 6-(1\*0)+(2/2) would become 6 1 0 \* - 2 2 / +, and the OP’s (6-1)\*0+2/2 would become 6 1 - 0 \* 2 2 / +]

---

<div class="post-metadata">

**Author:** ![thelurkinghorror](https://avatars.discourse-cdn.com/v4/letter/t/7c8e57/32.png) [@thelurkinghorror](https://boards.straightdope.com/u/thelurkinghorror)\
**Post date:** [September 4, 2012, 5:30pm UTC](https://boards.straightdope.com/t/math-question-order-of-operations/633453/43 "2012-09-04T17:30:14Z")

</div>

> [@Doug\_K](#):
>
> I have a 30 year old calculator that isn’t a graphing calculator. If I type in 1 + 2 + 3 =
> 
> The display will show as follows:  
> type 1, display shows [1]  
> type +, display shows [1 +]  
> type 2, display shows [2 +]  
> type +, display shows [3 +]  
> type 3, display shows [3 +]  
> type =, display shows [6]
> 
> 1 + 2 X 3 = yields this:
> 
> 1 [1]
> 
> - [1 +]  
> 2 [2 +]  
> X [2 X]  
> 3 [3 X]  
> = [7]

Yes, but it does “let you punch the whole line in,” which to clarify means that it has a memory for what you previously typed in. Cheaper ones just know: 2 numbers and an operator. So it’s like Windows Calculator’s standard mode, not scientific.

---

<div class="post-metadata">

**Author:** ![lisiate](https://avatars.discourse-cdn.com/v4/letter/l/f05b48/32.png) [@lisiate](https://boards.straightdope.com/u/lisiate)\
**Post date:** [September 4, 2012, 9:05pm UTC](https://boards.straightdope.com/t/math-question-order-of-operations/633453/44 "2012-09-04T21:05:01Z")

</div>

> [@Indistinguishable](#):
>
> No, this doesn’t work. - 6 \* 1 0 is perfectly meaningful, but then that + comes out of nowhere (and is only given the one argument / 2 2, rather than the two it needs).
> 
> Remember, to create Polish notation, just follow the usual “function(argument1, argument2, etc.)” convention in math, then remove all the (superfluous) parentheses and commas. (Or, in other words, write the expression tree, and then transcribe it in preorder traversal)
> 
> So the OP’s 6-(1\*0)+(2/2) would become +(-(6, \*(1, 0)), /(2, 2)) = + - 6 \* 1 0 / 2 2.
> 
> And the OP’s (6-1)_0+2/2 would become +(_(-(6, 1), 0), /(2, 2)) = + \* - 6 1 0 / 2 2.
> 
> [For reverse Polish notation, you do the same thing, but with function names coming _after_ their arguments (i.e., the expression tree in postorder traversal). This is natural in programming because this reflects how computation actually proceeds: first you evaluate the arguments, then you apply the function to them, eventually evaluating the whole expression this way from the bottom-up.
> 
> So in reverse Polish notation, the OP’s 6-(1\*0)+(2/2) would become 6 1 0 \* - 2 2 / +, and the OP’s (6-1)\*0+2/2 would become 6 1 - 0 \* 2 2 / +]

You’re right of course, I was unsure about the equation which is why I said “I _think_…”

---

<div class="post-metadata">

**Author:** ![robert\_columbia](https://avatars.discourse-cdn.com/v4/letter/r/e79b87/32.png) [@robert\_columbia](https://boards.straightdope.com/u/robert_columbia)\
**Post date:** [September 4, 2012, 9:31pm UTC](https://boards.straightdope.com/t/math-question-order-of-operations/633453/45 "2012-09-04T21:31:52Z")

</div>

> [@WhyNot](#):
>
> Yep, 7. Not having parentheses doesn’t mean you throw out all the other order of operations, just that you start with exponents. Not having exponents doesn’t mean you throw out all the other order of operations, just that you start with multiplication.
> 
> (We learned it PEMDAS - Parentheses, Exponents, Multiplication, Division, Addition, Subtraction)

Please Excuse My Dear Aunt Sally.

---

<div class="post-metadata">

**Author:** ![tomndebb](https://avatars.discourse-cdn.com/v4/letter/t/b9e5f3/32.png) [@tomndebb](https://boards.straightdope.com/u/tomndebb)\
**Post date:** [March 22, 2015, 3:39am UTC](https://boards.straightdope.com/t/math-question-order-of-operations/633453/46 "2015-03-22T03:39:56Z")

</div>

> [@Rick](#):
>
> This popped up in my Facebook today.  
> 6-1X0+2/2=?  
> Half of the answers say the correct answer is 7 as you do the order of operations with multiplication and division first giving you:  
> 6-(1X0)+(2/2)  
> 6-0+1=7
> 
> The other half of the people say that sans brackets or parentheses you go left to right.  
> (6-1)X0+2/2=1  
> My algebra classes were a loooong time ago, and I’m flat not sure of the correct answer. My first thought was the the latter of the two methods was correct working left to right, but I am not sure.  
> So mathematical dopers, what is the correct answer?

A number of the other answers gave 5.

I am guessing that they resolved the multiplication and division:

6 - 1X0 + 2/2 becomes 6 - 0 + 1

But then carried forward with addition before subtraction:

6 - 0 + 1 where the addition resolves to 1, leaving 6 - 1 = 5.

---

<div class="post-metadata">

**Author:** ![Saint\_Cad](https://sea3.discourse-cdn.com/straightdope/user_avatar/boards.straightdope.com/saint_cad/32/18907_2.png) [@Saint\_Cad](https://boards.straightdope.com/u/Saint_Cad)\
**Post date:** [March 22, 2015, 3:12pm UTC](https://boards.straightdope.com/t/math-question-order-of-operations/633453/47 "2015-03-22T15:12:53Z")

</div>

> [@Indistinguishable](#):
>
> It may be incorrect parsing relative to the orthographic standard, but I hardly see need to call it idiotic…

Really? OoOps is what? 2nd or 3rd grade? If an adult did not know basic primary school English most people would say that’s idiotic

---

<div class="post-metadata">

**Author:** ![LSLGuy](https://sea3.discourse-cdn.com/straightdope/user_avatar/boards.straightdope.com/lslguy/32/5813_2.png) [@LSLGuy](https://boards.straightdope.com/u/LSLGuy)\
**Post date:** [March 22, 2015, 3:29pm UTC](https://boards.straightdope.com/t/math-question-order-of-operations/633453/48 "2015-03-22T15:29:13Z")

</div>

> [@tomndebb](#):
>
> A number of the other answers gave 5.
> 
> I am guessing that they resolved the multiplication and division:
> 
> 6 - 1X0 + 2/2 becomes 6 - 0 + 1
> 
> But then carried forward with addition before subtraction:
> 
> 6 - 0 + 1 where the addition resolves to 1, leaving 6 - 1 = 5.

Good to know after 3 years we finally got \*that \*conundrum resolved. 😃

---

<div class="post-metadata">

**Author:** ![Great\_Antibob](https://avatars.discourse-cdn.com/v4/letter/g/e47c2d/32.png) [@Great\_Antibob](https://boards.straightdope.com/u/Great_Antibob)\
**Post date:** [March 22, 2015, 4:19pm UTC](https://boards.straightdope.com/t/math-question-order-of-operations/633453/49 "2015-03-22T16:19:18Z")

</div>

> [@Saint\_Cad](#):
>
> Really? OoOps is what? 2nd or 3rd grade? If an adult did not know basic primary school English most people would say that’s idiotic

Not the best analogy. It’s more like ending a sentence in a preposition.

Some pedants will try to claim it’s an absolute violation of the laws of English grammar (which don’t really exist either, but that’s a separate matter) while others will take the more sensible and historically sound argument that sentence ending prepositions occur all the time.

As mentioned _ad nauseum_ at this point, there’s no “Academy of Mathematics” that determines absolute rules. We have a few rules of thumb, enforced by nobody in particular, to reduce ambiguity in expressions. But ambiguity still exists.

The “correct” response to this sort of ambiguity, which is not actually addressed by the usual order of operations lessons and if there is a “correct” response at all, is not to blindly rely on non-existent rules but to ask for a clarification from the writer and to gently chide them for writing such an ambiguous expression in the first place.

An equally acceptable but less predictable course of action is to ask your arithmetic teacher the class policy, because the deliberate use of this type of ambiguity is generally as a lesson to a class - in this particularly case a lesson that is unnecessary as the better lesson is to avoid such ambiguities entirely in actual practice.

---

<div class="post-metadata">

**Author:** ![Octarine](https://avatars.discourse-cdn.com/v4/letter/o/22d042/32.png) [@Octarine](https://boards.straightdope.com/u/Octarine)\
**Post date:** [March 22, 2015, 4:24pm UTC](https://boards.straightdope.com/t/math-question-order-of-operations/633453/50 "2015-03-22T16:24:25Z")

</div>

> [@thelurkinghorror](#):
>
> o.O or O.o is Internet speak for a sort of befuddled or surprised expression. Therefore, 0.o.0 is obviously a triclops.

With two mouths! :eek:

---

<div class="post-metadata">

**Author:** ![Pai325](https://avatars.discourse-cdn.com/v4/letter/p/c68b51/32.png) [@Pai325](https://boards.straightdope.com/u/Pai325)\
**Post date:** [March 22, 2015, 4:26pm UTC](https://boards.straightdope.com/t/math-question-order-of-operations/633453/51 "2015-03-22T16:26:37Z")

</div>

> [@Chessic\_Sense](#):
>
> I’ve always wondered this about these threads: Are you guys just abbreviating for the Internet, or do you actually pronounce the word “Pedmas” in your head when you do math? I mean, was there actually a teacher somewhere in your lives that was like “Remember, kids, always follow pedmas when you work out arithmetic.”?
> 
> Because I of course learned O.o.O. in grade school, but until last years I’d never once heard of “PEDMAS” or “BODMAS” or any of these words.

I never said it, but I wrote it on the board.

I said, “Please excuse my dear Aunt Sally.”

The hardest part was getting them to realize that multiplication and division were done in the order you saw them, the same with addition and subtraction. Since “my” came before “dear” in the sentence, they wanted to do all the multiplication before starting the division.

---

<div class="post-metadata">

**Author:** ![tomndebb](https://avatars.discourse-cdn.com/v4/letter/t/b9e5f3/32.png) [@tomndebb](https://boards.straightdope.com/u/tomndebb)\
**Post date:** [March 22, 2015, 10:04pm UTC](https://boards.straightdope.com/t/math-question-order-of-operations/633453/52 "2015-03-22T22:04:30Z")

</div>

> [@LSLGuy](#):
>
> Good to know after 3 years we finally got \*that \*conundrum resolved. 😃

The puzzle was wandering across Facebook, again, yesterday and I found it interesting that it was prevalent in the Facebook responses, yet no one here even considered it.

---

<div class="post-metadata">

**Author:** ![sbunny8](https://avatars.discourse-cdn.com/v4/letter/s/c77e96/32.png) [@sbunny8](https://boards.straightdope.com/u/sbunny8)\
**Post date:** [March 23, 2015, 12:26am UTC](https://boards.straightdope.com/t/math-question-order-of-operations/633453/53 "2015-03-23T00:26:21Z")

</div>

Speaking as a former math teacher, I say the whole Order Of Operations thing is just plain silly. This NEVER comes up in real life, not even the real life of real mathematicians. You will NEVER walk into a meeting between a bunch of mathematicians where one of them says out loud “So my formula is six minus one times zero plus two divided by two” and that person expects everyone listening to magically figure out that the answer is 7. That would be ridiculous.

First of all, the formula would almost certainly contain some letters like a, x, or y, maybe even a Greek letter, not simply a bunch of numerals. Secondly, the formula would almost always be written down, either on a piece of paper, or on a chalk board, or projected on a slide, and the WAY it’s written would give subtle clues about exactly in which order the speaker intended you to do the operations. For example, if the two numbers being multiplied were written very close together, and the number it’s subtracted from is relatively far away, that tells you that the multiplication is more important. Like this…

6 - ab  
given a = 1 and b = 0

It should be obvious from the closeness of the a and b that the person who wrote the formula expects you to multiply them together before subtracting from 6. And if the person had intended for you to do it the other way, s/he would have written…

( 6 - a ) b

so either way, there’d be no confusion, because the parenthesis indicate that the b is not just being multiplied by the a but also by the 6.

And if the person actually was speaking out loud, with no written formula, s/he would use a pause for emphasis, such as “Six minus ay [pause] times bee” instead of “Six minus aybee”.

The whole “order of operations” debate seems to be grounded on the assumption that mathematicians sit around all day trying to think of ways to trick each other into getting wrong answers. The FACT is that people who are doing math, and expect other people to be able to follow along with it, will use a little common sense to clear up any confusion. Only a troll would intentionally write a confusing formula on a chalk board and sit back smugly while everyone struggles to figure out the ambiguities of it. And yet Algebra textbooks seem to want math teachers to do just that, as if the students will be gaining some valuable life skill from it. I say hogwash.

So, my answer to the OP is that if someone wrote down that formula and asked you to figure it out, the correct response would be to find the person who wrote the formula and insist that they clarify it, because they did their job badly.

---

<div class="post-metadata">

**Author:** ![Digital\_is\_the\_new\_Analog](https://avatars.discourse-cdn.com/v4/letter/d/a88e4f/32.png) [@Digital\_is\_the\_new\_Analog](https://boards.straightdope.com/u/Digital_is_the_new_Analog)\
**Post date:** [March 23, 2015, 1:30am UTC](https://boards.straightdope.com/t/math-question-order-of-operations/633453/54 "2015-03-23T01:30:33Z")

</div>

It does come into play in programming.  
In C and C++, you can define symbols like  
#define MY\_SIZE 8  
#define HEADER\_SIZE 4  
#define TOTAL\_SIZE MY\_SIZE + HEADER\_SIZE

That gives us TOTAL\_SIZE as 12. Maybe.  
In code, a rookie might refer to  
TOTAL\_SIZE \* 2  
because they have two of the item. But the way it actually works is we have  
MY\_SIZE + HEADER\_SIZE \* 2  
And because of order of operations, that turns into MY\_SIZE + (HEADER\_SIZE \* 2)  
Which is 16.  
The correct mechanism is to use parens in the define:  
#define TOTAL\_SIZE (MY\_SIZE + HEADER\_SIZE)  
Not understanding how order of operations works, at least from a programming perspective and as defined by the langues, can cause real problems.

---

<div class="post-metadata">

**Author:** ![Saint\_Cad](https://sea3.discourse-cdn.com/straightdope/user_avatar/boards.straightdope.com/saint_cad/32/18907_2.png) [@Saint\_Cad](https://boards.straightdope.com/u/Saint_Cad)\
**Post date:** [March 23, 2015, 2:03am UTC](https://boards.straightdope.com/t/math-question-order-of-operations/633453/55 "2015-03-23T02:03:59Z")

</div>

> [@sbunny8](#):
>
> Speaking as a former math teacher, I say the whole Order Of Operations thing is just plain silly. This NEVER comes up in real life, not even the real life of real mathematicians.

Really? Because as a current math teacher I see this on a daily basis when my students try to parse a complicated calculation (like the amortization of a loan) into their calculator or translating a formula into Excel.

ETA: It is teachers like sbunny that make the students’ job so much harder later on in school.

---

<div class="post-metadata">

**Author:** ![Indistinguishable](https://avatars.discourse-cdn.com/v4/letter/i/90ced4/32.png) [@Indistinguishable](https://boards.straightdope.com/u/Indistinguishable)\
**Post date:** [March 23, 2015, 2:55am UTC](https://boards.straightdope.com/t/math-question-order-of-operations/633453/56 "2015-03-23T02:55:10Z")

</div>

As a mathematician, I’m Team **sbunny8**. Some familiarity with the notational conventions is to be desired. But let’s not give them more significance than they deserve.

---

<div class="post-metadata">

**Author:** ![Indistinguishable](https://avatars.discourse-cdn.com/v4/letter/i/90ced4/32.png) [@Indistinguishable](https://boards.straightdope.com/u/Indistinguishable)\
**Post date:** [March 23, 2015, 3:23am UTC](https://boards.straightdope.com/t/math-question-order-of-operations/633453/57 "2015-03-23T03:23:51Z")

</div>

And, again, this whole stupid unnecessary mess would be avoided if we just wrote expression trees directly!

But, instead, we write arithmetic expressions by A) linearizing them using B) an inorder traversal with C) delimiters generally suppressed, from which disambiguation demands D) a convention such as “order of operations”. If we didn’t do A) [e.g., if we wrote expressions in terms of their tree-structure directly, as we typically do when considering mathematical trees in other contexts], we wouldn’t have any need for the later things. If we didn’t do B) [e.g., if we linearized with consistently pre-order traversal, as we already use for most functions], we wouldn’t have any need for the later things. If we didn’t do C) [e.g., if we linearized with mandatory parentheses around function’s inputs, as we already use for most functions of multiple arguments], there would be nothing to drill schoolchildren and yell at adults over. It’s only because of the combined effect of all of these unnecessarily poor conventions that we’re stuck wasting energy on threads of this sort, when we could be doing actual math (or anything else) instead!

---

<div class="post-metadata">

**Author:** ![Jragon](https://avatars.discourse-cdn.com/v4/letter/j/e19b73/32.png) [@Jragon](https://boards.straightdope.com/u/Jragon)\
**Post date:** [March 23, 2015, 4:45am UTC](https://boards.straightdope.com/t/math-question-order-of-operations/633453/58 "2015-03-23T04:45:38Z")

</div>

Writing ASTs is a tad space inefficient, however. And it wouldn’t play too nicely with computers.

> [@Saint\_Cad](#):
>
> Really? Because as a current math teacher I see this on a daily basis when my students try to parse a complicated calculation (like the amortization of a loan) into their calculator or translating a formula into Excel.
> 
> ETA: It is teachers like sbunny that make the students’ job so much harder later on in school.

As a PhD student in computer science, who reads a lot of papers with pure math (especially probability), I can say that the mathematical community is going to make their job way harder than anything else. I can’t tell you how many times I’ve had to actively reason through an expression to be able to tell whether a summation encompassed the entire expression or just the first term.

---

<div class="post-metadata">

**Author:** ![Derleth](https://avatars.discourse-cdn.com/v4/letter/d/b9e5f3/32.png) [@Derleth](https://boards.straightdope.com/u/Derleth)\
**Post date:** [March 23, 2015, 5:00am UTC](https://boards.straightdope.com/t/math-question-order-of-operations/633453/59 "2015-03-23T05:00:10Z")

</div>

> [@Digital\_is\_the\_new\_Analog](#):
>
> It does come into play in programming.  
> In C and C++, you can define symbols like  
> #define MY\_SIZE 8  
> #define HEADER\_SIZE 4  
> #define TOTAL\_SIZE MY\_SIZE + HEADER\_SIZE
> 
> That gives us TOTAL\_SIZE as 12. Maybe.  
> In code, a rookie might refer to  
> TOTAL\_SIZE \* 2  
> because they have two of the item. But the way it actually works is we have  
> MY\_SIZE + HEADER\_SIZE \* 2  
> And because of order of operations, that turns into MY\_SIZE + (HEADER\_SIZE \* 2)  
> Which is 16.  
> The correct mechanism is to use parens in the define:  
> #define TOTAL\_SIZE (MY\_SIZE + HEADER\_SIZE)  
> Not understanding how order of operations works, at least from a programming perspective and as defined by the langues, can cause real problems.

In programming, if anything is ambiguous, or might be ambiguous, or is just a bit complex, it gets parenthesized out the ass until it is no longer ambiguous. Or at least that’s how it works in any civilized codebase. Only a yahoo memorizes the precedence and associativity rules for C, for example: If you’re making an expression with multiple operators, you parenthesize every sub-expression and chain sub-expressions (and nested sub-expressions) in such a way that the intent is clear, to the compiler, your co-workers, and yourself six months from now.

So more complex versions of PEDMAS are coded into every single compiler and interpreter of every widely-used programming language, but only fools rely on a full knowledge of those rules to make expressions readable. Parentheses are there for a reason.

---

<div class="post-metadata">

**Author:** ![Derleth](https://avatars.discourse-cdn.com/v4/letter/d/b9e5f3/32.png) [@Derleth](https://boards.straightdope.com/u/Derleth)\
**Post date:** [March 23, 2015, 5:05am UTC](https://boards.straightdope.com/t/math-question-order-of-operations/633453/60 "2015-03-23T05:05:03Z")

</div>

> [@Jragon](#):
>
> Writing ASTs is a tad space inefficient, however. And it wouldn’t play too nicely with computers.

If you write your ASTs as parenthesized lists, they play with computers very nicely, and they’re no more space inefficient than any other textual representation of source code.

For example:

```auto

(+
    (* 6 3)
    (* 
        (+ 5 7) 
        (/ 2 
            (+ 7 13))))

```

[Previous page](https://boards.straightdope.com/t/math-question-order-of-operations/633453.md?page=2)

[Next page](https://boards.straightdope.com/t/math-question-order-of-operations/633453.md?page=4)
