Created
          June 12, 2014 02:58 
        
      - 
      
 - 
        
Save cynx/771dd017b33d33ba812d to your computer and use it in GitHub Desktop.  
    Count number of bits
  
        
  
    
      This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
      Learn more about bidirectional Unicode characters
    
  
  
    
  | int bitcount(unsigned x) | |
| { | |
| int b; | |
| for(b = 0;x != 0;x &= x-1) | |
| ++b; | |
| return b; | |
| } | 
  
    Sign up for free
    to join this conversation on GitHub.
    Already have an account?
    Sign in to comment