**Why RPN**

The main difference between Algebraic Mode and the Reverse Polish Notation (RPN), is the absence of the = ( ) keys and the addition of an Enter (8 ) Key. RPN looks like this:

5 | + | 4 | = |
| Algebraic Mode (5 keystrokes) |

5 | Ent | 4 | + |
| Reverse Polish Notation (5 keystrokes) |

Characteristic for RPN is that the operator (red) is always entered after the operands (black). This is called postfix notation. And that is done very consistently. In the next example Algebraic mode switches from infix notation (the operator is placed between the operands) to postfix notation. RPN keeps using postfix notation.

5 | 1/x |
| Algebraic Mode (3 keystrokes) |

5 | 1/x |
| Reverse Polish Notation (3 keystrokes) |

The real power of RPN becomes visible when the formula’s gets more complicated. Algebraic mode needs brackets to be effective. RPN does not, it keeps using postfix notation. For instance:

4 | * | ( | 2 | + | 3 | ) | = |
| Algebraic Mode (8 keystrokes) |

2 | Ent | 3 | + | 4 | * |
| Reverse Polish Notation (6 keystrokes) |

RPN is made possible by the use of a stack. This can be compared with a stack of dinner plates: you can only place and take plates from the top. When a number is entered it is put on the top of the stack. The next entered number, is placed on top of that. An operator always works on the top of stack (unary operator or operator with one operand) or on the top two stack levels (binary operator or operator with two operands). Then the upper two values are replaced with the calculated value and the stack is shifted up. The example above uses a stack as follows:

Keys pressed | 4 | 2 | 3 | + | * | |

Stack level 1 | 4 | 2 | 3 | 5 | 20 | Top of stack |

Stack level 2 | 4 | 2 | 4 | Used for binary operations | ||

Stack level 3 | 4 |

And when the formular gets longer, RPN becomes increasingly more efficient:

( | 1 | + | 2 | ) | * | ( | 3 | + | 4 | ) | = |
| Algebraic (12) |

1 | En | 2 | + | 3 | 8 | 4 | + | * |
| RPN (9 ) |

So RPN is often shorter (less key strokes), more consistent (uses always postfix notation) and therefore simpler to use. The only disadvantage is that one has to become familiar with RPN, but that appears to go surprisingly fast.

**Finally a nerd!**

A very good starting point of building your own RPN calculator with a mechanical keyboard, would be to find a suitable key-caps set. An ortholinear key-caps set, has all the key caps made in the same shape. A single sized enter key, would solve the problem of making a large key with two mounting points. Finding suitable keycaps, is very difficult. Since every row of keys has another shape, so keys cannot be placed everywhere. The keys for a keypad also have cursor arrows on it, and that’s not what we want. Finally, the larger enter key often has three mounting points, where two are needed.

I wanted a very rigid calculator, so I made it entirely of aluminum. But a 3d printed case would have been an option too. I wanted a nice retro-look. Therefore, I used a mechanical keyboard with two seven segment displays and not an LCD display. I am very rarely making scientific calculations and need only basic calculation functions And, if I need scientific calculations, I can always use my smartphone app. For most of my calculations, 6 digits are enough. The calculator shows the two top-level stack values. If more digits are used, both displays are automatically combined to one virtual 12-digit display.

At an early stage, I decided that I needed an Arduino Nano, because of its compact size. And I am familiar with C++. Just because I could, I also wanted a real-time clock (RTC). That offers me a date/time display and a count-down clock to my wife’s birthday (or any other very important date).

Writing the software was very hard. It is not difficult to write software, but it is difficult to write excellent and user-friendly software. For instance, a backspace key makes it very easy to correct a typo. So, I wanted one. But the implementation was complicated. The backspace key press, modifies an array of characters that needs to be converted to a string, before being stored as a 64-bit floating point number. This number is converted to a string, so it can be converted to 7-segment coding and finally can be displayed. It appears that I needed a special library, because the standard Arduino precision was by far not enough to make a calculator. Fortunately, I am not the only guy that is in need of a self-built RPN calculator, so I could use fp64lib. See: https://fp64lib.org/documentation/history-of-fp64lib/.

With the build of this Retro-RPN calculator, I build my masterpiece, graduated and became an official nerd. I am now part of the geek-society that uses home-build RPN calculators for their day-to-day calculations. Finally. Since the software is there, building your own retro RPN calculator is now reduced to a mechanical challenge and a bit of soldering. So good luck!

**The functionality of the retro RPN calculator**

The calculator uses two 6-segment LED displays, that show the x (top of stack) on the upper display and the y on the lower display. Both displays will merge into one virtual display when large numbers are entered. It can add, subtract, multiply and divide. Secondary functions are 1/x, %, -x and x^y. It has 10 memory locations, prefilled with useful constants. The number of decimals behind the comma can be set. It can split a number in an integer part (upper display) and fractional part (lower display). It also has a scientific notation. Date and time can be displayed and a count-down/count up clock is available. It has an optional sleep function that switches the displays off (and still keep the clock running).