Wrong Calculations - Printable Version
+- SA-MP Forums Archive (
https://sampforum.blast.hk)
+-- Forum: SA-MP Scripting and Plugins (
https://sampforum.blast.hk/forumdisplay.php?fid=8)
+--- Forum: Scripting Help (
https://sampforum.blast.hk/forumdisplay.php?fid=12)
+--- Thread: Wrong Calculations (
/showthread.php?tid=637450)
Wrong Calculations -
MRM - 14.07.2017
Hello,
I print one calculation,but it is wrong
PHP код:
printf("%d",(400000000*40)/100);
Log:
why?!
Re: Wrong Calculations -
Paulice - 14.07.2017
2,147,483,647 is cellmax. Order matters in this case:
PHP код:
printf("%d",(400000000/100)*40);
Re: Wrong Calculations -
GaByM - 14.07.2017
When you do 400.000.000*40 it gives you 16.000.000.000 and it is too large. This is caleld overflow. The maximum it can hold (on pawn) is 2147483647 and the minimum -2147483648.
https://sampwiki.blast.hk/wiki/Scripting_Basics#Variables
Re: Wrong Calculations -
AbyssMorgan - 14.07.2017
400000000*40 = 16000000000
cut 32 bit: -1179869184
-1179869184 / 100 = -11798691.84 round -11798692
All is okay :P
SA:MP Data Converter