HP 48GX Division by Zero
|
06-03-2015, 11:55 PM
Post: #1
|
|||
|
|||
HP 48GX Division by Zero
Hello,
I had to rewrite part of a program because an unexpected division by zero error was generated. I never thought the program would encounter that. I started out with an IFERR structure, but I settled on an IFTE structure to test for the presence of a zero because I assumed it might be a bit faster and use less bytes. Who else has been surprised by an error in a program that you've been using for a long time? Regards, Mark |
|||
06-05-2015, 09:03 AM
Post: #2
|
|||
|
|||
RE: HP 48GX Division by Zero
Try -22 SF
|
|||
06-05-2015, 09:47 AM
Post: #3
|
|||
|
|||
RE: HP 48GX Division by Zero
(06-05-2015 09:03 AM)Bruno Wrote: Try -22 SFI'd call that a workaround, not a solution;-) A division by zero could indicate a program algorithm error (bug). -- Ray |
|||
06-05-2015, 10:05 AM
(This post was last modified: 06-05-2015 10:10 AM by Bruno.)
Post: #4
|
|||
|
|||
RE: HP 48GX Division by Zero
lol, I agree Raymond, but this could answer his question :
"Who else has been surprised by an error in a program that you've been using for a long time?" -> Flag -22 has changed on your machine and was cleared for any reason |
|||
06-06-2015, 08:10 PM
Post: #5
|
|||
|
|||
RE: HP 48GX Division by Zero
Bruno: Thanks for replying! I was unaware of flag -22.
Raymond: Thanks for your input! There's only one algorithm I know of for calculating the azimuth between two points, which is ATAN ((E2 - E1) / (N2 - N1)). If point 1 is 5000 N, 5000 E and point 2 is 5000 N, 5400 E, I have division by zero. |
|||
06-06-2015, 11:56 PM
(This post was last modified: 06-07-2015 01:20 AM by Dave Britten.)
Post: #6
|
|||
|
|||
RE: HP 48GX Division by Zero
What about arcsin((n2-n1)/SQRT((e2-e1)^2+(n2-n1)^2))?
EDIT: That just covers 1st quadrant, though. You'd have to figure out signs to get the correct angle. Or better yet, just make the 48 do the work for you. Code: \<< SWAP - ROT ROT SWAP - SWAP R\->C ARG \>> Input: 4: E1 3: E2 2: N1 1: N2 Output: 1: Azimuth |
|||
06-07-2015, 03:32 AM
Post: #7
|
|||
|
|||
RE: HP 48GX Division by Zero
Thanks, Dave! I haven't used R\->C and ARG since last century!
|
|||
« Next Oldest | Next Newest »
|
User(s) browsing this thread: 1 Guest(s)