HP Forums

Full Version: HP48
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
Does the HP48 have a "Last X" function?
It has something very similar. The closest operation to "Last X" is probably the CMD keyboard command. Depending on the HP-48 model, it will either return the last argument(s) you had on the command line or a pop-up window with the last 4 command lines.

For example, if you add two numbers together like this:
1
Enter
2
+

It returns the result 3 to the stack.

Pressing the left-shift CMD key on a HP-48-S/SX will return a 2 to the command line. You could then press the - operator to subtract it from the result and undo the calculation, similar to how you could use Last X.

The ARG keyboard command (aka LASTARG) places the arguments of the most recently executed command to the stack so you can use them again. In the above example pressing left-shift ARG key after the addition would return a 1 and a 2 to the stack (the 3 would still be present be on stack level 3). Note these commands are on different keys on the HP-48G/GX series.
Not quite the same, but the HP 48G series has an undo function (right-shift EVAL), and the HP 48S series has a last stack function (left-shift 2).
(10-12-2020 12:29 AM)mobi323 Wrote: [ -> ]Does the HP48 have a "Last X" function?

Yes, but something different and "better": they have LASTARG command.
  • HP 48S/SX
    It is located on blue-shifted above "2" key, and labeled ARG (with LAST on white above it)
  • HP 48 G/GX/G+
    It is located on blue-shifted above "EEX" key, and labeled ARG

I think it was more clear on HP 48S models because those commands labels contained "LAST" over them (there are 4 commands with LAST over them: LAST STACK, LAST ARG, LAST CMD and LAST MENU, on keys "2" and "3").

LASTARG sates for "LAST ARGuments", and it returns the last arguments used.

LAST-X in RPN only takes back last X argument (only one argument), while LASTARG on RPL models takes back all arguments from last used command.

For example if you compute 5 SIN, on both cases LAST-X and LASTARG returns 5. But if you compute 2 3 + in RPN LAST-X returns only 3 while in RPL LASTARG returns 2 and 3, i.e. two stack levels, as + command take 2 arguments.

If you would want you could create a LASTX program (which only returns X) and even you could assign it to LASTARG key, but I don't see a reason for it. That unnecesary program could be something like:
« DEPTH -> d « LASTARG -> x « DEPTH d - DROPN x » »
This program simply does this: it executes LASTARG and drops all results from it except level-1 stack (the equivalent from X level in RPL).
Although you could use it one time (if you use it 2 consecutive times, the second one you would get the argument DROPN got). It can be modified to fix that:
« DEPTH -> d « LASTARG -> x « DEPTH d - DROPN x DUP DROP » »
Surely it can be done better in USER RPL or SYSTEM RPL, but this was a fast development Smile (for an unnecesary program).

IMPORTANT: As a lot of things on this machine, it can be customized: LASTARG functionality can be disabled by user/soft: -55 flag controls its state: if it is set (for example with -55 SF, or setting it on MODES menu) LASTARG is disabled, and if you try to use LASTARG command (or ARG key) you will get an error: "LASTARG Error: LASTARG disabled". But by default it is activated and most of us have it activated always (at least I do).

The reason to have the option to disable it is to be faster in some programs: if you have it enabled system has to record last arguments for possible temporal use, and that may consume more resources than in a simple RPN calculator where you only stores a number on LAST-X memory. Think that if you are operating for example with some very large matrix LASTARG stores temporally a copy, and that takes some CPU time and some extra memory. But I think most of use have LASTARG always on (and only a few intensive programs can have it disabled: mine never had).
(10-14-2020 04:37 AM)jklsadf Wrote: [ -> ]Not quite the same, but the HP 48G series has an undo function (right-shift EVAL), and the HP 48S series has a last stack function (left-shift 2).

The similar (not equal¹) function to LAST-X in RPN is LASTARG in RPL (HP 48 series).

UNDO/LAST_STACK is totally different idea: it restores stack to previous state before operation, and old HP RPN machine doesn't have that functionality (only RPL have those capability).

¹: LAST-X in RPN and LASTARG in RPL get the same reults if RPL operation only gets one argument. If las operation takes more than one argument, LASTARG returns all them, while LAST-X only returns X (top stack element for that prior operation).
(10-23-2020 10:29 PM)David22 Wrote: [ -> ]Yes, but something different and "better": they have LASTARG command.
  • HP 48S/SX
    It is located on blue-shifted above "2" key, and labeled ARG (with LAST on white above it)
  • HP 48 G/GX/G+
    It is located on blue-shifted above "EEX" key, and labeled ARG

On the HP 50g it is called ANS on the keyboard (left-shift ENTER). Confusingly there is also an ARG on the keyboard (right-shift /) but that is the argument (polar angle) of a complex number.
(10-24-2020 12:23 PM)John Keith Wrote: [ -> ]On the HP 50g it is called ANS on the keyboard (left-shift ENTER). Confusingly there is also an ARG on the keyboard (right-shift /) but that is the argument (polar angle) of a complex number.

You are right. HP 49/50g are some hybrid: they have two modes, algebraic and RPL mode, and in fact they boot in algebraic mode. Most HP 49/50 user immediately after boot change to mode RPL (I do), but some penalty remain: small enter key at bottom right instead of large ENTER key in left middle, bad key arragement or label (this ANS instead of "LAST ARG"). I hate their different key sizes and irregular key arragement, specially when used to HP 48 models being so good.
Yes, there are numerous threads here complaining about the HP 49/50 keyboard layout. It is annoying but you get used to it after a while.
Reference URL's