Integer Formatting
#1

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
Reply
#2

Put if the number is < 10 it formates like 0%i
Reply
#3

Quote:
Originally Posted by Dujma
Put if the number is < 10 it formates like 0%i
ty

*duh*

:P
Reply
#4

pawn Code:
new number = 5;
format(string, sizeof(string), "%02d", number);

%02d will result: 05
%03d will result: 005
%06d will result: 000005
Reply
#5

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
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)