Octal in PAWN
#6

I write a plugin that has a 'chmod' function, in C/C++ using the octal number like 0777 0644 etc.
if i say, that people must use 1 2 4 8 16 (1 | 2 | 4) etc. it would be strange, would prefer to use the 0777 0644 etc.
000 = 0
010 = 8
020 = 16
030 = 24 (010 + 020)
040 = 32
050 = 40 (010 + 040)
060 = 48 (040 + 020)
070 = 56 (010 + 020 + 040)

like using 1 2 4 8 16 32 64 128 256 512 1024 etc.

//EDIT:
pawn Код:
stock OctalValue(x)
{
    new str[10], rn;
    valstr(str, x);
    for(new z, i = strlen(str) - 1; i >= 0; i--, z++)
        rn += (str[i] - '0') * floatround(floatpower(8.0, z));

    return rn;
}
is there any easier way?
Reply


Messages In This Thread
Octal in PAWN - by Terminator3 - 26.12.2011, 12:17
Re: Octal in PAWN - by [MG]Dimi - 26.12.2011, 12:20
Re: Octal in PAWN - by Terminator3 - 26.12.2011, 12:24
Re: Octal in PAWN - by [MG]Dimi - 26.12.2011, 12:26
Re: Octal in PAWN - by WooTFTW - 26.12.2011, 12:49
Re: Octal in PAWN - by Terminator3 - 26.12.2011, 12:50

Forum Jump:


Users browsing this thread: 2 Guest(s)