So... we do have bitwise ops now or we don't have bitwise ops? I tried using them, couldn't get them to work, looked it up on the wiki to see if they were implemented, found this thread on the forum and... the permissions func doesn't work, parsing error... so we don't have these? Personally I would appreciate it if we did.
Here is a crude workaround that will at least enable bitfields. (bnot doesn't work exactly like a binary not because it doesn't fill all the bits, it only reverses the bits from the highest used power of two and below.)
int band(int a, int b)
{
int ret=0;
int c=0;
int Da=0;
int Db=0;
a=2*a;
b=2*b;
while(a>0 && b>0)
{
a=a/2;
b=b/2;
Da=a % 2;
Db=b % 2;
if (Da+Db==2) ret=ret+2^c;
c=c+1;
a=a-Da;
b=b-Db;
}
return ret;
}
int bnot(int a)
{
int ret=0;
int c=0;
int Da=0;
a=2*a;
while (a>0)
{
a=a/2;
Da=a%2;
if (Da==0) ret=ret+2^c;
a=a-Da;
}
return ret;
}
int bor(int a, int b)
{
int ret=0;
int c=0;
int Da=0;
int Db=0;
a=2*a;
b=2*b;
while (a>0 && b>0)
{
a=a/2;
b=b/2;
Da=a%2;
Db=b%2;
if (Da+Db>0) ret=ret+2^c;
c=c+1;
a=a-Da;
b=b-Db;
}
if (b>a) a=b;
while (a>0)
{
a=a/2;
Da=a%2;
if (Da==1) ret=ret+2^c;
c=c+1;
a=a-Da;
}
return ret;
}