HP Forums
MOD function on HP Prime, in programming mode - Printable Version

+- HP Forums (https://www.hpmuseum.org/forum)
+-- Forum: HP Calculators (and very old HP Computers) (/forum-3.html)
+--- Forum: HP Prime (/forum-5.html)
+--- Thread: MOD function on HP Prime, in programming mode (/thread-3432.html)



MOD function on HP Prime, in programming mode - Powersoft - 03-19-2015 02:41 PM

The mod function is working normaly on the HP Prime.
When I run this small test it prints not the reminder, but
360001.5.

What is doing wrong?

EXPORT test()
Begin
Local J;
J:=(360*1000+1.5 mod 360);
Print(J);
End;

Cheers,

Jan Kromhout
Hellevoetsluis-NL


RE: MOD function on HP Prime, in programming mode - Thomas_Sch - 03-19-2015 02:59 PM

(03-19-2015 02:41 PM)Powersoft Wrote:  EXPORT test()
Begin
Local J;
J:=(360*1000+1.5 mod 360);
Print(J);
End;
Are you trying to calculate J:=( (360*1000+1.5) mod 360); ?


RE: MOD function on HP Prime, in programming mode - Wes Loewer - 03-19-2015 03:08 PM

(03-19-2015 02:41 PM)Powersoft Wrote:  The mod function is working normaly on the HP Prime.
When I run this small test it prints not the reminder, but
360001.5.
...
J:=(360*1000+1.5 mod 360);

That seems like the right answer to me. Did you perhaps mean
J:=(360*1000+1.5) mod 360;

In the order of operations, mod comes before +.