# Tagged: reverse polish notation

# HP-12C

This is my HP-12C financial calculator, which I bought from Shopgoodwill last year. It came in this beautiful case and just required some new batteries to start working.

To the extent that it’s possible for a pocket calculator to be legendary, that’s what the HP-12C is. When it turned 30 in 2011, it was covered in the Wall Street Journal and on major blogs like Technorati. HP even posted a celebratory video on YouTube entitled HP 12c Calculator — Then & Now. Despite the fact that it was first released in 1981 (the same year as the IBM PC) it’s still being sold today. You can buy one new at Amazon, or from Staples, or OfficeDepot, or Walmart and the price you will pay is not what I would call cheap.

I don’t actually have much use for a financial calculator but I bought this HP-12C for two reasons: First, because a Reverse Polish Notation calculator seemed like a great nerd novelty item and second because it’s a classic of early 1980s technology.

Today the vast majority of pocket calculators and small desktop calculators you see are extremely cheap commodity crap. But, there was a time when a calculator was a prized possession, probably the most advanced piece of technology a person owned. The HP-12C is one of the last remnants of that era.

The HP-12C is a member of a line of calculators that HP created for different professions in the early 1980s including the HP-10C, HP-11C, and HP-15C scientific calculators and the HP-16C programmer’s calculator. The HP-12C apparently has endured because finance professionals loved their portability and reliability of the HP12-C and required newcomers to learn how to use them.

Unlike most calculators the HP-12C uses Reverse Polish Notation (RPN). In order to add two numbers you do not type 2 + 4 and press =. Instead, you press 2 and then press Enter. Then you press 4 then you hit the + button and your two numbers are added together and 6 shows up on the screen. You enter the numbers first and then the operation. Why would you want a calculator that works like this?

It’s best if I let this page at HP’s site about RPN explain the difference:

Believe it or not, the process of using RPN is similar to the way you learned math. If you think about it, you have to modify the way you learned math in order to use an algebraic mode calculator.

Here’s an example

3+5

—

7+6Or (3+5) / (7+6) = x

Algebraic method: Add 3+5=8. Write down the answer or store it in memory. Add 7+6=13. Now enter the 8 from the first answer and then divide it by entering the second answer to get x=0.62.

RPN method: Touch 3 then the ENTER key. Touch 5 then the + key. Touch 7, and then ENTER. Touch 6 then the + key. Note that the answer to the second sum is displayed. Now here’s the magic part. Touch the divide key and the calculator gives the answer, 0.62.

Algebraic: 13 strokes, not counting the effort to write down or memorize the first answer while you calculated the second answer.

RPN: 9 strokes, and no need to write anything down.

The beauty of this is that in RPN the order of operations is explicit. As computer science buffs are aware, RPN works on a stack. Basically each new number you put in is pushing down a new entry on the stack and each operation is popping off numbers from the stack in a last-in, first out order.

The tricky bit to imagine in that example above is that each time you enter numbers, the stack is being pushed down. So 3 is pushed into the stack and then 5 is pushed into the stack and then + pops them off the stack and then pushes the answer 8 back onto the stack. Then 7 is pushed onto the stack, 6 is pushed onto the stack and they’re added together to make 13, which is pushed back onto the stack. At this point the stack looks like this:

13

8

As a result, when the divide button is pressed 13 and 8 are popped off of the stack and 8 is divided by 13 giving us 0.62. Because there’s a stack there’s a fairly sophisticated memory function basically built in.

The HP-12C is actually a small computer. Unlike most pocket calculators which have a relatively primitive fixed-function calculator IC there is actually a CPU inside of an HP-12C. When you push a button the calculator is actually loading a tiny program into the CPU.

The HP-12C and the other members of the HP-10C line all used the same CPU, referred to as Voyager, with different code assigned to the different buttons on each model.

The HP-12C is actually *programmable*. That is to say that it has what we would today call a macro language where you can store up to 99 lines of operations and recall them at a button press.

Because it is programmable there are honest-to-goodness *games *(warning: PDF) people have written for this pocket calculator. You have to key them in one line of code at a time, like old BASIC programs on early home computers.

On the back of the HP-12C is this sort of quick explanation of some of the calculator’s functions. The fact they’re written in gold lettering, and that there’s a ton of information contained in them that’s somewhat hard to decipher reminds me a bit of the pictograms on the Voyager Golden Record.

The gist of these things is that the programs trigger by those buttons are capable of some sophisticated data conversions, like finding the number of days between two dates. Additionally there are five special registers (basically memories) for Time Value of Money financial calculations called n, i, PV, PMT, and FV. A wide variety of financial calculations can be done by entering numbers into those registers and running the little programs on them.

If this serial number decoding explanation is correct then my HP-12C was made in the United States during the 43rd week of 1988.

As you would expect from a consumer electronics device that has been made for three decades, there have been several revisions of the HP-12C over time. Suffice to say that over the years they have kept the button arrangement and external appearance the same but re-arranged the innards several times.

According to this site, the HP-12C originally had two chips: a CPU chip and a ROM/RAM/Display Driver chip. By the 28XX series like mine the two chips had been merged into a single chip where the Voyager CPU chip also contained the other chip’s functionality.

Interestingly, if you buy an HP-12C today what you get is outwardly nearly identical but very different inside that the older one I have. The old Voyager CPU has been replaced with an ARM-based CPU. ARM CPU cores have been famously used in everything from the Game Boy Advance to the iPhone and Android devices. They’re ideal for situations where you need a CPU that uses a tiny amount of power for a specific task.

In the HP-12C, I believe what they’ve done is created an emulator that uses the ARM CPU to faithfully reproduce the functionality of the old CPU, but with faster execution speed.

These newer HP-12Cs can be identified visually by the fact that they now have two button batteries that go in horizontally, rather than three that face vertically.