Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl-Sensitive Sunglasses
 
PerlMonks  

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

by grizzley (Chaplain)
on Sep 17, 2012 at 11:17 UTC ( #994014=note: print w/ replies, xml ) Need Help??


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

In description of unpack there is following method to count number of bits:

# Count the bits in a chunk of memory (e.g. a select vector) unpack( '%32b*', $mask );
Update: sorry, I misunderstood question. If you have string of bits with one bit set, then you could try just $bitstring =~ /1(0*)$/; $originalvalue = length($1)+1;


Comment on Re: Which bit is set? (inverse of (1<<$value) operator)
Select or Download Code
Re^2: Which bit is set? (inverse of (1<<$value) operator)
by wirito (Acolyte) on Sep 17, 2012 at 12:13 UTC
    Nope, it's a two-byte int, not a strings filled with 0's and 1's.

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others drinking their drinks and smoking their pipes about the Monastery: (6)
As of 2015-07-07 01:22 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    The top three priorities of my open tasks are (in descending order of likelihood to be worked on) ...









    Results (86 votes), past polls