Reverse Time Back To The Days Of RPN

While Texas Instruments maintains dominance in the calculator market (especially graphing calculators), there was a time when this wasn’t the case. HP famously built the first portable scientific calculator, the HP-35, although its reverse-Polish notation (RPN) might be a bit of a head-scratcher to those of us who came up in the TI world of the last three or four decades. Part of the reason TI is so dominant now is because they were the first to popularize infix notation, making the math on the calculator look much more like the math written on the page, especially when compared to the RPN used by HP calculators. But if you want to step into a time machine and see what that world was like without having to find a working HP-35, take a look at [Jeroen]’s DIY RPN calculator.

Since the calculator is going to be RPN-based, it needs to have a classic feel. For that, mechanical keyboard keys are used for the calculator buttons with a custom case to hold it all together. It uses two rows of seven-segment displays to show the current operation and the results. Programming the Arduino Nano to work as an RPN calculator involved a few tricks, though. [Jeroen] wanted a backspace button, but this disrupts the way that the Arduino handles the input and shows it on the display but it turns out there’s an Arudino library which solves some of these common problems with RPN builds like this.

One of the main reasons that RPN exists at all is that it is much easier for the processor in the calculator to understand the operations, even if it makes it a little bit harder for the human. This is because early calculators made much more overt use of a stack for performing operations in a similar way to Assembly language. Rather than learning Assembly, an RPN build like this can be a great introduction to this concept. If you want to get into the weeds of Assembly programming this is a great place to go to get started.

68 thoughts on “Reverse Time Back To The Days Of RPN

    1. Which infix notation is that? The one where 1+23=7, or 1+23=9, or where sin(1+2) has to be entered as 1+2=sin?

      RPN is concise, explicit, flexible, and has a pleasing workflow: gather everything you need together, and only then operate on it.

        1. It’s possibly just 5, if it’s basic calculator infix – the plus hasn’t happened yet, it’s just telling you what operation is next. 5 plus is then equivalent to 5 minus times minus plus, because the first three just change the operation you are about to perform.

          What’s 545+? In rpn calculator land, it could be 59, it could be 50, it could be 545 plus the output from the previous line, it could be 545 alone, or it could be an error. After all, I failed to specify where the separator was in that string, or what the starting contents of the stack were, or how the calculator resolves such things. Infix uses the operator as a separator, letting you express both pieces of information in one keypress, and then the equals button lets it know not to expect any more operands and just show the output.

          Really though, parentheses are what you want past a certain point. Even if the order of operations would technically be right, just make it clearer and use them sometimes, whether on paper or not. Also lets you get the other functions right – a sine is a sin( and you close the parenthetical where you like and continue on happily. Sine being reverse of arithmetic can get silly.

      1. Was that meant to say 1+2=7, 1+2=9 ? Having a hard time imagining any way to interpret 1+23= generating anything but 24. But of course there’s a lot of weird stuff out there, so if indeed it was meant as posted, what diabolical devices did that ?

      2. Sigh. Not quite sure what happened there, nor what the “HaD treatment of the asterisk bit us both” might be. Avoiding asterisks and using x to mean multiplication, I meant to write:

        “The one where 1+2×3=7, or 1+2×3=9, or where sin(1+2) has to be entered as 1+2=sin?”

      1. I’ve used RealCalc for years. It’s great! RPN let’s you solve problems with the calculator the same way you’d solve them on paper or in your head. When you think about what you DO, and not how it’s written, RPN calculators are far more natural to use than algebraic notation ones.

    2. I still use my HP 11C.
      I remember how others back in the days had to mess around with brackets and/or long divisions. I simply used the 4 register stack :-)

      The 48GX is somewhere in a drawer ;-)

      But to be honest, when doing math with my children I now use a Casio – also because it is the calculator allowed in school.

    3. Same!

      I vaguely remember RPN feeling weird back as a high school freshman when I first encountered it. But it’s not exactly difficult.

      For anything but a simple two numbers make one answer problem that I could have done in my head I think non-RPN calculators are so clumsy to use!

  1. I still have my HP-15C, HP-16C in my office. I started in college with the HP-11C. At home we still use the HP-12C for general use calculator. My dad used an HP-35, my uncle a HP-41. Forgot what my cousins used in college…

    On my home Linux computers, for a calculator, I have an HP-15C emulator for quick calcs. Don’t know why RPN lost out as it so much more intuitive to calculate in standard RPN and everyone in CS, Chem, and Engineering was using them (in college) and when I went to work most engineers and computer people were using them.

    1. RPN, IMHO, lost out, because TI scientific calculators beat HP to the college market by a year and a couple hundred dollars. The HP-35 (I knew someone who had one, we were all jealous) was far too expensive for a student. By the time you could finally get a HP-25, the TI calculators were ubiquitous and about $150 less expensive (but the keypads wore out and felt cheap).

      I got my HP-25 in 1976 and still have it, though now I run a V41 emulator on my PC. RPN is very logical and works the way you evaluate math expressions anyway. Never did get into the TI way of doing things, but my wife claims it’s natural for her (and it’s what she taught in her middle school math classes)

    1. I have a 42S which I bought in 1987, to replace the 11 that sadly grew legs when I left it unattended in the lab at school for 10 minutes. That 42S has the best keyboard layout of any HP I’ve ever used. Love that e^x and ln_x are both single press. It supports hexadecimal and the only program I ever keep in it allows me to flip back and forth from decimal to hex with one press of R/S. It goes 10 years on a set of batteries.

      Someone gave me an HP48 simply because they didn’t like RPN and knew I did. Too much emphasis on programmability, that one. Would happily trade it for an 11, 15 or 42. If I need anything programmed, well, that’s a job for a computer.

      Also bought one of those 35S models they came out with a while back. That was a near miss of a device. The silly 4-key directional rose is a waste of space. Theta and ‘8’ are nigh indistinguishable on the display. Worst is it’s just laggy enough that if, say, you peck in 123456789 in an even somewhat hasty way, it’s guaranteed to miss one of the digits, despite the otherwise pleasing tactile click of the key. And it sucks a pair of 2032 cells flat in 3 months.

      But to the point, my 42S goes to work with me almost every day.

  2. After the obvious ones, I’ve found the most useful keys on a RPN calculator are X<>Y and 1/x. They enable quick operations that would be clumsy or involve temporary storage in a memory on a muggle calculator.

  3. “RealCalc” – a scientific calculator app for Android can be set for RPN operation, which is fun to confuse the uninitiated with (“Where’s the equals key on this thing?”).

    My memory of this is that RPN was conceived by Jan Łukasiewicz as a means of making computation more efficient (fewer keystrokes/parentheses with calculators if I recall my HP-15 manual correctly) and it tucks nicely in with some stack operations.

  4. Infix calculators aren’t easier for the human. They’re a giant pain in the butt to use once you’ve invested the 5 or 10 minutes it takes to internalize how the stack works.

    And TI was not “the first to popularize infix notation”. Old four-function calculators were universally infix.

        1. Rats. Here’s the relevant bits, but since I don’t understand hacker’s scrotty little markdowns language, you’ll have to guess where the asterisks are.
          For some operations, such as addition, it is RPN, so 3+4 is entered as “C 3 + 4 +”, where “C is clear”. Yup, the “+” key has a dual function.
          For other operations, such as multiplication, it is algebraic, so 3*4 is entered as “C 3 * 4 =”.
          No, I can’t see how to calculate -3 * -4 = 12!

          Then you get to “chain calculations”, where extra keys have to be used.
          (17*9)+5 is entered as “C 17 * 9 = + 5 +”
          There’s that dual function, again.

          The memory is similarly weird, albeit interesting: it is an accumulating memory.
          To calculate 34+56 you enter “C CM 3 * 4 = 5 * 6 = RM”, where CM and RM are clear/recall memory. Essentially the “=” also causes the result to be added to memory; no “+” is necessary.

          The “%=” key is also quite nice, even if it is unnecessary.
          What is “25% of 125” is calculated “C 125 * 25 %=” i.e. 31.25.
          “If 21 is 25%, what is 100%” is calculated “C 21 / 25 %=” i.e. 84.

  5. RPN is also easier on the user. It doesn’t have complicated operator precedence rules that you must remember or else get the wrong results.
    I am convinced that this is why most (99%) of the scores in my undergrad engineering thermodynamics course were so awful, but mine weren’t. I can’t prove that the other two students with good scores used HP calculators, but given the price differential in 1980, that ratio seems about right.

    1. It doesn’t have complicated operator precedence rules that you must remember or else get the wrong results.

      Hmm… interesting… we’ve learned these rules at school didn’t we. Even before calculators were common. So when processing calculations or formulas we need to honor them otherwise different people (or calculators) will produce different results, eventually resulting in world wide chaos, global misunderstanding. People start to think that if we can’t calculate then how would it be possible that almost 60 years ago things landed on the moon. And people might even think that if we can’t calculate, well then the world might be flat for all we know. People will go crazy, stop thinking all together and come up will all sorts of crazy stuff, some might even think the world is run by lizard people or that we live in a simulation.

      Fortunately… most of us do use the complicated operator precedence rules properly, so the world is still a nice place [sarcasm may be applied here], lets keep it that way.

  6. Had one of the first HP RPN calculators in the mid-70s. Other students would want to borrow it in class so I’d hand it to them. That was followed by them handing back to me after a few moments asking where the ‘Equals’ key was.

  7. Still have a working HP67 my wife gifted me while I was in EE studies… I have lost track of the number of NiCd battery pack rebuilds.
    It been a few years but I did 2 RPN coding for uC devices: one for the CC2533 in “C” and one for the ATmega128 – both on Smart Response surplus hardware.

    https://hackaday.io/project/191722-rpn-integer-calculator-from-smart-response-pe

    https://hackaday.io/project/192472-tweaking-basic-on-smartresponse-xe

    I did not put a lot of effort in these weekend projects, so anyone pulling down the code has plenty of opportunity to enhance.

    1. Me too. For simple things it does not matter, you can calculate 3+5 on any calculator, but as soon as a formula gets more complicated and you want to start using brackets RPN is so much easier for data entry. RPN was a great help for me during school time to enter formulas into my calculator without typing errors. The great advantage of RPN, is that when you press an operator key, it executes it. If you pres “plus”, it does an addition, if you press “sin()” it executes the sine function.

      And despite that I love my old HP48G, I find Forth truly horrifying. Data entry in RPN for a calculator is fine, but reading text in RPN notation is horrifying.

      But these days, I just paste some text in a python window and fiddle a bit with it until it works. My HP48G is at arms reach, but I very rarely turn it on.

  8. i use dc every day and less often a kind of hp rpn calculator knockoff app i made for android. i wish i had something in between those two extremes. orpie is pretty cool but it’s too ‘weird’, a real voyage of discovery every time i use it. rpncalc was alright but had a different and just as bad set of limits, and it doesn’t seem to have a debian package anymore. i should just hack my android app to have a commandline interface, i guess.

  9. Used a new version HP-35s for hard core number crunching through grad school. Not only was it massively easier, pretty much no one could figure out how to use it thus no one stole it.
    Finance people still use HP calcs for TVM (I do all the time and it has saved me tons of $$$ figuring out repayment plans for student loans)
    And I’m not a programmer but I’m told pretty much anyone com-sci inclined is very familiar with stack operations.
    RPN is dead? Stuff.

  10. I had a Sharp EL 5100 programmable calculator where you could type in equations exactly like they are written out complete with nested parentheses. I used it for a couple of years in college for my math and physics courses until it got stolen. Then I got an HP 15C. RPN was MUCH faster for complicated equations than trying to keep track of the parentheses and order of operations gymnastics of the Sharp. I still have a 15C I got used on eBay on my desk and an emulator on my iPhone.

  11. I still have the HP28S I had in college in the 90s.
    I had replaced the IR led with a serial port back then and I was using it as a Teletext recorder/player (french Minitel).
    I did a bit of assembly on it too and some if my schoolmates were writing graphic games for it.
    I miss those days sometimes :)

  12. I admit it, I “cut my teeth” on HP calculators in the 1970s, but complex infix notation with parentheses only became easy to use once 5×7 dot matrix alphanumeric displays became available that could show the user their whole algebraic expression before hitting the = sign. in the era with only numeric calculator displays, you had to keep the expression and its parentheses in your head, which I claim, was a bigger (or at least equivalent) mental burden to RPN.

  13. Ah, I love these posts – they bring out all the oldsters (of which I’m one) either saying, “I used one!” or “I still use them!”

    I still use them! All my calculators are RPN. My daily drivers are 35S’s but I have a couple of the classics, a 32S II which unfortunately has a bad key, and an 11C which might actually be worth money except it lost it’s logo.

  14. I have an HP-41CV and all the attachments (various plug-in modules, extra memory, card reader, printer, and HP-IL interface) which I used as a Navigator in the US Navy back in 1981. Among other things, I wrote a program to calibrate the magnetic compass on the bridge. It is the only calculator I use and still works. LOVE RPN!!!!!

    1. Hooray! I still have my HP-41CX with original box, leatherette belt case and manuals. I still use it and RPN to this day. I tried to get my daughter accustomed to RPN on a new HP-35S, but the schools basically require TI graphing calculators these days. Good job, TI sales team. You’ve slowed down calculations for generations…

  15. I use my 40+ year old 15c daily, 32SII, and 35 as needed. Still wish my 41CX worked. Realcalc on my android is ok but nothing beats the muscle memory of the 15c for day to day work.

Leave a Reply

Please be kind and respectful to help make the comments section excellent. (Comment Policy)

This site uses Akismet to reduce spam. Learn how your comment data is processed.