Beefy Boxes and Bandwidth Generously Provided by pair Networks
Keep It Simple, Stupid
 
PerlMonks  

Re^4: Efficient bit counting with a twist.

by BrowserUk (Pope)
on Jun 01, 2013 at 09:49 UTC ( #1036400=note: print w/ replies, xml ) Need Help??

Help for this page

Select Code to Download


  1. or download this
    my $mask = hex($ARGV[0]);
    
    ...
    my $setbits = unpack("%32b*", $mask);
    
    printf("0x%x has %d set", $mask, $setbits);
    
  2. or download this
    C:\test>junk 0xff
    255    ## 3 bytes
    323535 ## 6 nybbles with bit patterns 0011 0010 0011 0101 0011 0101 
    0xff has 11 set
    
  3. or download this
    #! perl -slw
    use strict;
    ...
    255
    ff
    0xff has 8 set
    

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others scrutinizing the Monastery: (7)
As of 2015-07-05 20:16 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 (67 votes), past polls