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.