Many thanks!
The lookup idea is nice and clean. I will use it as I only have 9 different bits.
However, your second option is the one I was (foolish) looking for. In my code, this could be the line:
# return the first less significant bit set. return $_ for grep { $bit & 1<<$_ } (0..8)';
In reply to Re^2: Which bit is set? (inverse of (1<<$value) operator)
by wirito
in thread Which bit is set? (inverse of (1<<$value) operator)
by wirito
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |