HP Forums
HP 48GX Division by Zero - Printable Version

+- HP Forums (https://www.hpmuseum.org/forum)
+-- Forum: HP Calculators (and very old HP Computers) (/forum-3.html)
+--- Forum: General Forum (/forum-4.html)
+--- Thread: HP 48GX Division by Zero (/thread-4069.html)



HP 48GX Division by Zero - MNH - 06-03-2015 11:55 PM

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


RE: HP 48GX Division by Zero - Bruno - 06-05-2015 09:03 AM

Try -22 SF


RE: HP 48GX Division by Zero - Raymond Del Tondo - 06-05-2015 09:47 AM

(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).


RE: HP 48GX Division by Zero - Bruno - 06-05-2015 10:05 AM

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


RE: HP 48GX Division by Zero - MNH - 06-06-2015 08:10 PM

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.


RE: HP 48GX Division by Zero - Dave Britten - 06-06-2015 11:56 PM

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


RE: HP 48GX Division by Zero - MNH - 06-07-2015 03:32 AM

Thanks, Dave! I haven't used R\->C and ARG since last century!