The Evolution of RPN & Numeric Entry (original) (raw)
Contents
- Prehistory
- Adding Machines and Mechanical Calculators
- Reverse Polish But Not Quite "RPN" (Friden ECs)
- RPN
- 3 Level RPN
- 4 Level RPN
- RPL
- Numeric Entry Styles
- Enter, Rolls and Drops
Prehistory
RPN is formally traced to prefix and postfix mathematical systems proposed by Jan Lukasiewicz in 1951. However many mechanical calculators both before and after 1951 had a certain postfix flavor. Storing numbers in some kind of registers and then performing an operation on them is a natural implementation.
Adding Machines and Mechanical Calculators
The earliest mechanical calculators operated in a postfix manner. Rather then entering 4 + 5 =, the user cleared the accumulator, keyed (or levered) in the first number, performed some action to add this number to the accumulator, then keyed the second number and performed the same adding action as before. So to add 4 to 5, the user essentially performed:
CLEAR 4 + 5 +
and read the result of 9. To subtract 3 from 4, the user would perform:
CLEAR 4 + ("+" might consist of turning a crank in one direction 3 - whereas "-" might consist of turning it the other way.)
and read the result of 1. Machines like this had a single accumulator and a keyboard register instead of a stack and were limited in their ability to deal with long expressions. (Many modern "adding machine-style calculators" also multiply and divide but these functions are usually implemented in an infix/algebraic notation while the addition and subtraction is still postfix. The HP-10 implemented this form of logic.)
Reverse Polish But Not Quite "RPN" (Friden ECs) (ca. 1964)
Friden was the second company to produce electronic calculators. The EC-130 implemented the basic four functions and the EC-132added square root. The Friden ECs had a stack of four registers named "register #1" through "register #4" and the ENTER key served to complete the keyboard entry into register #1.
The Friden logic system had a lot in common with the RPN logic system that HP would later develop but there were some interesting differences including:
- There were no stack manipulation keys. The Friden lacked the exchange, and roll functions found in RPN systems. Using the Friden on complicated problems required more forethought.
- The ENTER key didn't act like HP's. It did not push the number but simply completed its display in register #1. However, the REPEAT key acted more like HP's ENTER. For example to square 25 on the Friden you could enter 25 REPEAT ×.
- STORE consumed the contents of register 1 so to save and use a number STORE was followed by RECALL.
- The Friden system had less "computer-like" flavor. There were no arrow symbols etc. Friden never mentioned "Polish", "reverse Polish" or "RPN" in its calculator documentation and only briefly mentioned that the calculator used a "stacking principle".
"Polish Notation" is really a style of writing expressions on paper rather than keying them on a calculator so determining precisely which calculators were or were not "RPN" is difficult. Since HP first applied the acronym "RPN" to its calculators, and because most users mean HP's specific implementations when they refer to "RPN", the museum doesn't classify the Friden ECs as true RPN calculators.
RPN
It's not clear where HP began in the development of the Reverse Polish Notation (RPN). HP considers it a direct derivation from the mathematical works of Jan Lukasiewicz, but it's likely that experience with mechanical calculators and/or the logic system of the FridenECs influenced them as well.
3 Level RPN (ca. 1968)
Used on the HP 9100 and HP 9810.
- Three Level Stack (X keyboard, Y accumulator, Z temporary)
- All Three levels displayed
- Numbers in Z copied down on pop
- Two operand operations left result in Y register
- Store and Recall commands provided for both X and Y registers
- Store X leaves the X register untouched
- Most unary operations worked on X, but a few worked on Y
- No implied stack lift on new entry. (e.g. 5 Log 10 would cause the result of 5 log to be overwritten.)
- Number [enter] left number in both X and Y
4 Level RPN (ca. 1972)
Introduced on the HP-35. Like 3 Level RPN except:
- Stack expanded to four levels (X, Y, Z, T)
- Only X displayed
- Numbers in T copied down on pop
- All operations left result in X register
- Store and Recall commands provided for X register only
- All Unary functions worked on X register
- Implied stack lift on new entry. (e.g. 5 log 10 resulted in 5 log in Y and 10 in X.
The HP-35 allowed the user to press the CHS sign before or during number entry. If a number was in the display as a result of something other than digit entry, pressing CHS negated it, but if the CHS key was then followed by a digit, the calculator assumed the CHS was actually meant for the following entry. Thus the previous number displayed was pushed onto the stack without the (already displayed) sign change. This feature could be confusing and later models required the CHS key to be pressed after the first digit of a number.
(User) RPL (ca. 1987)
Introduced on the HP-28C/S. Like 4 Level RPN except:
- Large stack size (essentially unlimited)
- Some smaller amount shown (4 lines in the 48 series.)
- Store X pops X from the stack
- Number [enter] leaves Number in X only. (As numbers are typed in, they go into an input buffer - not the stack. Enter moves them to the stack.) Squaring a number by multiplying by itself now requires two [enters].
- Stack now holds objects including arrays, matrices lists, strings and programs as easily as it holds numbers
User RPL also implies other changes beyond the stack such as:
- Named variables replace registers
- Variables and programs share the same address space
- Please visit the RPL page for a more complete RPL description.
Numeric Entry Styles
Non RPL machines enter numbers directly into the stack. On RPL machines numbers are typed into an input buffer and copied to the stack via [Enter] The high end desktop machines (made in Colorado) were somewhat more interactive in their input of numbers:
- Numbers were always displayed in the chosen display format even during input. (Including live rounding.)
- If the user typed more digits than could be displayed in fixed mode, the machines switched to scientific and incremented the exponent for each additional digit entered.
- Manual exponent entry was also live - typing the first digit caused the number to format as if that were the entire exponent until/unless a second exponent digit was entered. For example, if the display was in fix mode and the user pressed 2 . 6 [Enter Exp] 2, the display would immediately display 260. If the user pressed 5, the display would then show 2.6 25.
Enter, Rolls and Drops
On the HP 9100 and HP 9810, the enter key was labeled only with an arrow pointing up. Drop was indicated by an arrow pointing down. The calculators also had keys with arrows in each direction and the word ROLL to allow rolling either way. Finally an X<->Y (exchange) function was included.
On the HP-35, the word Enter was added to the upward arrow. The small calculator didn't have room for as many stack positioning keys so the only two besides ENTER were the X<->Y and a roll down key indicated by R followed by a downward arrow. This was not a great loss since rolling down, acted much like drop in that the value in X was moved to the top of the stack where it would soon be lost.)
On the HP-80, ENTER was relabeled SAVE. (This was the only calculator so labeled.)
When the HP-28C introduced the unlimited stack, using a roll down function to delete unwanted data in X no longer made sense since any rolled data would live forever at the top of the stack. Thus the HP-9100's downward arrow key returned but this time with the label DROP. This model also relabeled the X<->Y key to SWAP since the stack levels were no longer named.