Post Reply 
Program listing for RPN Sunrise/Sunset
10-15-2017, 05:16 PM (This post was last modified: 10-15-2017 06:05 PM by Dieter.)
Post: #6
RE: Program listing for RPN Sunrise/Sunset
(10-14-2017 09:20 PM)Craig Bladow Wrote:  Still get a DATA ERROR, so need to do some more debugging.

FTR: I tried the HP41 version in V41 and it works just fine. The times for today exactly match those from a good online calculator.

However, I think the program can be improved. I also wonder if the FLOOR routine is really required. But I don't get any errors. At least not for my location and timezone. What values did you try?

Edit: The program calculates floor(R10/90) and floor(R11/90). Both R10 and R11 are the result of a mod 360 operation which always returns a value >= 0. So I think the complete FLOOR routine is obsolete and can be replaced with a simple INT command. And maybe the whole thing can be done even more elegantly with MOD.

Edit 2: I now have replaced the following lines of the original program...

Code:
 99    ATAN
100    360
101    MOD
102    STO  11
103    RCL  10
104    90
105    /
106    XEQ 'FLOOR    Floor function.  External program
107    90
108    x
109    +
110    RCL  11
111    90 
112    / 
113    XEQ 'FLOOR    Floor function.  External program
114    90
115    x 
116    -     
117    15
118    /     
119    STO  11

...with this:

Code:
 99    ATAN
100    90
101    MOD
102    RCL  10
103    90
104    /     
105    INT
106    90
107    x 
108    +
109    15
110    /
111    STO  11

And it seems to work. But please do your own tests and report here if you find any cases where errors occur.

Dieter
Find all posts by this user
Quote this message in a reply
Post Reply 


Messages In This Thread
RE: Program listing for RPN Sunrise/Sunset - Dieter - 10-15-2017 05:16 PM



User(s) browsing this thread: 1 Guest(s)