![]() |
Previous | Table Of Contents | Next | ![]() |
Operating The Calculator
You can identify a Reverse Polish Notation (RPN) calculator because it lacks an Equals (=) key. How are you supposed to compute anything without an Equals key?
We all know how to employ a conventional calculator to compute, say, 2 times 3. Conventional calculator's are called algebraic calculators and you can find an algebraic calculator at Start/Programs/Accessories/Calculator in all versions of the Microsoft Windows operating system. We simply need to click the following keys:
![]() |
![]() |
![]() |
![]() |
On the algebraic calculator we get our answer when we click on the Equals key. That is, the multiplication is not performed when we press the Multiply key. Or is it? Try the following keystroke sequence on your favorite algebraic calculator:
![]() |
![]() |
![]() |
![]() |
![]() |
![]() |
The answer is 24, of course, but did you notice that this time a multiplication (the multiplication of 2 by 3) occurred when you pressed the Multiply key for the second time? Apparently, the Multiply keystroke may or may not cause a multiplication depending upon whether the two necessary operands are already available.
So the first advantage of an RPN calculator is consistency: a multiplication ALWAYS occurs when you hit the Multiply key. This means you must always enter both operands before hitting the Multiply key. This is the purpose of the ENTER key. Here is the keystroke sequence necessary to compute 2 * 3 using an RPN calculator:
![]() |
![]() |
![]() |
![]() |
Note that the Multiply key is employed only after both operands have been entered and that the multiplication result is computed as soon as the Multiply key is clicked.
I am now going to switch over to the actual button images used in this Windows
program. Each of the buttons on our RPN calculator can perform up to 3 different
functions, depending upon whether they are clicked without a prefix, with the
prefix (called the f key), or with the
prefix (called the g key). So the
keystrokes necessary to compute 2 * 3 are:
![]() |
![]() |
![]() |
![]() |
Note that none of these four keystrokes required a prefix key since the functions we wanted were the ones printed on the center rather than the top or bottom edges of the keys.
Perhaps you are now wondering where the operands go when you "enter" them.
This is another area where the RPN calculator outshines algebraic
calculators. Consider the job of raising the number two to the third power on an
algebraic calculator. This requires the key or the
key depending upon your calculator (you won't
see this key on the Microsoft calculator until you select View/Scientific from
the menu bar). So evidently
algebraic calculators have two storage locations called X and Y. But
why aren't they mentioned with regard to any of the other operations that
the algebraic calculator can perform? In truth, these same storage
locations are employed for multiplication, division, and all other two operand
operations.
The RPN calculator has a "y to the x" key
(, note that it
requires the f prefix) but more importantly the
RPN calculator explicitly uses the same X and Y storage locations for ALL of its
operations.
On the RPN calculator the X and Y storage locations are the first two locations in a four deep stack of operands. Want to see this stack? Just click and drag the On/Off slide switch over to the On position and the RPN calculator's LED display will change from:
to:
.
Now you can not only see the X and Y locations of the stack but also the other two locations, which are labeled Z and T (T for "top"). You are free to leave the On/Off slide switch in the On position thus causing the RPN calculator's stack to always be visible (the only downside is that the numbers are slightly smaller). Any time the On/Off slide switch is in the Off position you are viewing just the number in the X stack location.
To gain some familiarity with the operation of the stack, execute the following keystroke sequence while observing the stack:
![]() |
![]() |
![]() |
![]() |
![]() |
![]() |
![]() |
After this keystroke sequence the four deep stack of the RPN calculator will look like:
but if you were careless and added a 4th ENTER
keystroke then your stack will look like:
You have managed to enter four operands. Every time you type out a number it is placed into the X location of the operand stack. The ENTER key copies the number in the Z stack position into the T stack position (causing the prior contents of the T stack position to be lost), and copies the number in the Y stack position into the Z stack position, and copies the number in the X stack position into the Y stack position. This whole process is known as lifting the stack.
There are two other keys that directly affect the stack. The
key (called the Exchange key) interchanges the contents of the X and Y
stack locations without affecting the contents of the Z or T stack locations.
Go ahead, try it! Then experiment with the
key (called the Rolldown key). This key
is sort of the reverse of the Enter key except that no numbers are lost: instead
T is copied to Z, Z is copied to Y, Y is copied to X, and X is copied to T.
I said that these keys directly affect the stack. But other keystrokes
indirectly affect the stack. For example, the Multiply ()
keystroke causes the stack to drop. The stack drops
because the two operands in the X and Y stack locations are both removed from
the stack and the multiplication result is placed back into the stack in the
X location. This is a net loss of one number from the stack and consequently
Z drops (is copied) to Y and T drops (is copied) to Z with the result that the
contents of the Z and T stack locations become identical.
This process will make sense after you watch the stack while performing the following keystroke sequence:
![]() |
![]() |
![]() |
![]() |
![]() |
![]() |
![]() |
![]() |
![]() |
![]() |
![]() |
![]() |
![]() |
![]() |
![]() |
![]() |
![]() |
![]() |
Note that you hit the Multiply key twice in a row! You can hit the Multiply key at any time because the stack will always be populated with 4 numbers and hence there will always be an X and Y operand available for the multiplication. In our example you can continue clicking on the Multiply key and the stack will not change. Do you see why?
Everything you have learned about the Multiply key also applies to every other two-operand key such as Add, Subtract, and Divide. All two-operand keystrokes take their two operands from the X and Y stack locations, place their result back in the X stack location, and drop the stack. Similarly, all one-operand keystrokes such as Reciprocal (1/x) and log (common logarithm) take their one operand from the X location of the stack and place their result back in the X stack location (the rest of the stack doesn't move).
Here is a list of the one-operand keystrokes listed in the order they appear on the calculator's face:
Here is a list of the two-operand keystrokes:
The pi keystroke can be considered a zero-operand keystroke since it lifts the stack by populating the X stack entry with 3.14159...
Every one of the calculator's keys is further explained in the section of this document entitled The Instruction Set.
Generally, anytime you start entering a new number the stack will lift to accommodate the new number. You can see these automatic stack lifts in the previous example. Most keystrokes leave the calculator in a state where the stack will automatically lift upon the next number. The only exceptions to this rule are the ENTER key and the CLX (clear X) key which both leave the calculator in a state where it won't automatically lift when the next number is entered. Consequently, the next number after an ENTER or CLX keystroke will replace the contents of the X stack location without affecting the rest of the stack. Why are there these two exceptions? The ENTER key copies X to Y so there is no reason for the stack to automatically lift when you enter a subsequent number. You also wouldn't want the stack to lift after a CLX because that would just insert a zero into the stack. You rarely need to think about this -- the calculator just does the right thing.
Before leaving this section I should point out that you don't have to use the mouse to click on the keys seen on the calculator if your computer's keyboard has the equivalent key. That is, you can operate the RPN calculator using the following keys found on a standard Microsoft keyboard:
![]() |
Previous | Table Of Contents | Next | ![]() |