(long) Storage Register Math in 48GX



#2

I couldn't decide whether to post here or in comp.sys.hp48, but since I am including an RPN program, decided to post here.

(I think Raul Lion will find this question easy to answer).


My problem is (and this will show me to be a real RPL neophyte) that I have not found a clean and easy way to do storage register math with RPL. Perhaps it is just that the "STO + x" mentality is just so engrained, but when I try various combinations of local and global variables in RPL, I keep ending up with problems trying to add a value to an old register---because if the register is not defined, then I cannot add to it! I am not clever enough to figure out a flag or loop control to say, "if the register x does not exist, then make it, else recall it, act on it with the stack, and store the result back in x".

The specific RPN programs which I was trying to convert are shown below. Being a mechanical type of engineer (actually ships and boats etc) I often solve weight and moment computations, and a handy way of doing this repetitively (like when checking a spreadsheet, or on a ship in the bilge, adding up lead ingots or something) is to use the following programs:


Programs for summing moments about the w,x,y axes and finding the arms and total masses.

Will find intermediate summations and allow for continuation.

first, enter data int stack this way:

Mass <ent> arm w <ent> arm x <ent> arm y <ent>, leaving the stack as such:

T z (mass)

z w (arm)

y x (arm)

x y (arm)


01 LBL w (Program for taking mass and arm input, and producing running sum of moments)

02 R ^

03 STO s (stores currently entered mass for temp use)

04 STO + z (stores currently entered mass for summation)

05 X (multiplies the "y" {from orig reg. "t"} arm by the mass

06 STO + y (stores the y moment for summation)

07 R down

08 RCL s

09 X (multiplies the "x" {from orig reg. "z"} arm by the mass)

10 STO + x

11 R down

12 RCL s

13 X

14 STO + w

15 RTN

checksum AD51 022.5 bytes


view any mass or moment sum by reviewing the appropriate register


01 LBL T (program to take sums of moments in w,x,y axes and sum of mass, and finds arms.

02 0

03 ENTER

04 ENTER (clearing stack)

05 RCL y ("y" moment sum)

06 RLC z (mass moment sum)

07 / (solve "y" arm)

08 STO v (store "y" arm)

09 RCL x ("x" moment sum)

10 RCL z

11 / (solve "x" arm)

12 STO u

13 RCL w ("w" moment sum)

14 RCL z

15 /

16 STO t (store "w" arm)

17 RTN

check 089E 025.5 bytes


Note that the w,x,y arms are in the (x,y,z) stack registers and may be viewed with Rdown.


Besr regards,

Bill Platt


#3

Hey, Bill;

try something like:

IFERR STO+ THEN DUP 0 STO STO+ END

I have no manuals in hands, but what you should take much care is to make sure LAST ARGUMENT is set ON or you'll lost the arguments when STO+ (or any storage operation) fails. Also, storage arithmetic allows variable name in level 1 or 2; in my example, the variable name should bve in level 1.

If my example fails, let me know. I read your post now and I know this is one possibility, but I'm in a rush. I have to teach classes in about five minutes... Gosh!

Bye

Luiz C. Vieira - Brazil

#4

Well, as Luiz said, one way is the IFERR...THEN...END, but the easiest way (IMHO) is define the variables we are going to use at the begining of the program. Why don't do it?

I'll try to convert these prgs to RPL, but, please, help me with a good description of what is exactly you want in my email.

Raul


#5

Raul and Luiz,

Thanks!


I tried both your respective ideas the first time around----but I'm sure I did not understand the command order quite right but will try a bit now and get back to you-all.


Thanks again,

best regards,


Bill


Possibly Related Threads…
Thread Author Replies Views Last Post
  Need help understanding math.... cyrille de BrĂ©bisson 9 3,710 12-13-2013, 02:23 AM
Last Post: Didier Lachieze
  HP Prime: Long integers (continued) Helge Gabert 2 1,482 11-07-2013, 11:24 AM
Last Post: Helge Gabert
  HP Prime: Pass "Long" Integers to a Program Helge Gabert 6 2,402 11-03-2013, 01:12 PM
Last Post: Helge Gabert
  HP Prime polynomial long division bluesun08 13 3,602 10-30-2013, 03:29 AM
Last Post: parisse
  OT: a math competition site Pier Aiello 0 1,032 09-16-2013, 06:03 AM
Last Post: Pier Aiello
  Simple Math Question Namir 2 1,387 08-09-2013, 06:13 PM
Last Post: Eddie W. Shore
  Little curiosity: why the fourth stack register is called "T"? Antlab 34 8,389 07-03-2013, 04:49 PM
Last Post: Walter B
  A very long HP-17BII equation Gerson W. Barbosa 22 5,226 04-19-2013, 12:37 AM
Last Post: Gerson W. Barbosa
  A long WP-34S night Siegfried (Austria) 10 3,055 04-16-2013, 02:11 AM
Last Post: Siegfried (Austria)
  HP-25 left on for a long, long, while Matt Agajanian 12 3,536 04-10-2013, 11:33 PM
Last Post: Steve Leibson

Forum Jump: