Beefy Boxes and Bandwidth Generously Provided by pair Networks
Don't ask to ask, just ask
 
PerlMonks  

Re^2: Which bit is set? (inverse of (1<<$value) operator)

by wirito (Acolyte)
on Sep 17, 2012 at 12:11 UTC ( #994023=note: print w/ replies, xml ) Need Help??


in reply to Re: Which bit is set? (inverse of (1<<$value) operator)
in thread Which bit is set? (inverse of (1<<$value) operator)

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)';

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://994023]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others romping around the Monastery: (13)
As of 2016-06-28 12:10 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    My preferred method of making French fries (chips) is in a ...











    Results (357 votes). Check out past polls.