Trident Help

RPN Advanced 42 manual · Chapter 3 of 18

The stack

How the four-level stack works: X, Y, Z and T, ENTER, stack lift, swap, roll down, LASTx and how to plan a calculation.

3.1The four stack levels#

The stack is a pile of four numbered slots named X, Y, Z and T (top). X is the bottom slot and the one you see most. Y is directly above it. Operations such as + and × take their numbers from X and Y, leave the answer in X, and move everything above down one level. Matrices and complex numbers each take just one level, like a real number.

With no menu open the display shows only Y and X. Z and T are still there; roll the stack down with R↓ to look at them.

After 1 ENTER 2 ENTER 3 ENTER 4 the stack holds T=1, Z=2, Y=3, X=4. The display shows Y and X. The display shows: y: 3.0000 / x: 4_.
After 1 ENTER 2 ENTER 3 ENTER 4 the stack holds T=1, Z=2, Y=3, X=4. The display shows Y and X.
Filling the stack. Each ENTER copies X up one level.

3.2What ENTER does and when the stack lifts#

ENTER copies X into Y and pushes everything up. The old T is lost. ENTER also does something subtle: it turns the stack lift off, so the next number you type overwrites the copy in X instead of pushing the stack up again. That is why 3 ENTER 4 gives Y = 3 and X = 4 with no leftover copy.

The stack lift is on again after almost every other operation. After a calculation, typing a new number pushes the answer up to Y and leaves it there. Three keys turn the lift off: ENTER, ← when it clears X, and the CLX and CLST commands in CLEAR.

Example 3.1

Square a number by duplicating it

  1. Type 3, press ENTER to copy it, then press multiply.

    3ENTERENTER×
Result of the example "Square a number by duplicating it" The display shows: y: 3.0000 / x: 9.0000.
You should see9.0000

The first ENTER copies, the second ENTER is not needed: 3 ENTER mul is enough. A second ENTER simply copies again.

Example 3.2

A number typed after ENTER replaces X

  1. Type 5, press ENTER, then type 7. The 5 stays in Y and X shows 7.

    5ENTER7
Result of the example "A number typed after ENTER replaces X" The display shows: y: 5.0000 / x: 7_.
You should seey: 5.0000 x: 7_
Example 3.3

A number typed after a calculation pushes the answer up

  1. Add 5 and 6, then type 7. The answer 11 moves to Y.

    5ENTER6+7
Result of the example "A number typed after a calculation pushes the answer up" The display shows: y: 11.0000 / x: 7_.
You should seey: 11.0000 x: 7_
Example 3.4

Backspace clears X and turns the lift off

  1. Type 7 ENTER 8, press backspace to clear X, type 5 and add. 5 replaced the cleared X.

    7ENTER8←5+
Result of the example "Backspace clears X and turns the lift off" The display shows: y: 0.0000 / x: 12.0000.
You should see12.0000
Stack lift: after a calculation a new number pushes the answer up.

3.3What happens to the stack during a calculation#

A two-number operation takes X and Y, puts the answer in X, and drops Z into Y and T into Z. T keeps its value, so it is copied down. This lets you reuse a constant that you have pushed into T.

Adding with a full stack. The top value T is copied down each time.
Example 3.5

Add down a full stack

  1. Fill the stack with 1, 2, 3 and 4.

    1ENTER2ENTER3ENTER4
  2. Press + three times.

    +++
    After step 2: Press + three times. The display shows: y: 1.0000 / x: 10.0000.
Result of the example "Add down a full stack" The display shows: y: 1.0000 / x: 10.0000.
You should see10.0000 y: 1.0000

3.4Swap and roll the stack#

x⇄y exchanges X and Y. It is the cure for numbers that were entered in the wrong order, which matters for subtraction and division. R↓ (roll down) moves every number down one slot and sends X round to T, so nothing is lost. Press it four times to get back where you started.

Swap and roll down on the stack 4, 3, 2, 1 (X first).
Example 3.6

Subtract in the other order

10−3=710-3=7
  1. Enter 3 then 10. Y = 3, X = 10.

    3ENTER10
  2. Swap so that Y = 10 and X = 3.

    x⇄y
    After step 2: Swap so that Y = 10 and X = 3. The display shows: y: 10.0000 / x: 3.0000.
  3. Subtract: 10 − 3.

    −
Result of the example "Subtract in the other order" The display shows: y: 0.0000 / x: 7.0000.
You should see7.0000
Example 3.7

Roll the stack down

  1. Fill the stack: T=1, Z=2, Y=3, X=4.

    1ENTER2ENTER3ENTER4
  2. Press R-down once. X becomes 3 and the old X goes to T.

    R↓
Result of the example "Roll the stack down" The display shows: y: 2.0000 / x: 3.0000.
You should seex: 3.0000 y: 2.0000

3.5Bring back the last X#

Before a function or operation runs, the calculator saves X in a register called LASTx. Shift x⇄y pushes it back onto the stack. Use it to recover a number you used by mistake, or to use the same number twice in one calculation.

Example 3.8

Undo a divide

  1. Divide 12 by 4.

    12ENTER4÷
  2. Shift swap brings back the 4 that was divided by.

    ⇧LASTxx⇄y
    After step 2: Shift swap brings back the 4 that was divided by. The display shows: y: 3.0000 / x: 4.0000.
  3. Multiply: 3 × 4 gives 12 again.

    ×
Result of the example "Undo a divide" The display shows: y: 0.0000 / x: 12.0000.
You should see12.0000
Example 3.9

Reuse a number: 1 over (2 plus 3), times (2 plus 3)

  1. Add 2 and 3.

    2ENTER3+
  2. Take the reciprocal.

    1/x
  3. LASTx brings back 5, the value before the reciprocal.

    ⇧LASTxx⇄y
  4. Multiply: 0.2 × 5.

    ×
Result of the example "Reuse a number: 1 over (2 plus 3), times (2 plus 3)" The display shows: y: 0.0000 / x: 1.0000.
You should see1.0000

3.6Plan a longer calculation#

Work from the innermost brackets outwards and keep intermediate answers on the stack. The stack has four levels, so you can keep up to four unfinished numbers. If an expression needs more, store a partial result in a variable instead.

122+4=2\frac{12}{2+4}=2
Example 3.10

Calculate 12 divided by (2 + 4)

  1. Put 12 on the stack.

    12ENTER
  2. Add 2 and 4 on top of it.

    2ENTER4+
    After step 2: Add 2 and 4 on top of it. The display shows: y: 12.0000 / x: 6.0000.
  3. Divide Y by X.

    ÷
Result of the example "Calculate 12 divided by (2 + 4)" The display shows: y: 0.0000 / x: 2.0000.
You should see2.0000
Example 3.11

Calculate (2 × 3) + (4 × 5)

2×3+4×5=262\times3+4\times5=26
  1. Multiply each pair, then add.

    2ENTER3×4ENTER5×+
Result of the example "Calculate (2 × 3) + (4 × 5)" The display shows: y: 0.0000 / x: 26.0000.
You should see26.0000
Evaluating 12 / (2 + 4).

3.7Clear X or the whole stack#

Backspace with no number being typed clears X (CLX). The CLEAR menu offers CST to clear the whole stack. LASTx and variables are not touched. Both leave the stack lift off.

Example 3.12

Clear only X

  1. Put 1 and 2 on the stack, press ENTER to copy the 2, then press backspace. X is cleared; the 2 in Y stays.

    1ENTER2ENTER←
Result of the example "Clear only X" The display shows: y: 2.0000 / x: 0.0000.
You should seex: 0.0000 y: 2.0000

HP-42S 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.