function
#1

how I can convert a number to string?
for example I have the number 1569789, I want convert this number to string and the string will be: "1,569,789".
And so on, if I have the number 1000 then the string will be "1,000".

thanks for all helpers.
Reply
#2

I'm not entirely sure how to do it, but you could perhaps try: Valstr. Again, I have no idea, but I think that may help you? Sorry if it doesn't.
Reply
#3

pawn Код:
stock number_format(amount)
{
    new
        money[16],
        negativ = 0;
    if(amount < 0) negativ = 1;
    format(money, sizeof(money), "%i", amount);
    new
        lenght = strlen(money);
    while((lenght -= 3) > negativ) strins(money, ".", lenght);
    return money;
}

// This would print 1.500

main()
{
     prinft("%s", number_format(1500));
}
Reply
#4

thanks
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)