Skip to content

Instantly share code, notes, and snippets.

@shumon84
Created March 27, 2017 18:04
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save shumon84/0d00dd5f598995fb30d1c08c8b384ee8 to your computer and use it in GitHub Desktop.
Save shumon84/0d00dd5f598995fb30d1c08c8b384ee8 to your computer and use it in GitHub Desktop.
int count_bits(int n)
{
int sum;
sum=(n>>1)&03333333333;
sum=n-sum-((sum>>1)&03333333333);
sum=((sum+(sum>>3))&0707070707)%077;
return sum;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment