Wrong Calculations
#1

Hello,
I print one calculation,but it is wrong

PHP код:
printf("%d",(400000000*40)/100); 
Log:
PHP код:
-11798692 
why?!
Reply
#2

2,147,483,647 is cellmax. Order matters in this case:
PHP код:
printf("%d",(400000000/100)*40); 
Reply
#3

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
Reply
#4

400000000*40 = 16000000000
cut 32 bit: -1179869184
-1179869184 / 100 = -11798691.84 round -11798692

All is okay :P

SA:MP Data Converter
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)