Octal in PAWN
#1

I want to write a function that changes 010 (10 in PAWN) to 8, 020 (20 in PAWN) to 16 etc.
Reply
#2

You mean 80% of something?

pawn Код:
stock GetOctal(value)
{
    new newvalue = value/100*80;
    return newvalue;
}
Reply
#3

no, octal from C/C++

00001 = 1
00002 = 2
00004 = 4
00010 = 8
00020 = 16
00040 = 32
00100 = 64
etc.
Reply
#4

Just explain me what does it do and I'll create you mathematics formula.
Reply
#5

Quote:
Originally Posted by [MG]Dimi
Посмотреть сообщение
Just explain me what does it do and I'll create you mathematics formula.
Dude, you can't create an formula for it.
****** it and read more about it.
Reply
#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


Forum Jump:


Users browsing this thread: 2 Guest(s)