RPN Financial 12 manual · Chapter 2 of 16
How RPN and the stack work
What reverse Polish notation is, the four stack registers X, Y, Z and T, ENTER, stack lift, rolling, swapping and LSTx, with step-by-step stack diagrams.
2.1What RPN is and why accountants like it#
In RPN you give the numbers first and the operation last. To add 3 and 4 you do not write 3 + 4. You write 3 4 + , which reads "3 and 4: add them". That is where "reverse Polish" comes from.
This pays off in longer work. You never need brackets, because the order in which you press the operations decides the order of the maths. You never need an equals key, because every operation shows its answer at once. And you can see every in-between answer, so a slip is easy to spot.
Think of a stack of plates. You put numbers on the top of the pile. An operation takes the top plate (or the top two), works on them, and puts the answer back on top.
2.2The four stack registers: X, Y, Z and T#
The stack has four places, called registers. They are named X, Y, Z and T, from the bottom of the pile to the top.
| Register | What it is | Where you see it |
|---|---|---|
| X | The number you are typing, or the latest answer. It is the one shown in the main display, and the one one-number functions work on. | Bottom line |
| Y | The second level. Two-number operations use Y and X. | Line above X |
| Z | The third level. | Third line |
| T | The top level. | Top line |
A calculation with two numbers always reads "Y operation X". In Y ÷ X, Y is the number being divided and X is the divisor. So 10 ÷ 4 means 10 in Y and 4 in X: key in 10, press ENTER, key in 4, press ÷.
In every stack figure the registers are listed X first, then Y, Z and T.
See all four registers
Key in 1, ENTER, 2, ENTER, 3, ENTER, 4.
1ENTER2ENTER3ENTER4

T = 1, Z = 2, Y = 3, X = 4.2.3What ENTER does#
ENTER has one job: it separates two numbers. It copies the number in X up into Y (and moves what was in Y up to Z, and so on), and leaves X holding the same number. The next number you type then replaces that copy in X, so nothing is wasted.
That is why 3 ENTER 4 + works. After 3 ENTER, X and Y both hold 3. When you type 4, it replaces the copy in X. The stack now has 3 in Y and 4 in X, and + adds them.
3 ENTER 4 +
Key in 3, ENTER, 4, then +.
3ENTER4+

7.00You do not press ENTER after the last number, and you do not press it before an operation key. If you press an operation straight after typing a number, the calculator finishes the number for you.
2.4One-number functions and two-number operations#
There are two kinds of key. A one-number function (√x, 1/x, LN, n! and so on) works on X only and replaces X with the answer. Y, Z and T stay put.
A two-number operation (+, −, ×, ÷, yˣ) uses Y and X. The answer goes into X, and the stack drops: Z moves down to Y, and T moves down to Z. T keeps its value, so a copy of it also appears in Z.
Square root leaves the rest alone
Key in 5, ENTER, then 9 and press g, √x.
5ENTER9g√xyˣ

X shows 3.00 and Y still holds 5.00.The stack drops after an operation
Fill the stack with 1, 2, 3 and 4 as before, then press +.
1ENTER2ENTER3ENTER4+

X = 7 (3 + 4), Y = 2, Z = 1 and T = 1: the old T value is copied downwards.2.5Chain calculations without brackets#
To work out (3 + 4) × (5 + 6), do the brackets first, one at a time, and let the answers wait on the stack. First 3 ENTER 4 + gives 7. That 7 stays in X. Key in 5: because 7 was an answer, it moves up to Y by itself. Press ENTER, key in 6, press + to get 11. The 7 is in Y again. Press × to finish.
(3 + 4) × (5 + 6)
Add 3 and 4.
3ENTER4+Add 5 and 6. The 7 moves up by itself.
5ENTER6+Multiply the two answers.
×

77.00(12 + 8) ÷ (2 × 5)
Add 12 and 8.
12ENTER8+Multiply 2 and 5.
2ENTER5×Divide Y by X.
÷

20 ÷ 10 = 2.00.Work from the inside out: do the innermost brackets first, then the next level. Four stack levels are enough for most expressions of this kind.
2.6When a new number replaces X and when it lifts the stack#
When you key in a new number, the calculator decides: should the new number go on top of what is in X (lifting the stack), or replace X? It follows one rule, called stack lift.
- After most operations (+, −, ×, ÷, functions, RCL, and results of any kind), stack lift is on. The next number you key in lifts the stack: the old X moves up to Y.
- After ENTER, stack lift is off. The next number replaces X. This is what makes 3 ENTER 4 work.
- After CLx (CLx), stack lift is off too. The next number replaces the cleared X.
- After Σ+ or gΣ−Σ+ (Σ+ or Σ−) stack lift is off. The count n shown in X is replaced by the next data point.
- STO, the display format keys and the BEG, END, D.MY and M.DY keys do not change the lift state.
A result lifts the stack when you type a new number
Add 2 and 3, then key in 4 and multiply.
2ENTER3+4×

5 × 4 = 20.00. The 5 moved up to Y when you typed 4.ENTER turns lift off
Key in 7, ENTER, then key in 8. The 8 replaces the copy in X.
7ENTER8

Y = 7 and X = 8. There is no extra 7.2.7Use a number twice: ENTER ENTER#
Pressing ENTER twice puts two copies of X on the stack. That helps when a number appears more than once. 3 ENTER ENTER × squares 3 and leaves a 3 in Y. Press × again and you get 3 × 3 × 3 = 27.
Cube a number
Key in 3, press ENTER twice, then × twice.
3ENTERENTER××

27.00You can also use gx²× (x²) to square X, or yˣ for any power.
2.8Roll the stack and swap X and Y#
x⇄y (x⇄y) swaps X and Y. It cures numbers keyed in the wrong order. Keyed as 10 ENTER 4 ÷ you get 2.5. If you wanted 4 ÷ 10, press x⇄y first.
Swap to divide the other way
Key in 10, ENTER, 4, swap, then divide.
10ENTER4x⇄y÷

4 ÷ 10 = 0.40.R↓ (R↓, roll down) moves every number down one level. X goes to the top (T), and Y, Z and T each move down. Nothing is lost, because the numbers go round in a circle. Four presses bring the stack back to where it started. This model has only a roll-down key.
Roll down
Fill the stack with 1, 2, 3 and 4, then press R↓.
1ENTER2ENTER3ENTER4R↓

X = 3, Y = 2, Z = 1 and T = 4 (the 4 went round to the top).2.9Bring back the last number with LSTx#
Every time you press a function or operation, the calculator saves the number that was in X just before. gLSTxENTER (LSTx, "last X") pushes that number back. It is useful to correct a slip, or to use the same number again.
Undo a multiplication with LSTx
Key in 6, ENTER, 2 and press × (you meant to add). Press g, LSTx to bring back the 2, then ÷.
6ENTER2×gLSTxENTER÷

12 ÷ 2 returns to 6.00, ready to try again.Reuse a number: 5 + 3, then 3 more
Key in 5, ENTER, 3, then +. Press g, LSTx to recall the 3, then + again.
5ENTER3+gLSTxENTER+

8 + 3 = 11.00.2.10Stack habits that save time#
- Do not press ENTER after the last number or before an operation.
- Work from the inside out for brackets.
- If a result seems wrong, press R↓ a few times to look at Y, Z and T. The numbers you need are still there.
- The stack holds only four numbers. If you have more waiting to be used, store some in registers (see Memory).
- For a − b, key in a, ENTER, b and press −. For a ÷ b it is the same: a goes in first.
HP 12C is a trademark of HP Inc.. Trident Calculator is an independent product by South View Studios and is not affiliated with, sponsored by or endorsed by HP. The name is used only to describe the kind of calculator this model resembles; Trident's names, keys, display, fonts and software are its own clean-room design.