# How does a calculator do trickier calculations?

**URL:** https://boards.straightdope.com/t/how-does-a-calculator-do-trickier-calculations/182536
**Category:** Factual Questions
**Created:** [June 17, 2003, 8:20pm UTC](https://boards.straightdope.com/t/how-does-a-calculator-do-trickier-calculations/182536 "2003-06-17T20:20:13Z")
**Posts on this page:** 20
**Page:** 2

<div class="post-metadata">

### Author: ![iamthewalrus\_3](https://avatars.discourse-cdn.com/v4/letter/i/258eb7/32.png) [@iamthewalrus\_3](https://boards.straightdope.com/u/iamthewalrus_3)
#### Post date: [June 17, 2003, 11:11pm UTC](https://boards.straightdope.com/t/how-does-a-calculator-do-trickier-calculations/182536/21 "2003-06-17T23:11:58Z")

</div>

Calculators work the way they do because of tradition. Sure, **William\_Ashbless** , you can write a program like that _now_, that will work on a standard calculator. Could you write one that would work on the standard calculator 10 years ago? 20? 40? What happens when your arbitrary program overflows the stack on those? What happens when there isn’t a stack at all? Cheap calculators work like they do because they used to _have_ to work like that. And there are people who have used calculators that long and expect them to work the same.

Plus, let’s say that I’ve input some expression that evaluates to 4568, for example, then I realize that, actually, I overcounted. What I really want is 1/4 of that. If I hit / 4, I want to get 1/4 of what’s on the screen, not the correct interpretation of the entire expression by the order of operation rules. If the screen is only large enough to display the last result, then that should be the only information the calculator has, too. If it’s large enough to display the expression and the result (as nicer ones are), then it will use that information. Just as it should, obviously, be, to the naive observer.

---

<div class="post-metadata">

### Author: ![yabob](https://sea3.discourse-cdn.com/straightdope/user_avatar/boards.straightdope.com/yabob/32/2821_2.png) [@yabob](https://boards.straightdope.com/u/yabob)
#### Post date: [June 17, 2003, 11:12pm UTC](https://boards.straightdope.com/t/how-does-a-calculator-do-trickier-calculations/182536/22 "2003-06-17T23:12:40Z")

</div>

Typo, sorry - I meant to say 2\*3+4 = 14. (3+4 first, = 7. 7 \* 2 = 14).

---

<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: [June 17, 2003, 11:12pm UTC](https://boards.straightdope.com/t/how-does-a-calculator-do-trickier-calculations/182536/23 "2003-06-17T23:12:46Z")

</div>

All my calculators correctly solve 2+3\*4=14. Well, 7 of them, anyway. The 8th one has dead batteries, but I’ll assume it will do so as well. Apparently scientific calculators are programmed better than your average dollar-store special.

To those arguing with **Whack-A-Mole** about order of operations: cut it out. He’s correct. Any mathematician who sees “2 + 3 x 4 = \_\_” on a blackboard and writes “20” oughta get himself bitch-slapped. They didn’t drill “Please Excuse My Dear Aunt Sally” into my skull because it was fun.

Incidentally for more calculator weirdness, eter “3.141592654 - pi”. You get a result similar to 4.E-10. or maybe 4.102 E-10. This is because the calculator stores the value as pi with more than the 7 decimal digits displayed.

---

<div class="post-metadata">

### Author: ![Whack-a-Mole](https://sea3.discourse-cdn.com/straightdope/user_avatar/boards.straightdope.com/whack-a-mole/32/141_2.png) [@Whack-a-Mole](https://boards.straightdope.com/u/Whack-a-Mole)
#### Post date: [June 17, 2003, 11:20pm UTC](https://boards.straightdope.com/t/how-does-a-calculator-do-trickier-calculations/182536/24 "2003-06-17T23:20:30Z")

</div>

> [@](#):
>
> _Originally posted by MC Master of Ceremonies \*  
> \*\*Actually, you get 14 if you type ‘2’, ‘+’, ‘3’, '_’, ‘4’ ‘=’ onto a standard calculator anyway, it’s only if you type ‘2’, ‘+’, ‘3’, ‘=’, ‘\*’, ‘4’, ‘=’ you get 20. \*\*

No doubt some calculators do it correctly…as they all should. Many still give you “20” as an answer though as the Windows Standard Mode calulator will attest to.

---

<div class="post-metadata">

### Author: ![MC\_Master\_of\_Ceremonies](https://avatars.discourse-cdn.com/v4/letter/m/bb73d2/32.png) [@MC\_Master\_of\_Ceremonies](https://boards.straightdope.com/u/MC_Master_of_Ceremonies)
#### Post date: [June 17, 2003, 11:25pm UTC](https://boards.straightdope.com/t/how-does-a-calculator-do-trickier-calculations/182536/25 "2003-06-17T23:25:24Z")

</div>

When I said a “standard calculator”, I actually meant a “standard scientific calculator”.

---

<div class="post-metadata">

### Author: ![kanicbird](https://avatars.discourse-cdn.com/v4/letter/k/5f8ce5/32.png) [@kanicbird](https://boards.straightdope.com/u/kanicbird)
#### Post date: [June 17, 2003, 11:32pm UTC](https://boards.straightdope.com/t/how-does-a-calculator-do-trickier-calculations/182536/26 "2003-06-17T23:32:35Z")

</div>

Actually I vaguly recall a calculator manual that stated that equations must be converted as I stated above for you to get the correct answer. Also the Palm OS calculator gives the answer as 2+3\*4 = 20 FWIM, got a palm by any chance \*\*William\_Ashbless  
\*\*?

> [@](#):
>
> Is it just me or shoud the calculator be made to conform to accepted mathematic principles laid down over thousands of years rather than adjusting mathematics to comply with how the calculator wants it done?

I would guess the reason for this is that is was simpler for a calculator to be programed this way when they 1st came out - maybe the only way to make them affordable at the time, and people now expect them to work that way.

> [@](#):
>
> Is it just me or shoud the calculator be made to conform to accepted mathematic principles laid down over thousands of years rather than adjusting mathematics to comply with how the calculator wants it done?

Perhaps you expect your washing machine to go down to the river and beat your cloths on some rocks?

---

<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: [June 18, 2003, 1:43am UTC](https://boards.straightdope.com/t/how-does-a-calculator-do-trickier-calculations/182536/27 "2003-06-18T01:43:13Z")

</div>

Calculators come in several basic species. The really simple four-function calculators that you can get for a dollar or two, that just add, subtract, multiply, and divide, and maybe do square roots, but nothing fancier— **all** of these, as far as I have seen, perform arithmetic operations in exactly the order they’re keyed in, without regard to the algebraic rules about order of operations. (The calculator **doesn’t** see “2+3\*4”; it only sees one thing at a time: first the 2, then the +, etc.) Windows’ calculator’s Standard mode is an emulation of these simple cheapo calculators.

Then you have your scientific calculators. These are the ones that can do exponents, logs, trig functions, parentheses, and whatever else is built into them. These, without exception, do know and follow the algebraic rules for order of operations.

So basically, I’m agreeing with **NormanConquest** here: the cheapo calculators aren’t _wrong_, they’re just designed to perform a different task: to do individual operations rather than to evaluate expressions.

---

<div class="post-metadata">

### Author: ![Shade](https://avatars.discourse-cdn.com/v4/letter/s/2bfe46/32.png) [@Shade](https://boards.straightdope.com/u/Shade)
#### Post date: [June 18, 2003, 1:52am UTC](https://boards.straightdope.com/t/how-does-a-calculator-do-trickier-calculations/182536/28 "2003-06-18T01:52:57Z")

</div>

Just because a calculator doesn’t use the standard mathematical notation doesn’t mean it’s wrong. It may be less convenient, but OTOH, sometimes it’s more convenient to use “from left to right” or reverse polish evaluations.

Written calculations use by default the standard operator ordering, but unless the calculator writes out “2+3\*4” on the screen, I don’t think it’s unreasonable to use a different method, provided this is made clear. Now we are settling on a convention that they do use the standard notation, which is great, but they didn’t always, often for fairly good reasons (I guess)

---

<div class="post-metadata">

### Author: ![LtningBug](https://avatars.discourse-cdn.com/v4/letter/l/73ab20/32.png) [@LtningBug](https://boards.straightdope.com/u/LtningBug)
#### Post date: [June 18, 2003, 5:03am UTC](https://boards.straightdope.com/t/how-does-a-calculator-do-trickier-calculations/182536/29 "2003-06-18T05:03:53Z")

</div>

> [@](#):
>
> \*Originally posted by Q.E.D. \*  
> \*\*Incidentally for more calculator weirdness, eter “3.141592654 - pi”. You get a result similar to 4.E-10. or maybe 4.102 E-10. This is because the calculator stores the value as pi with more than the 7 decimal digits displayed. \*\*

The TI-92 uses 12 digits internally but only displays 10 digits. This is so internal rounding doesn’t affect the displayed number.

---

<div class="post-metadata">

### Author: ![SlickRoenick](https://avatars.discourse-cdn.com/v4/letter/s/e68b1a/32.png) [@SlickRoenick](https://boards.straightdope.com/u/SlickRoenick)
#### Post date: [June 18, 2003, 5:55am UTC](https://boards.straightdope.com/t/how-does-a-calculator-do-trickier-calculations/182536/30 "2003-06-18T05:55:22Z")

</div>

> [@](#):
>
> \*Originally posted by Whack-a-Mole \*  
> \*\*According to the rules of the calculator? Is it just me or shoud the calculator be made to conform to accepted mathematic principles laid down over thousands of years rather than adjusting mathematics to comply with how the calculator wants it done?
> 
> Again…I understand that as a practical matter the 2+3\*4=20 on a calculator is here to stay but I don’t care how you slice it…that is still a wrong answer. \*\*

Does this ultimately boil down to the simplistic nature of a calculator? It can do 1 thing at a time and does it in the order you tell it, just like a person. You enter:  
you enter–calculator thinks  
2----------ok, i will start with 2  
±---------now i have to add something to 2  
3----------2+3, simple enough it’s 5  
_----------now i gotta do 5 times something  
4----------5_4 is an even 20–i’m smart

---

<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: [June 18, 2003, 6:02am UTC](https://boards.straightdope.com/t/how-does-a-calculator-do-trickier-calculations/182536/31 "2003-06-18T06:02:47Z")

</div>

> [@](#):
>
> \*Originally posted by Muldoon III \*  
> \*\*Does this ultimately boil down to the simplistic nature of a calculator? It can do 1 thing at a time and does it in the order you tell it, just like a person. You enter:  
> you enter–calculator thinks  
> 2----------ok, i will start with 2  
> ±---------now i have to add something to 2  
> 3----------2+3, simple enough it’s 5  
> _----------now i gotta do 5 times something  
> 4----------5_4 is an even 20–i’m smart \*\*

Well, yes. But all the scientific calculators I have seem to do it this way:

[list]  
Ok, you entered 2. Cool.  
Now you want to add something to that. Ok, keep your shirt on.  
3? ok, but that’s not what i would have picked.  
Ohhhh, multiplication!  
Times 4? Ok, then.  
At last!  
The eq

---

<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: [June 18, 2003, 6:06am UTC](https://boards.straightdope.com/t/how-does-a-calculator-do-trickier-calculations/182536/32 "2003-06-18T06:06:35Z")

</div>

> [@](#):
>
> \*Originally posted by Muldoon III \*  
> \*\*Does this ultimately boil down to the simplistic nature of a calculator? It can do 1 thing at a time and does it in the order you tell it, just like a person. You enter:  
> you enter–calculator thinks  
> 2----------ok, i will start with 2  
> ±---------now i have to add something to 2  
> 3----------2+3, simple enough it’s 5  
> _----------now i gotta do 5 times something  
> 4----------5_4 is an even 20–i’m smart \*\*

Well, yes. But all the scientific calculators I have seem to do it this way:

[ul]  
Ok, you entered 2. Cool.  
Now you want to add something to that. Ok, keep your shirt on.  
3? ok, but that’s not what i would have picked.  
Ohhhh, multiplication!  
Times 4? Ok, then.  
At last!  
The equals key!  
OK, hold on while I evaluate the entries: 2 + 3 \* 4 = 2 + (3 \* 4) = 2 + 12 = 14.  
Yay!  
[/ul]

---

<div class="post-metadata">

### Author: ![sailor](https://avatars.discourse-cdn.com/v4/letter/s/a587f6/32.png) [@sailor](https://boards.straightdope.com/u/sailor)
#### Post date: [June 18, 2003, 7:15am UTC](https://boards.straightdope.com/t/how-does-a-calculator-do-trickier-calculations/182536/33 "2003-06-18T07:15:07Z")

</div>

To insist that a calculator has to follow the rules established for a written equation is just silly. A calculator is expected to calculate as it goes along which you are not expected to do as you write. They are different things and both valid as long as you are aware of the rules to be followed. My scientific Casio fx-17 gives the result as 20 and I have no problem with that. A calculator is a useful tool as long as you understand how it works.

---

<div class="post-metadata">

### Author: ![Desmostylus](https://avatars.discourse-cdn.com/v4/letter/d/c57346/32.png) [@Desmostylus](https://boards.straightdope.com/u/Desmostylus)
#### Post date: [June 18, 2003, 9:29am UTC](https://boards.straightdope.com/t/how-does-a-calculator-do-trickier-calculations/182536/34 "2003-06-18T09:29:44Z")

</div>

I use either HPs, or cheap $5 calculators. Both do exactly what I expect, i.e. perform a calculation as soon as I hit an operator key.

The other kind (TIs, etc.) shit me to tears.

_I_ know what the operator precedence is, I don’t want the calculator second guessing me.

---

<div class="post-metadata">

### Author: ![SlickRoenick](https://avatars.discourse-cdn.com/v4/letter/s/e68b1a/32.png) [@SlickRoenick](https://boards.straightdope.com/u/SlickRoenick)
#### Post date: [June 18, 2003, 9:52am UTC](https://boards.straightdope.com/t/how-does-a-calculator-do-trickier-calculations/182536/35 "2003-06-18T09:52:05Z")

</div>

> [@](#):
>
> \*Originally posted by Q.E.D. \*  
> \*\*Well, yes. But all the scientific calculators I have seem to do it this way:
> 
> [ul]  
> Ok, you entered 2. Cool.  
> Now you want to add something to that. Ok, keep your shirt on.  
> 3? ok, but that’s not what i would have picked.  
> Ohhhh, multiplication!  
> Times 4? Ok, then.  
> At last!  
> The equals key!  
> OK, hold on while I evaluate the entries: 2 + 3 \* 4 = 2 + (3 \* 4) = 2 + 12 = 14.  
> Yay!  
> [/ul] \*\*

Scientific calculators (AFAIK) and graphing calculators do wait until the = key (or enter) is pressed before running the PEMDAS (please excuse my dead aunt sally) process. But just a regular desk calculator only does 1 piece of the puzzle at a time in the order it is punched. It was kinda off topic but that was the effect i was going for. I do understand what you’re saying though.

---

<div class="post-metadata">

### Author: ![William\_Ashbless](https://avatars.discourse-cdn.com/v4/letter/w/a87d85/32.png) [@William\_Ashbless](https://boards.straightdope.com/u/William_Ashbless)
#### Post date: [June 18, 2003, 2:17pm UTC](https://boards.straightdope.com/t/how-does-a-calculator-do-trickier-calculations/182536/36 "2003-06-18T14:17:02Z")

</div>

My calculator is ‘scientific’ in that it … well, says so on the case. Dn’t know the model number off the top of my head. Not really the point.

All of the calculators I have had have properly done the… bedmas/pedmas, pemdas, whatever… process.

But I’m a cheap bastard and have yet to buy a calculator that stores up an entire equation, waiting for the = to be hit to calculate.

All of the calculators I have owned have behaved this way. They calculate-as-they-go, but they still obey the proper order of operations. Its a fairly straightforward ‘trick’ – on the calculator detecting that it has to handle a higher order operator, it holds off the calculation, but the moment that’s not true, even if the = hasn’t been hit, it can legitimately calculate the preceeding hunk of the equation.

Maybe a ‘regular desk calculator’, whatever that means, would ignore the order of operations for simplicity, but cost cannot be a reasonable factor, so the only answer is that such calculators are pandering to those who have never learned the order of operations properly or to those for whom, for some mystic reason, the order of operations is a detriment. I guess it doesn’t really matter as long as you know how the particular calculator works.  
No biggy!

And boy, have we wandered off down the garden path.

Back to the OP, its interesting to note that a programming puzzle I was forced to beat my head against last night involved the calculation of PI by way of Archimedes’ area or edge approximation around a circle via a, inscribed polygon. Yet another interesting mechanism for calculation of nontrivial values.

---

<div class="post-metadata">

### Author: ![William\_Ashbless](https://avatars.discourse-cdn.com/v4/letter/w/a87d85/32.png) [@William\_Ashbless](https://boards.straightdope.com/u/William_Ashbless)
#### Post date: [June 18, 2003, 3:16pm UTC](https://boards.straightdope.com/t/how-does-a-calculator-do-trickier-calculations/182536/37 "2003-06-18T15:16:46Z")

</div>

Um, on sober reflection, I apologize if I offended anybody. The net has a tendency to drop my sarcasm and wit packets (must be stabilized in IPV6), and I got up in a cranky mood this morning. 🙂

Sigh.

---

<div class="post-metadata">

### Author: ![Whack-a-Mole](https://sea3.discourse-cdn.com/straightdope/user_avatar/boards.straightdope.com/whack-a-mole/32/141_2.png) [@Whack-a-Mole](https://boards.straightdope.com/u/Whack-a-Mole)
#### Post date: [June 18, 2003, 4:33pm UTC](https://boards.straightdope.com/t/how-does-a-calculator-do-trickier-calculations/182536/38 "2003-06-18T16:33:14Z")

</div>

> [@](#):
>
> \*Originally posted by William\_Ashbless \*  
> \*\*And boy, have we wandered off down the garden path. \*\*

Indeed we have and I apologize for it (but I did enjoy the discussion).

My reason for initially pointing it out was in regard to the OP. Clearly different calculators do math differently. Whether it is order of operations, calculating Pi…whatever. For most day-to-day tasks it probably doesn’t matter overly much. However, if your calculations demand a precision that is out of the ordinary you might want to run a few trial calculations through to determine what the calculator is doing and adjust your inputs accordingly (or go buy a different calculator).

---

<div class="post-metadata">

### Author: ![SlickRoenick](https://avatars.discourse-cdn.com/v4/letter/s/e68b1a/32.png) [@SlickRoenick](https://boards.straightdope.com/u/SlickRoenick)
#### Post date: [June 19, 2003, 1:13am UTC](https://boards.straightdope.com/t/how-does-a-calculator-do-trickier-calculations/182536/39 "2003-06-19T01:13:28Z")

</div>

> [@](#):
>
> \*Originally posted by William\_Ashbless \*  
> **’regular desk calculator’, whatever that means,**

I meant having an LCD 8-digit display and only 1, 2, 3, 4, 5, 6, 78, 9, 0, ., +, -, X, /, MC, MR, M+, M-, CE, C, and ON buttons. Sometimes OFF buttons.

---

<div class="post-metadata">

### Author: ![Hail\_Ants](https://avatars.discourse-cdn.com/v4/letter/h/dc4da7/32.png) [@Hail\_Ants](https://boards.straightdope.com/u/Hail_Ants)
#### Post date: [June 19, 2003, 6:22am UTC](https://boards.straightdope.com/t/how-does-a-calculator-do-trickier-calculations/182536/40 "2003-06-19T06:22:22Z")

</div>

Wow! Reading this thread made me think how mine was probably the last generation that still had to learn how to do math with pencil and paper. I was born in 1965 and remember the pocket calculator revolution of the 70s vividly.

It came just late enough that I still learned multiplication tables by route in 4th grade. Do they still makes kids memorize these (they should). Then, ug, mastering long division in 5th grade.

Fortunately, by the time I was taking Regents Algebra in middle school calculators were considered practical and my teacher, just for fun, showed us how you calculated a square root on paper! We were all really glad we didn’t have to master that! 😉

[Previous page](https://boards.straightdope.com/t/how-does-a-calculator-do-trickier-calculations/182536.md?page=1)

[Next page](https://boards.straightdope.com/t/how-does-a-calculator-do-trickier-calculations/182536.md?page=3)
