wwe has asked for the wisdom of the Perl Monks concerning the following question:
I managed to get right output using the & operator $bitmask_value & 2, see example code:
could you please tell me if there is some major problem or if I can trust this code? thank yo in advanceuse strict; use warnings; my @bitmask_value = ( 512, 514, 210, 328, 2, 1, 65535 ); foreach my $bitmask_value ( @bitmask_value ) { print 'bit 2 is ', $bitmask_value & 2 ? 'set' : 'not set', " for v +alue [$bitmask]\n"; }
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: bitmask check
by Eliya (Vicar) on Mar 29, 2011 at 17:10 UTC | |
|
Re: bitmask check
by ikegami (Patriarch) on Mar 29, 2011 at 17:30 UTC | |
|
Re: bitmask check
by lostjimmy (Chaplain) on Mar 29, 2011 at 18:51 UTC | |
by Anonymous Monk on Nov 12, 2013 at 21:01 UTC |