in reply to fast bit twiddling
If you wanted to compare bit's 1 and 2 for equality, you could do...
if( ( 2 & $x ) == ( ( 1 & $x) << 1) ) ... [download]