
hp calculators
HP 12C Platinum Using the RPN stack to solve problems efficiently
hp calculators - 3 -HP 12C Platinum Using the RPN stack to solve problems efficiently - Version 1.0
Example 2: What is the most common keystroke sequence to enter 2.33 and 4.5 and add them to each other? What
registers in the stack are used?
Solution: The most common keystroke sequence to add 2.33 to 4.5 is:
4.5 \ 2.33 +
Figure 3
In fact, all of the stack registers have their contents changed during this single addition. However, the real question is
that since both numbers must "exist" in the calculator memory before +is pressed, "Where do they exist?" When +
is pressed, the calculator proceeds with the following operation sequence:
1. take a copy of the X-register contents and put it in L-register (last-x);
2. take Y-register contents and add to X-register contents;
3. replace actual X-register contents for resulting value;
4. "drop" T- and Z-register contents respectively to Z- and Y-registers;
5. maintain a copy of T-register contents in T.
Based on these facts, it is seen that \not only separates two numbers entered in a keystroke sequence, but it
actually provides that a copy of the number currently in the X-register is preserved for immediate use, and this copy is
kept in the Y-register. This way, when +is pressed in this example, the number that is in the Y-register is the one that
was copied there by \. This same operational sequence is observed when -, §, zand qare used. These
are the 'two-number functions'. When the \key is pressed, the copy of the number shown in the display is actually
kept in the Y-register. This pushes the previous contents of the Z- and Y-registers up to the T- and Z-registers,
respectively. This is called "stack lifting" because the stack register contents are "lifted" or pushed up. Previous
T-register contents are lost after \is pressed, since they are "pushed" off the top of the stack.
Viewing and reordering stack registers contents
Example 3: How would you fill the T, Z, Y and X stack registers with the numbers 44, 33, 22 and 11, respectively?
Solution: The most common keystroke sequence to fill the stack registers with these numbers is:
44 \ 33 \ 22 \ 11
The stack registers contents would be updated according to the diagrams shown below:
T 44.00 44.00
Z 44.00 44.00 33.00 33.00
Y 44.00 44.00 33.00 33.00 22.00 22.00
X 44 44.00 33 33.00 22 22.00 11
44 \(∗) 33 \(∗) 22 \(∗) 11
Figure 4
(∗)Entering a number in the X-register right after \, O, _or g^ overwrites current X-register contents and does not lift stack contents