in reply to fast bit twiddling

If you have a scalar that has a number for you to twidle bits, why not use the & operator?

If you wanted to compare bit's 1 and 2 for equality, you could do...

if( ( 2 & $x ) == ( ( 1 & $x) << 1) ) ...
And if the expression gets complex, put it in a function, and call it isValid or something..