Multiplier and Divider operators a bit bugged? - 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)
+---- Forum: Help Archive (
https://sampforum.blast.hk/forumdisplay.php?fid=89)
+---- Thread: Multiplier and Divider operators a bit bugged? (
/showthread.php?tid=273208)
Multiplier and Divider operators a bit bugged? -
Donya - 31.07.2011
Okay, well I can't explain this very good but sometimes the * and / operator's either return very OFF values or negative values, using the raw floatmul and floatdiv fixes it
Example, when someone sells a house in my server that has over 20m or around that price it gives them negative values, this is how the sale price is calculated
pawn Код:
SafeGivePlayerMoney(playerid, HouseInfo[i][Price] * 87/100);
Yet, it gave then -x instead of x.
doing this
pawn Код:
SafeGivePlayerMoney(playerid, floatround(floatdiv(floatmul(HouseInfo[i][Price], 87), 100)));
did the trick s:
I don't know if it's suppose to be like that but... if so just remove the topic please
Re: Multiplier and Divider operators a bit bugged? -
Vince - 31.07.2011
It's because you're trying to multiply an integer with a float and then returning an integer again.
pawn Код:
new price = floatround(float(HouseInfo[i][Price]) * 0.87);
Something like that should work.
Re: Multiplier and Divider operators a bit bugged? -
Donya - 31.07.2011
oh... well I kinda learnt by multiplying first so..
Thanks I guess..