float converting - 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: float converting (
/showthread.php?tid=197458)
float converting -
The_Gangstas - 09.12.2010
how would i convert a float to 1.decimal places if the float is 1000 or more
e.g
1000 - 1.points
2000 - 2.etc
3000 - 3.etc
Re: float converting -
cessil - 09.12.2010
pawn Код:
if(floatcmp(MyFloat,1000.0) == 1)
{
format(string,sizeof(string),"my float at 1 decimal place: %.1f",MyFloat);
SendClientMessageToAll(COLOUR,string);
}
Re: float converting -
The_Gangstas - 09.12.2010
not 1 decimal place, 1 before the decimal
Re: float converting -
cessil - 09.12.2010
I think I understand, but maybe not
try using this and then rounding it off.
(x - (x - 1000)/10)+100
so if x = 1129 it'd be 112
Re: float converting -
The_Gangstas - 09.12.2010
but if i round it off it'll become an integer? i want it like 1.54 km if that explains it better lol
Re: float converting -
cessil - 09.12.2010
oh so instead of say 1928 you want it to be 1.928? if it's greater than 1000 then just divide by 1000
new Float:MyFloat;
MyFloat = MyDecimal/1000;