Posts: 61
Threads: 4
Joined: Oct 2014
Reputation:
0
10.03.2016, 06:19
(
Последний раз редактировалось AdmBot; 10.03.2016 в 07:18.
)
Hi! I've modified the include made by AbyssMorgan (for unsigned long variables) and i have some issues formating long numbers.
I've tried with strval, but doesn't work for long number. I think the solutin is to make a function to format string (as numbers).
Ex: for 250000000000 show 250,000,000,000 but not working for number upper 1,450,000,000. Could anyone help me?
Posts: 1,208
Threads: 36
Joined: Apr 2015
10.03.2016, 08:49
(
Последний раз редактировалось AbyssMorgan; 10.03.2016 в 16:59.
)
PHP код:
new buffer[64];
GetLYString(250,999,buffer);
printf("Value: %s",buffer); // print 250000000999
//Commas can add modifying buffer
format(buffer,sizeof buffer,"%s",AddCommasLY(buffer));
Posts: 61
Threads: 4
Joined: Oct 2014
Reputation:
0
10.03.2016, 15:31
(
Последний раз редактировалось AdmBot; 10.03.2016 в 16:55.
)
How can i modify the buffer, i need to use commas.
Posts: 1,208
Threads: 36
Joined: Apr 2015
PHP код:
stock AddCommasLY(string[]){
new tStr[32];
format(tStr,sizeof(tStr),"%s",string);
if(strlen(tStr) < 4) return tStr;
new iPos = strlen(tStr), iCount = 1;
while(iPos > 0)
{
if(iCount == 4)
{
iCount = 0;
strins(tStr,",",iPos,1);
iPos++;
}
iCount++;
iPos--;
}
return tStr;
}
Posts: 61
Threads: 4
Joined: Oct 2014
Reputation:
0
It works. Thank you very much!
Posts: 61
Threads: 4
Joined: Oct 2014
Reputation:
0
@AbyssMorgan, another problem: I want to calculate the bank interest using this long number. You can i do this?
Posts: 1,208
Threads: 36
Joined: Apr 2015
12.03.2016, 16:52
(
Последний раз редактировалось AbyssMorgan; 16.09.2017 в 08:53.
)
//edit: to improve it did not work exactly
Update LY.inc and use
PHP код:
CalculatePercentLY(&prefix,&suffix,Float:percent = 0.0,increase = true,limitprefix = DEFAULT_MAX_LY_PREFIX)
Download:
LY.inc
Example:
PHP код:
new a, b, c[LY_STRING_LEN];
a = 250;
b = 999999999;
//input: 250 999 999 999
CalculatePercentLY(a,b,10.0,true);
GetLYString(a,b,c);
printf(c); //Output: 276 099 999 999