Beefy Boxes and Bandwidth Generously Provided by pair Networks
XP is just a number
 
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 having an uproarious good time at the Monastery: (6)
As of 2014-12-27 10:54 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

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





    Results (177 votes), past polls