HP Forums

Full Version: HP 48GX Division by Zero
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
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
Try -22 SF
(06-05-2015 09:03 AM)Bruno Wrote: [ -> ]Try -22 SF
I'd call that a workaround, not a solution;-)
A division by zero could indicate a program algorithm error (bug).
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
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.
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
Thanks, Dave! I haven't used R\->C and ARG since last century!
Reference URL's