How to split numbers and set a dot in it -
tMike - 03.11.2012
Hey,
how is it possible to split numbers and set points in it?
Example:
Before we split, we have $2582960, after we split, we have $2.582.960
Is there a filterscript or include for it?
I don't know what i should type in the search, sorry. Thanks for help.
Re: How to split numbers and set a dot in it -
nmader - 03.11.2012
Well, the correct way is "$2,582,960" Meaning commas, not periods after three digits and yes, here you are:
pawn Код:
stock Comma(numbers)
{
new temp[24],counter = -1;
valstr(temp,numbers);
for(new i = strlen(temp);i > 0; i--)
{
counter++;
if(counter == 3)
{
strins(temp,",",i);
counter = 0;
}
}
return temp;
}
And anywhere you are defining the amount use:
pawn Код:
Comma(WhateverNumbers) //Whatever Number you want the commas within.
Re: How to split numbers and set a dot in it -
Mauzen - 03.11.2012
using a point . for thousands separation is the common way in germany and some other areas where you use , as the decimal separator, so both variations are okay. To get the . as separator you just need to replace the , in strins with a . in his code of course.
Re: How to split numbers and set a dot in it -
nmader - 03.11.2012
Quote:
Originally Posted by Mauzen
using a point . for thousands separation is the common way in germany and some other areas where you use , as the decimal separator, so both variations are okay. To get the . as separator you just need to replace the , in strins with a . in his code of course.
|
Ah, I was not aware of that, haha. Thanks for the lesson, Mauzen.
Re: How to split numbers and set a dot in it -
Mauzen - 03.11.2012
Quote:
Originally Posted by nmader
Ah, I was not aware of that, haha. Thanks for the lesson, Mauzen. 
|
Youre welcome

Though your version of course is the more handy one, else you would need to swap all the . decimal separators as samp uses them, with , to avoid mixing both versions.
AW: How to split numbers and set a dot in it -
tMike - 03.11.2012
Thanks a lot guys.