SA-MP Forums Archive
Floats and Zeros - 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: Floats and Zeros (/showthread.php?tid=146290)



Floats and Zeros - Miguel - 06.05.2010

Hey ya'll, can you show me how to do this?

pawn Код:
new Float:fl = 0.00010;
printf("%f", fl);
That would print "0.00010", but I don't want it to print the last zero. How can I do it?

pawn Код:
new Float:fl = 0.00100;
printf("%f", fl);
Same for that one, I don't want it to print the last 2 zeros.

Help


Re: Floats and Zeros - Jefff - 06.05.2010

Код:
new Float:fl = 0.00100;
printf("%.3f", fl);



Re: Floats and Zeros - Miguel - 06.05.2010

Quote:
Originally Posted by Jefff
Код:
new Float:fl = 0.00100;
printf("%.3f", fl);
No, I don't want to print 3 numbers after the dot. I want to get rid of the zeros after the last number greater than 0.

Like saying 4.0 == 4 or 4.0010 == 4.001.


Re: Floats and Zeros - -Rebel Son- - 06.05.2010

So you want a normal number like 4.0? do
pawn Код:
%.0f