HP Forums

Full Version: STO+ STO- STO/ backward behavior on HP50g
You're currently viewing a stripped down version of our content. View the full version with proper formatting.

I just ran into some odd behavior on the 50g:

10 'X' STO

1 'X' STO-

After this sequence, the result in X is -9, not 9. In other words, STO- doesn't do "VAR = VAR - Level2" but instead does "VAR = Level2 - VAR"

The same is true with STO/ and STO+ (although you won't notice it with STO+ unless the variable contains strings or such).

This seems backwards to me and indeed my HP41CV behaves the way I would have expected (decrementing the variable). It must be intentional. Does anyone know when and why HP did this?

Thanks,
Dave

That's why I am not too thrilled about RPL.

I am thinking about presenting RPN2 in HHC2009. I have an Excel-based emulator for RPN2 which is a version of RPN that can handle local and global, labels and variables. The variables can store Booleans, reals, arrays, matrices, and strings. This makes RPN2 suitable for modular design thanks to the local/global feature. I have to finish the documentation before I share it.

Namir

Hi,

it's the same on the real HP-48GX.

However this is documented in the excellent HP-48 AUR on page 3-330;-)

To get the wanted 9 in 'X', just perform 'X' 1 STO- .

So you see that the way the RPL machines handle this is more flexible than in the HP-41,

since you can subtract either a discrete value from X, or X from a discrete value easily.

As hint: On an RPL stack, you subtract the content of stack level 1 from that on level 2.

HTH

Raymond

Wow! Now THAT'S cool ('X' 1 STO-) !!

Yes, this is much more flexible than the HP41 and it means that you can do exactly what I wanted. Thanks Raymond.

The HP49+ AUR is somewhat ambiguous, saying only that it calculates the difference between the value and the variable, but it doesn't say whether it's var-obj or obj-var or, (as it turns out to be) level2-level1

I tried it for the ambiguous case of 'Y' 'X' STO-. The result is Y-X stored into X.

Quote:
I just ran into some odd behavior on the 50g:
10 'X' STO 
1 'X' STO-

After this sequence, the result in X is -9, not 9. In other words, STO- doesn't do "VAR = VAR - Level2" but instead does "VAR = Level2 - VAR"

The same is true with STO/ and STO+ (although you won't notice it with STO+ unless the variable contains strings or such).

...

This seems backwards to me...


David --

"Ya learn somethin' every day" goes the saying, and you've found a tidbit of knowledge for yourself, me, and probably others.

This, in my estimation, is yet another example in RPL of consistency trumping logical intuitiveness. To wit, should storage-register-arithmetic operations act as storage-register operations or as arithmetic operations?

If the order of

{value} {register} {operation}
for storage-register operations (including arithmetic) held throughout, an error message would be given if the arguments were reversed. Instead, the convention for stack arguments in arithmetic operations is applied.

Indeed,

5 3 -

on the command line will evaluate to 2, so

1 'X' STO- 
would store 1-X, by the same logic. The point is taken that the actual RPL implementation is more flexible, but I question whether it was worthwhile.

-- KS

Edited: 25 Jan 2009, 10:40 p.m.