# calculators giving different answers

**URL:** <https://boards.straightdope.com/t/calculators-giving-different-answers/469325>\
**Category:** Factual Questions\
**Created:** [October 24, 2008, 9:34am UTC](https://boards.straightdope.com/t/calculators-giving-different-answers/469325 "2008-10-24T09:34:04Z")\
**Posts on this page:** 20\
**Page:** 2

<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:** [October 24, 2008, 6:49pm UTC](https://boards.straightdope.com/t/calculators-giving-different-answers/469325/21 "2008-10-24T18:49:38Z")

</div>

> [@Chronos](#):
>
> The title Esq. (Esquire) after a name usually indicates a lawyer, in the US at least.

Indeed, although I believe **Thudlow Boink** is pointing out that Fermat was both a lawyer and a mathematician.

---

<div class="post-metadata">

**Author:** ![GargoyleWB](https://sea3.discourse-cdn.com/straightdope/user_avatar/boards.straightdope.com/gargoylewb/32/199_2.png) [@GargoyleWB](https://boards.straightdope.com/u/GargoyleWB)\
**Post date:** [October 24, 2008, 7:00pm UTC](https://boards.straightdope.com/t/calculators-giving-different-answers/469325/22 "2008-10-24T19:00:34Z")

</div>

> [@shijinn](#):
>
> oh btw, when i keyed the question in Google it forced the question to display as (8/2)\*(5-3). heh.

Yes, I love Google calculator. However, I wish it would also helpfully display, in the same manner, its preference for degrees vs radians, or other units.

Google’s outputs are either (depending if you specify degrees or not)

sin(45) = 0.850903525  
sin(45 degrees) = 0.707106781

_insert preemptive “shut up” to radians-being-non-dimensioned pedantry sure to follow_

It is equally awkward and unhelpful when trying to convert between bases (binary to decimal to octal, and such) unless I monkey with testing known results to deduce what defaults it likes.

Now, one might say “Gargoyle, get a real calculator to crunch engineering math”. But when I’m in an airport and all I’ve got is my Nintendo DSLite or a rentacomputer, I’d like access to something nice and Googly for math beyond basic arithmetic.

---

<div class="post-metadata">

**Author:** ![Bad\_Astronaut](https://avatars.discourse-cdn.com/v4/letter/b/e19adc/32.png) [@Bad\_Astronaut](https://boards.straightdope.com/u/Bad_Astronaut)\
**Post date:** [October 24, 2008, 9:44pm UTC](https://boards.straightdope.com/t/calculators-giving-different-answers/469325/23 "2008-10-24T21:44:08Z")

</div>

I tried it in my Casio fx-991MS and also got 2. The calculator places implicit multiplication of a quantity in parentheses above explicit multiplication and division in its order of operations.

Seems reasonable, because normally the only reason you would place a number outside of parentheses with no operator is if your intention was to immediately multiply it.

---

<div class="post-metadata">

**Author:** ![DSYoungEsq](https://avatars.discourse-cdn.com/v4/letter/d/c6cbf5/32.png) [@DSYoungEsq](https://boards.straightdope.com/u/DSYoungEsq)\
**Post date:** [October 24, 2008, 9:58pm UTC](https://boards.straightdope.com/t/calculators-giving-different-answers/469325/24 "2008-10-24T21:58:01Z")

</div>

> [@CookingWithGas](#):
>
> If I’m not mistaken
> 
> There is only one correct possibility based on order of operations, the way this is actually written. Your first example is the only way to interpret it and that’s how any programming language would do it (although they need an explicit multiplication symbol). If it had been written as in your second example, the result would be different, but that’s not how it was written.

Excuse me?

8/2\*(5-3) as written, using proper order of operations, would be resolved in the following sequence:

8/2\*(5-3)

8/2\*2

8/4

2

This is because you resolve the multiplication before you resolve the division, to eliminate the otherwise ambiguous nature of the symbol for division.

And no, not “every” programming language would resolve them your way. But the TI-83 says “8”.

(To answer the question about “Esq”, I used to work as an attorney (still licensed in one state), but I’ve moved on to better things. 🙂 )

---

<div class="post-metadata">

**Author:** ![Thudlow\_Boink](https://sea3.discourse-cdn.com/straightdope/user_avatar/boards.straightdope.com/thudlow_boink/32/320_2.png) [@Thudlow\_Boink](https://boards.straightdope.com/u/Thudlow_Boink)\
**Post date:** [October 24, 2008, 11:09pm UTC](https://boards.straightdope.com/t/calculators-giving-different-answers/469325/25 "2008-10-24T23:09:14Z")

</div>

> [@DSYoungEsq](#):
>
> 8/2\*2
> 
> 8/4
> 
> 2
> 
> This is because you resolve the multiplication before you resolve the division, to eliminate the otherwise ambiguous nature of the symbol for division.

Do you have a cite for this?

Because the way all the beginning algebra textbooks I’ve seen explain the rule for the order of operations, “multiplication and division, in order from left to right” is a single step. And my scientific calculator interprets “8 / 2 x 2” as 8.

(And yes, Fermat is the name that springs to mind when I think of a “a lawyer, though one with a marked interest in math.”)

---

<div class="post-metadata">

**Author:** ![Tenebras](https://avatars.discourse-cdn.com/v4/letter/t/977dab/32.png) [@Tenebras](https://boards.straightdope.com/u/Tenebras)\
**Post date:** [October 24, 2008, 11:56pm UTC](https://boards.straightdope.com/t/calculators-giving-different-answers/469325/26 "2008-10-24T23:56:35Z")

</div>

> [@CookingWithGas](#):
>
> There is only one correct possibility based on order of operations, the way this is actually written. Your first example is the only way to interpret it and that’s how any programming language would do it (although they need an explicit multiplication symbol). If it had been written as in your second example, the result would be different, but that’s not how it was written.

It’s not how any programming language would interpret it. In fact, it’s not even how every calculator would interpret it. According to wiki because I don’t own any calculators,

> [@](#):
>
> An expression like 1/2x is interpreted as 1/(2x) by TI-82, but as (1/2)x by TI-83.

Now, I think this makes more sense because, as I stated, if you wanted x/2 you should have written x/2. The order of keying into an RPN calculator assumes that you are smarter than the machine and will tell it what you want. TI-82 also seems to do so.

Now that’s fine that algebra text books say to do one thing, but I maintain that it is ambiguous. In fact, the number one hit when I searched “order of operations algebra” in Google was [this page](http://www.math.com/school/subject2/lessons/S2U1L2DP.html) which contains the following gem:

> [@](#):
>
> Working from left to right, do all multiplications and divisions. When there are several of these operations in the same term, the order within the term doesn’t matter.

which is certainly not true. :mad:

---

<div class="post-metadata">

**Author:** ![UncleRojelio](https://sea3.discourse-cdn.com/straightdope/user_avatar/boards.straightdope.com/unclerojelio/32/3160_2.png) [@UncleRojelio](https://boards.straightdope.com/u/UncleRojelio)\
**Post date:** [October 25, 2008, 12:25am UTC](https://boards.straightdope.com/t/calculators-giving-different-answers/469325/27 "2008-10-25T00:25:20Z")

</div>

> [@DSYoungEsq](#):
>
> This is because you resolve the multiplication before you resolve the division, to eliminate the otherwise ambiguous nature of the symbol for division.

This statement is false.

---

<div class="post-metadata">

**Author:** ![Q.E.D](https://avatars.discourse-cdn.com/v4/letter/q/51bf81/32.png) [@Q.E.D](https://boards.straightdope.com/u/Q.E.D)\
**Post date:** [October 25, 2008, 12:29am UTC](https://boards.straightdope.com/t/calculators-giving-different-answers/469325/28 "2008-10-25T00:29:26Z")

</div>

> [@UncleRojelio](#):
>
> This statement is false.

_cybernetic head asplodes_

---

<div class="post-metadata">

**Author:** ![The\_Hamster\_King](https://avatars.discourse-cdn.com/v4/letter/t/8edcca/32.png) [@The\_Hamster\_King](https://boards.straightdope.com/u/The_Hamster_King)\
**Post date:** [October 25, 2008, 12:54am UTC](https://boards.straightdope.com/t/calculators-giving-different-answers/469325/29 "2008-10-25T00:54:07Z")

</div>

> [@UncleRojelio](#):
>
> Hurray for RPN!!

Agreed. Parentheses are a kludge.

---

<div class="post-metadata">

**Author:** ![Thudlow\_Boink](https://sea3.discourse-cdn.com/straightdope/user_avatar/boards.straightdope.com/thudlow_boink/32/320_2.png) [@Thudlow\_Boink](https://boards.straightdope.com/u/Thudlow_Boink)\
**Post date:** [October 25, 2008, 10:46am UTC](https://boards.straightdope.com/t/calculators-giving-different-answers/469325/30 "2008-10-25T10:46:51Z")

</div>

> [@Tenebras](#):
>
> In fact, the number one hit when I searched “order of operations algebra” in Google was [this page](http://www.math.com/school/subject2/lessons/S2U1L2DP.html) which contains the following gem:  
> which is certainly not true. :mad:

Oof, that’s horrible! Yeah, it doesn’t matter in their specific example, but only because the division is last.

---

<div class="post-metadata">

**Author:** ![CookingWithGas](https://sea3.discourse-cdn.com/straightdope/user_avatar/boards.straightdope.com/cookingwithgas/32/485_2.png) [@CookingWithGas](https://boards.straightdope.com/u/CookingWithGas)\
**Post date:** [October 25, 2008, 11:08pm UTC](https://boards.straightdope.com/t/calculators-giving-different-answers/469325/31 "2008-10-25T23:08:47Z")

</div>

> [@Tenebras](#):
>
> It’s not how any programming language would interpret it. In fact, it’s not even how every calculator would interpret it. According to wiki because I don’t own any calculators,

Every language I’ve used requires the \* for multiplication and will raise a syntax error if you write

8/2(5-3)

If you make the multiplication explicit like this

8/2\*(5-3)

the following languages, off the top of my head, apply division and multiplication at the same level from left to right and would render an 8:

Ada  
C  
C++  
Excel  
Fortran  
Java  
PL/1  
VBA  
SNOBOL  
VBA

Please cite one that won’t. Calculators are another issue because they can interpret an implied multiplication, and may give a higher precedence to implied mulitiplication than explicit multiplication, which I still believe is erroneous.

I don’t think Wikipedia is an authoritative source on this.

---

<div class="post-metadata">

**Author:** ![Tenebras](https://avatars.discourse-cdn.com/v4/letter/t/977dab/32.png) [@Tenebras](https://boards.straightdope.com/u/Tenebras)\
**Post date:** [October 26, 2008, 1:28am UTC](https://boards.straightdope.com/t/calculators-giving-different-answers/469325/32 "2008-10-26T01:28:44Z")

</div>

> [@CookingWithGas](#):
>
> Every language I’ve used requires the \* for multiplication and will raise a syntax error if you write
> 
> 8/2(5-3)
> 
> If you make the multiplication explicit like this
> 
> 8/2\*(5-3)
> 
> the following languages, off the top of my head, apply division and multiplication at the same level from left to right and would render an 8:
> 
> Ada  
> C  
> C++  
> Excel  
> Fortran  
> Java  
> PL/1  
> VBA  
> SNOBOL  
> VBA
> 
> Please cite one that won’t. Calculators are another issue because they can interpret an implied multiplication, and may give a higher precedence to implied mulitiplication than explicit multiplication, which I still believe is erroneous.
> 
> I don’t think Wikipedia is an authoritative source on this.

APL evaluates everything from right to left in order. You still need an explicit multiplication, of course, but 8/2\*(5-3) would be evaluated as 8/(2\*(5-3)) = 2. In fact, without parentheses 8/2\*5-2 gives the exact same result.

Not the tech manual, but a description of the syntax can be found [here](http://www.mactech.com/articles/mactech/Vol.01/01.12/APL/index.html):

> [@](#):
>
> The next difficulty is the syntax. There is no hierarchy of operators - all APL expressions are evaluated from right to left. If you need to change the order of operation, you must use parentheses. For example, the expression 5-6-2 is equivalent to 5-(6-2) = 1 in APL, not (5-6)-2 = -3 as in most languages. And 5x6-2 equals 20, not 28.

The reason the language interprets everything right to left and in order is that it is based around an idea of functions rather than operations.  
The “order of operations” isn’t something which is a fundamental truth of mathematics. It’s just a convention. Sometimes it comes into conflict with the conventions for typing things. When writing longhand, especially when space is tight, it would not be ambiguous to write 8/2(5-3) to instead of 2. Especially if you did something more like [sup]8[/sup]/[sub]2(5-3)[/sub]. It’s certainly more convenient if your calculator can interpret 8/2(5-3) or 8/2\*(5-3) as 2, because it avoids an explosion of parentheses. Anytime you needed 4 you could just write 8\*(5-3)/2 and be done with it.  
As for which is “right” well, it’s all just convention. Should punctuation go inside or outside of quotation marks? Depends on which side of the Atlantic you’re on. Both conventions have their merits.

By the way, what does Excel return when you input =-1^2 what about =1-2^2 or =1±2^2? Are those answers right or wrong?

---

<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:** [October 26, 2008, 1:31am UTC](https://boards.straightdope.com/t/calculators-giving-different-answers/469325/33 "2008-10-26T01:31:21Z")

</div>

> [@Tenebras](#):
>
> The reason the language interprets everything right to left and in order is that it is based around an idea of functions rather than operations.

I’m a bit confused; what do you mean by this?

---

<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:** [October 26, 2008, 1:39am UTC](https://boards.straightdope.com/t/calculators-giving-different-answers/469325/34 "2008-10-26T01:39:08Z")

</div>

> [@Pochacco](#):
>
> Agreed. Parentheses are a kludge.

Only if they’re only required sometimes in ill-defined circumstances. If they’re always needed you can have functions with variable arity without needing arbitrary kludges to delimit how many operands they consume. Plus, parenthesizing everything means your source code is a trivial representation of a parse tree, so making real macros (functions that apply arbitrary transformations to parse trees) is easy.

If you need a concrete example, look at Lisp and Scheme.

A middle path is to use APL rules: _Everything_ is evaluated right to left unless parentheses explicitly force another ordering. So 5_6+3 == 5_9 == 45, but (5_6)+3 == 30+3 == 33. Nobody likes APL-like languages enough to apply this to any other family of languages, so it will make people scream because it looks normal until 5_6+3 evaluates to 45. 😉

---

<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:** [October 26, 2008, 1:46am UTC](https://boards.straightdope.com/t/calculators-giving-different-answers/469325/35 "2008-10-26T01:46:42Z")

</div>

> [@Indistinguishable](#):
>
> I’m a bit confused; what do you mean by this?

Because functions are evaluated right-to-left when written in the usual fashion: f(g(h(x))) evaluates h(x) first, then feeds the result to g(), then feeds the result to f(); f(), the leftmost function, is evaluated last.

APL-like languages seem to sit in an uncomfortable position between traditional infix (their syntax) and functional (their semantics), because Ken Iverson wanted a mathematical notation that was unambiguous and (presumably) didn’t like parentheses all that much.

---

<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:** [October 26, 2008, 2:35am UTC](https://boards.straightdope.com/t/calculators-giving-different-answers/469325/36 "2008-10-26T02:35:15Z")

</div>

> [@Derleth](#):
>
> Because functions are evaluated right-to-left when written in the usual fashion: f(g(h(x))) evaluates h(x) first, then feeds the result to g(), then feeds the result to f(); f(), the leftmost function, is evaluated last.

Oh. I suppose that’s true. Though, when written in the usual fashion, there’s also so many parentheses around that there isn’t even any potential ambiguity. But, yeah, I can understand the motivation of taking that convention and just removing the necessity of the parentheses.

I’m, of course, used to languages like Haskell, where currying is so ubiquitous that the traditional function-on-left, argument-on-right convention actually leads to the opposite decision, to left-associate by default (so that one might define a function “add” with the property that add 1 2 = (add 1) 2 = (the function which adds 1 to its argument) 2 = 3, rather than having add 1 2 = add (1 2) = add (the result of applying 1 to 2?) = add (WTF?) = death.

---

<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:** [October 26, 2008, 2:41am UTC](https://boards.straightdope.com/t/calculators-giving-different-answers/469325/37 "2008-10-26T02:41:26Z")

</div>

I forgot to close a parenthesis there. I am duly chagrined.

---

<div class="post-metadata">

**Author:** ![Tenebras](https://avatars.discourse-cdn.com/v4/letter/t/977dab/32.png) [@Tenebras](https://boards.straightdope.com/u/Tenebras)\
**Post date:** [October 26, 2008, 3:57pm UTC](https://boards.straightdope.com/t/calculators-giving-different-answers/469325/38 "2008-10-26T15:57:28Z")

</div>

What Derleth said, although I’d say that fgh(x) is more usual than f(g(h(x))), just because the latter is so much more difficult to read.

And the reason you think 5\*6+3 should be 33 is just because they told you so in elementary school. Lots of stuff they told you in school turned out to be wrong. 😉

---

<div class="post-metadata">

**Author:** ![shijinn](https://avatars.discourse-cdn.com/v4/letter/s/cc9497/32.png) [@shijinn](https://boards.straightdope.com/u/shijinn)\
**Post date:** [October 26, 2008, 6:41pm UTC](https://boards.straightdope.com/t/calculators-giving-different-answers/469325/39 "2008-10-26T18:41:49Z")

</div>

i think i understand the point about conventions and that either answer might be correct depending. but, judging from the reactions so far, can someone spell out exactly why the BODMAS rule for order of operations is so, so “brains splattering on the pavement” wrong? and considering that it doesn’t seem to have a use outside of its own topic in primary school, why is it taught at all?

you would think Maths is the one subject where the rules would not change with the playing field.

---

<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:** [October 26, 2008, 6:49pm UTC](https://boards.straightdope.com/t/calculators-giving-different-answers/469325/40 "2008-10-26T18:49:30Z")

</div>

> [@shijinn](#):
>
> i think i understand the point about conventions and that either answer might be correct depending. but, judging from the reactions so far, can someone spell out exactly why the BODMAS rule for order of operations is so, so “brains splattering on the pavement” wrong? and considering that it doesn’t seem to have a use outside of its own topic in primary school, why is it taught at all?

It’s not that wrong. It is the convention almost everywhere you go. But sometimes it’s not.

[Previous page](https://boards.straightdope.com/t/calculators-giving-different-answers/469325.md?page=1)
