Anonymous Monk has asked for the wisdom of the Perl Monks concerning the following question:

If I have a number say "66", and I want to see if the "64" bit is set ( 01000000 ), how do I do this in Perl?

Replies are listed 'Best First'.
Re: Bit Set Test
by friedo (Prior) on May 02, 2007 at 16:03 UTC

    You do it the same way as in C, using bitwise operators. E.g.

    my $mask = 1 << 6; # 0100 0000 if ( $mask & 66 ) { print "It's on" } else { print "It's off" }
Re: Bit Set Test
by akho (Hermit) on May 02, 2007 at 16:10 UTC