Post Reply 
Algorithm for entering numbers?
08-20-2019, 11:07 AM (This post was last modified: 08-20-2019 11:36 AM by Thomas Okken.)
Post: #22
RE: Algorithm for entering numbers?
(08-19-2019 06:29 PM)Albert Chan Wrote:  What is the rationale for Enter disable stack-lift ?

One of the functions of the ENTER key is filling the stack, so you can take advantage of the way T is duplicated when the stack drops, in order to perform repeated additions or multiplications. For example, to observe how a number grows when multiplied repeatedly by a constant factor, you can do factor ENTER ENTER ENTER number × × × × × ...

Doing this requires ENTER to duplicate the number in X, and not merely have the effect of ending number entry mode. But that means that when ending number entry mode is the desired effect, you'll want to prevent the duplication from cluttering up the stack unnecessarily, and that is accomplished by disabling stack lift.

The way the RPL calculators deal with the two uses of ENTER is different but accomplishes the same thing: in number entry mode (or more generally, any kind of entry on the command line), it ends entry mode, placing the entered number in X, also known as Level 1, without duplicating anything, while when not in entry mode, ENTER performs DUP.

So the details of the operation are different, but the results are almost the same, to the point where I don't really think about the difference when switching back and forth between the two systems.

I think the RPL approach is a bit more elegant because it handles the case where you specifically want just duplication better; on the HP-41C and 42S, you have to resort to the somewhat inelegant RCL ST X to achieve the same effect. For example, if you want to multiply the number in X by 10, while also preserving the original number on the stack, on a calculator like the HP-67 you'd have to do ENTER ENTER 10 ×, needing the second ENTER in because the stack-lift-disabling behavior is not desired here and needs to be worked around; on the HP-42S you could do RCL ST X 10 × (or 10 RCL× ST Y, but I digress), while the RPL approach is DUP 10 ×, which is actually the clearest of the three to read.
Visit this user's website Find all posts by this user
Quote this message in a reply
Post Reply 

Messages In This Thread
Algorithm for entering numbers? - rea5245 - 08-11-2019, 04:36 PM
RE: Algorithm for entering numbers? - Thomas Okken - 08-20-2019 11:07 AM

User(s) browsing this thread: 1 Guest(s)