Here's an example I ran across:
private function bitwiseAnd(a:int, b:int):int {
var result:int = 0;
var n:int = 1;
while ((a > 0) && (b > 0)) {
if (((a % 2) == 1) && ((b % 2) == 1)) {
result += n;
}
a = a / 2;
b = b / 2;
n = n * 2;
}
return result;
}
So basically all I need then is bitwiseOr and bitwiseNot and I'm set.
The reason is that Pixel Bender doesn't support bitwise ops (inexplicably) but does support various math operations. Also they don't support loops for Flash either, but the above can just be expanded out.
I thought about doing bitwise ops without bitwise operators a while back, but couldn't picture how to do it. I wouldn't know how the above was derived logically either.