in reply to Boolean Encoding in Integers
Pack and unpack are also great for bit twiddling. Takes me
back to my c++ days and bit fields. I must say I prefer $bitsting&1<<$bit (where bit is the 0 based index of
the bit to get, and is the log2 of the divisor to get
a given bit, ie the 128's bit would be bit no. 7) to /% for getting bits out of the bit string/int.
It seems much more natural, and considerablty less opaque,
and you can define things like $MYFLAG = 1<<3 and test for it in the bit string like if($bits&$MYFLAG) or even if($bits&($MYFLAG|$MYFLAG2)) and all his boolean algebra buddies.
'The fickle fascination of and Everlasting God'
- Billy Corgan, The Smashing Pumpkins