Modulo in pawno?
#1

Its passible to use modulo(%) in pawno?
5500%1000 = 500. Thats what should happen.

But i made a stock and its not working :<

Here is the stock:
PHP код:
stock GetNum(num)
{
    new 
num1[256],num2[256],num3[256],final[256];
    if(
num 999 && num 1000000) {
    
format(num1,sizeof(num1),"%d",(num/1000));
    
format(num2,sizeof(num2),"%d",(num%1000));
    
format(final,sizeof(final),"%d,%d",num1,num2); }
    if(
num 999999999 && num 1000000000000) {
    
format(num1,sizeof(num1),"%d",(num/1000000));
    
format(num2,sizeof(num2),"%d",(num%1000000/1000));
    
format(num3,sizeof(num3),"%d",(num%1000));
    
format(final,sizeof(final),"%d,%d,%d",num1,num2,num3); }
    return final;
    } 
When i enter there there any number its shouls return the number with ',' like this
55470 -> 55,470. but thats return me else numbers :<.

Or if you can give me else stock that do it and works will be nice :]
Reply
#2

Pawn has a modulo operator built in.

Код:
main()
{
	new var = 5500%1000;
	printf("%d", var);
}
Output is 500.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)