Help 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)
+--- Thread: Help Float (
/showthread.php?tid=634352)
Help Float -
PhamHoang - 17.05.2017
So the the Float are 1.000000, 6 decimals
new strc[128],Float:realnum,decimals;
format(strc,sizeof(strc),"%.%df",realnum,decimals) ;
decimals = 2;
so the float should return 1.00, but don't work
Re: Help Float -
AbyssMorgan - 17.05.2017
Try this:
PHP код:
new strc[128],Float:realnum,decimals;
format(strc,sizeof(strc),"%%.%df",decimals); //output %%.2f
format(strc,sizeof(strc),strc,realnum); //output %.2f
Re: Help Float -
ShihabSoft - 17.05.2017
PHP код:
new strc[128],Float:realnum;
format(sstrc, sizeof(strc), "%.2f", realnum);
As of using %.2f, it will limit the place holders to 2 after the decimal points.
Re: Help Float -
PhamHoang - 17.05.2017
Thanks, Solved
Re: Help Float -
Gammix - 17.05.2017
PHP код:
format(strc,sizeof(strc),"%.%df",realnum,decimals) ;
You should place "decimals" before "realnum" argument.