# Are RPN Calculators dead and buried? R U Happy or sad?

**URL:** <https://boards.straightdope.com/t/are-rpn-calculators-dead-and-buried-r-u-happy-or-sad/664138>\
**Category:** In My Humble Opinion\
**Created:** [July 21, 2013, 10:06pm UTC](https://boards.straightdope.com/t/are-rpn-calculators-dead-and-buried-r-u-happy-or-sad/664138 "2013-07-21T22:06:27Z")\
**Posts on this page:** 15\
**Page:** 5

<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:** [July 23, 2013, 8:07pm UTC](https://boards.straightdope.com/t/are-rpn-calculators-dead-and-buried-r-u-happy-or-sad/664138/81 "2013-07-23T20:07:39Z")

</div>

> [@Indistinguishable](#):
>
> semantics and notation are orthogonal.

(At least, at this particular level of notational decision)

---

<div class="post-metadata">

**Author:** ![Trinopus](https://avatars.discourse-cdn.com/v4/letter/t/2bfe46/32.png) [@Trinopus](https://boards.straightdope.com/u/Trinopus)\
**Post date:** [July 23, 2013, 10:10pm UTC](https://boards.straightdope.com/t/are-rpn-calculators-dead-and-buried-r-u-happy-or-sad/664138/82 "2013-07-23T22:10:55Z")

</div>

> [@Norse](#):
>
> Personally, I use [this one](https://play.google.com/store/apps/details?id=org.efalk.rpncalc&hl=en). Love it.
> 
> ETA: On my PC, I either use [XCalc](http://www.tordivel.no/xcalc/) for its great usability, or the [HP-15C simulator](http://hp-15c.homepage.t-online.de/content_web.htm) for its nostalgia value
> 
> And I still haven’t gotten over the fact that my trusty HP-15C - which I bought the during my first term in college, for about 10% of my student loan for that term - was stolen when I was a PhD student :mad:

I’ll track down RpnCalc and install it. Thanks!

I have a physical HP 10C right here by my workstation. Lovely old machine, still works like a charm.

---

<div class="post-metadata">

**Author:** ![ptr2void](https://sea3.discourse-cdn.com/straightdope/user_avatar/boards.straightdope.com/ptr2void/32/3406_2.png) [@ptr2void](https://boards.straightdope.com/u/ptr2void)\
**Post date:** [July 25, 2013, 6:22pm UTC](https://boards.straightdope.com/t/are-rpn-calculators-dead-and-buried-r-u-happy-or-sad/664138/83 "2013-07-25T18:22:09Z")

</div>

Somewhere in this house there’s a functional (last time I saw it) 28S. I need to find that bad boy.

---

<div class="post-metadata">

**Author:** ![Philliam](https://sea3.discourse-cdn.com/straightdope/user_avatar/boards.straightdope.com/philliam/32/3011_2.png) [@Philliam](https://boards.straightdope.com/u/Philliam)\
**Post date:** [July 29, 2013, 6:20pm UTC](https://boards.straightdope.com/t/are-rpn-calculators-dead-and-buried-r-u-happy-or-sad/664138/84 "2013-07-29T18:20:28Z")

</div>

My HP-11c has been used so much the text/info on the back is almost all worn off. All the functions and keys still operate like brand-new. If only all their new products worked as well.

---

<div class="post-metadata">

**Author:** ![JohnGalt](https://sea3.discourse-cdn.com/straightdope/user_avatar/boards.straightdope.com/johngalt/32/184_2.png) [@JohnGalt](https://boards.straightdope.com/u/JohnGalt)\
**Post date:** [July 31, 2013, 3:37am UTC](https://boards.straightdope.com/t/are-rpn-calculators-dead-and-buried-r-u-happy-or-sad/664138/85 "2013-07-31T03:37:41Z")

</div>

I have my computer science students use a stack to create an RPN calculator in C++. For fun, I have them create a data structure to implement mixed fractions (whole number, numerator, and denominator). It’s a good project that also shows how to do operator overriding of + etc. in C++.

Besides mixed fractions, what else other data structures might you recommend for an RPN calculator? Time (hours/minutes/seconds)? Polar coordinates? Others?

---

<div class="post-metadata">

**Author:** ![Dr.Strangelove](https://sea3.discourse-cdn.com/straightdope/user_avatar/boards.straightdope.com/dr.strangelove/32/6613_2.png) [@Dr.Strangelove](https://boards.straightdope.com/u/Dr.Strangelove)\
**Post date:** [July 31, 2013, 3:55am UTC](https://boards.straightdope.com/t/are-rpn-calculators-dead-and-buried-r-u-happy-or-sad/664138/86 "2013-07-31T03:55:03Z")

</div>

> [@JohnGalt](#):
>
> Besides mixed fractions, what else other data structures might you recommend for an RPN calculator? Time (hours/minutes/seconds)? Polar coordinates? Others?

Polynomials are useful. Also, numbers with units (kg, m/s, etc.).

---

<div class="post-metadata">

**Author:** ![Mama\_Zappa](https://avatars.discourse-cdn.com/v4/letter/m/71e660/32.png) [@Mama\_Zappa](https://boards.straightdope.com/u/Mama_Zappa)\
**Post date:** [August 2, 2013, 5:46pm UTC](https://boards.straightdope.com/t/are-rpn-calculators-dead-and-buried-r-u-happy-or-sad/664138/87 "2013-08-02T17:46:36Z")

</div>

RPN is supposed to mimic the way you evaluate a complex expression - from the inside out.  
Say you’ve got something like:  
-(1_3_4+5/11_15+4/99)800+4/74-22.  
Following standard precedence (and adding parens because hell, I can’t read that!):  
(-(1_3_4 + 5/(11_15) + 4/99) \* 800) + 4/(7\*4) - 22  
On pencil and paper, you evaluate it from the inside out like so:  
(-(12 + 5/(165) + 4/99) \* 800) + 4/(28) - 22  
(-12 - 5/165 - 4/99) \* 800) + 1/7 - 22  
((whatever, too lazy to figure so let’s call it 100) \* 800) + 1/7 - 22  
80,000 + 1/7 - 22  
79,978 + 1/7

That’s basically what RPN does. But looking at the mess it started with, how do you keep it straight to enter into the calculator? I tried using one, twice, and nearly threw it across the room.

I had a calculator once that let you put in the parentheses. So you could plug that expression in as-is, and it would figure it out.

---

<div class="post-metadata">

**Author:** ![Mama\_Zappa](https://avatars.discourse-cdn.com/v4/letter/m/71e660/32.png) [@Mama\_Zappa](https://boards.straightdope.com/u/Mama_Zappa)\
**Post date:** [August 2, 2013, 5:49pm UTC](https://boards.straightdope.com/t/are-rpn-calculators-dead-and-buried-r-u-happy-or-sad/664138/88 "2013-08-02T17:49:25Z")

</div>

Oh, and with that expression:  
(-(1_3_4 + 5/(11_15) + 4/99) \* 800) + 4/(7_4) - 22

I _think_ what you’re supposed to do is:  
1 (enter)  
3 \*  
4\*  
then maybe save that to memory?  
11 (enter)  
15 \*  
then how do you divide 5 by that?  
Hence my frustration.

---

<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:** [August 2, 2013, 6:13pm UTC](https://boards.straightdope.com/t/are-rpn-calculators-dead-and-buried-r-u-happy-or-sad/664138/89 "2013-08-02T18:13:19Z")

</div>

Write out the expression as a tree. (So when you want to add two subexpressions, draw a little + with arrows to the roots of the subexpressions, etc.). Can you do that? The structure of the tree will be the logical structure of the expression, expressed clearly and unambiguously without any “operator precedence” or any of that, and thus a good place to start.

---

<div class="post-metadata">

**Author:** ![Senegoid](https://sea3.discourse-cdn.com/straightdope/user_avatar/boards.straightdope.com/senegoid/32/6606_2.png) [@Senegoid](https://boards.straightdope.com/u/Senegoid)\
**Post date:** [August 2, 2013, 9:00pm UTC](https://boards.straightdope.com/t/are-rpn-calculators-dead-and-buried-r-u-happy-or-sad/664138/90 "2013-08-02T21:00:51Z")

</div>

> [@Mama\_Zappa](#):
>
> Oh, and with that expression:  
> (-(1_3_4 + **5/(11\*15)** + 4/99) \* 800) + 4/(7\*4) - 22
> 
> 11 (enter)  
> 15 \*  
> then how do you divide 5 by that?  
> Hence my frustration.

Just that little part of the expressions: 5/(11\*15) would be entered as:  
5 (enter) 11 (enter) 15 \* ÷

However, RPN calculators typically also have a button that interchanges the top two items on the stack. So you could also enter that as:  
11 (enter) 15 \* 5 (swap) ÷

---

<div class="post-metadata">

**Author:** ![Mama\_Zappa](https://avatars.discourse-cdn.com/v4/letter/m/71e660/32.png) [@Mama\_Zappa](https://boards.straightdope.com/u/Mama_Zappa)\
**Post date:** [August 2, 2013, 9:01pm UTC](https://boards.straightdope.com/t/are-rpn-calculators-dead-and-buried-r-u-happy-or-sad/664138/91 "2013-08-02T21:01:44Z")

</div>

> [@Indistinguishable](#):
>
> Write out the expression as a tree. (So when you want to add two subexpressions, draw a little + with arrows to the roots of the subexpressions, etc.). Can you do that? The structure of the tree will be the logical structure of the expression, expressed clearly and unambiguously without any “operator precedence” or any of that, and thus a good place to start.

Well, but you need to know something about operator precedence to figure out which are THE subexpressions and how they are associated with which others. So don’t discount that.

Correcting my own groupings, I actually did it wrong:  
-(1_3_4+5/11\*15+4/99)_800+4/7_4-22

should group to  
( -( (1_3_4) + (5/11)\*15 + 4/99) \* 800) + ( (4/7) \* 4) - 22

That evaluates to -15,106.something.

Breaking it down like a tree, I get:  
a) 1+3+4  
b) 5 / 11 \* 15 (not that if you mess up the rules of precedence, you could get 5/(11\*15) which is quite different)  
c) 4/99  
d) add b to a  
e) add c to d  
f) multiply e by -1  
g) multiply f by 800  
h) etc.

I guess what I don’t understand is how you do the ‘a’ calculations, then do the ‘b’ calculations separately, and so on.

The calculator on my phone has parenthesis capabilities, so I plugged in exactly what I wrote originally and came up with the correct answer.

How would you enter that (at least up through the multipy by 800) step in RPN?

---

<div class="post-metadata">

**Author:** ![Trinopus](https://avatars.discourse-cdn.com/v4/letter/t/2bfe46/32.png) [@Trinopus](https://boards.straightdope.com/u/Trinopus)\
**Post date:** [August 2, 2013, 9:18pm UTC](https://boards.straightdope.com/t/are-rpn-calculators-dead-and-buried-r-u-happy-or-sad/664138/92 "2013-08-02T21:18:10Z")

</div>

> [@Senegoid](#):
>
> . . . However, RPN calculators typically also have a button that interchanges the top two items on the stack. . . .

Also a “1/x” button. So you enter, say, 100, hit the 1/x, and it gives you .001. Another way to put the divisor before the dividend.

---

<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:** [August 3, 2013, 12:08am UTC](https://boards.straightdope.com/t/are-rpn-calculators-dead-and-buried-r-u-happy-or-sad/664138/93 "2013-08-03T00:08:56Z")

</div>

> [@Mama\_Zappa](#):
>
> Breaking it down like a tree, I get:  
> a) 1+3+4  
> b) 5 / 11 \* 15 (not that if you mess up the rules of precedence, you could get 5/(11\*15) which is quite different)  
> c) 4/99  
> d) add b to a  
> e) add c to d  
> f) multiply e by -1  
> g) multiply f by 800  
> h) etc.
> 
> I guess what I don’t understand is how you do the ‘a’ calculations, then do the ‘b’ calculations separately, and so on.
> 
> The calculator on my phone has parenthesis capabilities, so I plugged in exactly what I wrote originally and came up with the correct answer.
> 
> How would you enter that (at least up through the multipy by 800) step in RPN?

Well:  
a we would write as 1, 3, 4, \*, \* [I assume you meant \* instead of + here]  
b we would write as 5, 11, /, 15, \*  
c is 4, 99, /  
d is a + b. So we write the expression for a, then the expression for b, then +: this gives 1, 3, 4, \*, \*, 5, 11, /, 15, \*, +  
e is d + c: So we write the expression for d, then the expression for c, then +: this gives 1, 3, 4, \*, \*, 5, 11, /, 15, \*, +, 4, 99, /, +  
f is e \* -1: So we write the expression for e, followed by -1, followed by \*: this gives 1, 3, 4, \*, \*, 5, 11, /, 15, \*, +, 4, 99, /, +, -1, \*  
And g is f \* 800: So we write the expression for f followed by 800 followed by \*: this gives 1, 3, 4, \*, \*, 5, 11, /, 15, \*, +, 4, 99, /, +, -1, \*, 800, \*.

The whole thing follows the pattern: “To transcribe a tree into RPN, first recursively transcribe the child trees, then write the root operation.” This is just like ordinary mathematical/programming notation for expressions built out of general functions [like “f(g(3, 5), h(3, f(4, 3), 1))”], except with the operation coming after the arguments instead of before them.

---

<div class="post-metadata">

**Author:** ![dropzone](https://sea3.discourse-cdn.com/straightdope/user_avatar/boards.straightdope.com/dropzone/32/7515_2.png) [@dropzone](https://boards.straightdope.com/u/dropzone)\
**Post date:** [August 3, 2013, 2:45am UTC](https://boards.straightdope.com/t/are-rpn-calculators-dead-and-buried-r-u-happy-or-sad/664138/94 "2013-08-03T02:45:33Z")

</div>

> [@Hari\_Seldon](#):
>
> Remember back in second grade when you wrote
> 
> ## 2 5
> 
> 7
> 
> That’s RPN.

No, that’s algebraic, 2 + 5 = 7, only vertical. Add more addends and it looks more RPN:

```auto

  3
  4
  2
+ 5
----
 14 

```

because the operator appears to be postfixed, but that’s not how you solve it because you are not shifting things onto a stack in your head then solving it all at once. What you are doing is: 3 + 4 = 7, 7 + 2 = 9, 9 + 5 = 14. Make the addends more than one digit and it becomes none of the above, but with the sum being the result, when you do it by hand, of a sequence of single-digit additions in columns.

> [@](#):
>
> RPN is really the natural way to go.

Natural? I can see nothing natural about it, and I’ve used both. Though I like RPN fine, in small doses and short formulae, it strikes me as a kludge from the days of weak microprocessors that some people have taken to heart and made its weaknesses virtues, but to each his own. I prefer a calculator that thinks like I do (without the tangents) and calculates the way I would lay out the formula on paper.

> [@](#):
>
> Usually, whenever I needed a number, there it was on the stack.

Where on the stack? Are you sure where? And what are you going to do with the numbers above it? For me, my numbers are in one of the several memory slots I have available to put them, with “1” being one of the possible values of “several” and “a piece of paper” standing in for the rest. Anyway, most tax returns can be calculated with a pencil on the return itself. 😃

---

<div class="post-metadata">

**Author:** ![Senegoid](https://sea3.discourse-cdn.com/straightdope/user_avatar/boards.straightdope.com/senegoid/32/6606_2.png) [@Senegoid](https://boards.straightdope.com/u/Senegoid)\
**Post date:** [August 3, 2013, 3:12am UTC](https://boards.straightdope.com/t/are-rpn-calculators-dead-and-buried-r-u-happy-or-sad/664138/95 "2013-08-03T03:12:39Z")

</div>

> [@Trinopus](#):
>
> Also a “1/x” button. So you enter, say, 100, hit the 1/x, and it gives you .001. Another way to put the divisor before the dividend.

Yes, this too.

And similarly for reverse subtract: If you find it convenient for some reason to put the subtrahend before the minuend (remember subtrahend and minuend?), you could use the “Change sign” key (which most calculators have), or the “swap” key.

Example: Doing 10 - 7, if for some reason you felt the need to enter the 7 first:

7 (change sign) (enter) 10 + (Note that after changing sign, you still have to press Enter, at least on my calculator.)

OR: 7 (enter) 10 (swap) -

[Previous page](https://boards.straightdope.com/t/are-rpn-calculators-dead-and-buried-r-u-happy-or-sad/664138.md?page=4)
