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.

39 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. 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 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)

  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.

  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.

  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.

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.