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
 Thomas Okken Senior Member Posts: 1,478 Joined: Feb 2014
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.
 « Next Oldest | Next Newest »

 Messages In This Thread Algorithm for entering numbers? - rea5245 - 08-11-2019, 04:36 PM RE: Algorithm for entering numbers? - Thomas Okken - 08-11-2019, 04:57 PM RE: Algorithm for entering numbers? - Ángel Martin - 08-11-2019, 05:06 PM RE: Algorithm for entering numbers? - rea5245 - 08-11-2019, 05:37 PM RE: Algorithm for entering numbers? - Csaba Tizedes - 08-11-2019, 06:35 PM RE: Algorithm for entering numbers? - rprosperi - 08-11-2019, 07:03 PM RE: Algorithm for entering numbers? - rea5245 - 08-11-2019, 07:17 PM RE: Algorithm for entering numbers? - Thomas Okken - 08-11-2019, 07:38 PM RE: Algorithm for entering numbers? - Ángel Martin - 08-12-2019, 05:36 AM RE: Algorithm for entering numbers? - grsbanks - 08-12-2019, 08:08 AM RE: Algorithm for entering numbers? - Ángel Martin - 08-12-2019, 08:34 AM RE: Algorithm for entering numbers? - Thomas Okken - 08-12-2019, 10:26 AM RE: Algorithm for entering numbers? - Albert Chan - 08-19-2019, 06:29 PM RE: Algorithm for entering numbers? - rprosperi - 08-19-2019, 06:49 PM RE: Algorithm for entering numbers? - ijabbott - 08-19-2019, 06:52 PM RE: Algorithm for entering numbers? - grsbanks - 08-20-2019, 07:51 AM RE: Algorithm for entering numbers? - Thomas Okken - 08-20-2019 11:07 AM RE: Algorithm for entering numbers? - grsbanks - 08-20-2019, 11:29 AM RE: Algorithm for entering numbers? - grsbanks - 08-12-2019, 10:44 AM RE: Algorithm for entering numbers? - grsbanks - 08-12-2019, 09:09 AM RE: Algorithm for entering numbers? - Paul Dale - 08-12-2019, 10:54 AM RE: Algorithm for entering numbers? - Ángel Martin - 08-12-2019, 12:44 PM RE: Algorithm for entering numbers? - pier4r - 08-17-2019, 07:35 PM

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