Beefy Boxes and Bandwidth Generously Provided by pair Networks
more useful options
 
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)';


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

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 chanting in the Monastery: (12)
As of 2014-12-18 13:37 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    Is guessing a good strategy for surviving in the IT business?





    Results (51 votes), past polls