problem with float - 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: problem with float (
/showthread.php?tid=155039)
problem with float -
D1ma - 16.06.2010
HouseCost[InHouse[playerid]] is 35
that:
Код:
format(str,128,"%d",HouseCost[InHouse[playerid]]/2);
printing 17
and that
Код:
format(str,128,"%f",HouseCost[InHouse[playerid]]/2);
printing 0.00000
what is the problem here?
Re: problem with float -
Cameltoe - 16.06.2010
35/2 = 17.5
-
https://sampwiki.blast.hk/wiki/Format
Re: problem with float -
D1ma - 16.06.2010
Quote:
Originally Posted by Cameltoe
|
I know
but with %d it prints 17 and with %f it prints 0.00000
Re: problem with float -
smeti - 16.06.2010
Try:
pawn Код:
format(str, 128, "%0.2f", Float:HouseCost[InHouse[playerid]] / Float:2);
Re: problem with float -
-Rebel Son- - 17.06.2010
guys, stop leading him the rong way. if it prints 0.000000 thats the full float ammount. to shorten it to normal stature, put
%.0f
Re: problem with float -
(SF)Noobanatior - 17.06.2010
im guesing HouseCost[InHouse[playerid]] is a intger not a float and in this lies the problem
try
Код:
new Float:hc = HouseCost[InHouse[playerid]];
format(str, 128, "%.0f", hc / 2);
Re: problem with float -
D1ma - 17.06.2010
Quote:
Originally Posted by (SF)Noobanatior
im guesing HouseCost[InHouse[playerid]] is a intger not a float and in this lies the problem
try
Код:
new Float:hc = HouseCost[InHouse[playerid]];
format(str, 128, "%.0f", hc / 2);
|
thanks thats working!