I think you want if (($a >> $b) & 1) { ... }. That checks to see if the $b'th bit (from the right) is on.
Jeff japhy Pinyan,
P.L., P.M., P.O.D, X.S.:
Perl,
regex,
and perlhacker How can we ever be the sold short or the cheated, we who for every service have long ago been overpaid? ~~ Meister Eckhart