E: RPN: The Stack 271
File name : English-M02-1-040308(Print).doc Print data : 2004/3/9
How ENTER Works
You know that
E
separates two numbers keyed in one after the
other. In terms of the stack, how does it do this
?
Suppose the stack is
filled with
a
,
b
,
c
, and
d
. Now enter and add two new numbers:
5
+
6
:
a
(lost)
b
(lost)
T
a
b
c
c
c
Z
b
c
d
d
c
Y
c
d
5
5
d
X
d
5
5
E
5
6
6
+
11
Lift
Lift
No lift
Drop
E
replicates the contents of the X-register into the Y-register. The
next number you key in (or recall)
writes over
(instead of lifting) the copy
of the first number left in the X-register. The effect is simply to separate
two sequentially entered numbers.
Using a Number Twice in a Row.
You can use the replicating feature of
E
to other advantages. To add a number to itself, key in the number
and press
E+
.
Filling the Stack with a Constant.
The replicating effect of
E
,
together with the replicating effect (from T into Z) of stack drop, allows
you to fill the stack with a numeric constant for calculations.
Example: Constant, Cumulative Growth.
The annual sales of a small
hardware company are projected to double each year for the next 3
years. If the current sales are $84,000, what are the annual sales for
each of the next 3 years
?
1.
Fill the stack with the growth rate (2
EEE
).
2.
Key in the current sales in thousands (84).