HP Forums

Full Version: Algorithm for entering numbers?
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
Pages: 1 2
(08-19-2019 06:29 PM)Albert Chan Wrote: [ -> ]Say, 99 is stored in memory 00, "RCL 00" should be equivalent to "99 Enter"

Actually, no it shouldn't.

The big difference between RCL 00 and "99 [ENTER]" is the fact that the second leaves 99 in both X and Y and disables stack lift. the first just places 99 in X and does not disable stack lift.
(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.
(08-20-2019 11:07 AM)Thomas Okken Wrote: [ -> ]on the HP-41C and 42S, you have to resort to the somewhat inelegant RCL ST X to achieve the same effect.

Or [ENTER] [X<>Y]

Because [ENTER] does duplicate X into Y, the sole function of [X<>Y] is to re-enable stack lift after [ENTER] left it disabled.
Pages: 1 2
Reference URL's