Integer Formatting - 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: Integer Formatting (
/showthread.php?tid=68157)
Integer Formatting -
1337pr0 - 07.03.2009
Hi
I want to format an integer like so:
pawn Code:
new number = 5;
format(string, sizeof(string), "%i", number);
But instead of showing 5, I want it to show 05. How do I do this?
Thanks
Re: Integer Formatting -
Dujma - 07.03.2009
Put if the number is < 10 it formates like 0%i
Re: Integer Formatting -
1337pr0 - 07.03.2009
Quote:
Originally Posted by Dujma
Put if the number is < 10 it formates like 0%i
|
ty
*duh*
:P
Re: Integer Formatting -
Sandra18[NL] - 07.03.2009
pawn Code:
new number = 5;
format(string, sizeof(string), "%02d", number);
%02d will result: 05
%03d will result: 005
%06d will result: 000005
Re: Integer Formatting -
1337pr0 - 07.03.2009
Quote:
Originally Posted by =>Sandra<=
pawn Code:
new number = 5; format(string, sizeof(string), "%02d", number);
%02d will result: 05
%03d will result: 005
%06d will result: 000005
|
Ah, that's what I was looking for! Thanks