Skip to content

Instantly share code, notes, and snippets.

@dailybird
Created April 7, 2017 03:28
Show Gist options
  • Save dailybird/a43fd96a3d42dbefc43b35f566099ce8 to your computer and use it in GitHub Desktop.
Save dailybird/a43fd96a3d42dbefc43b35f566099ce8 to your computer and use it in GitHub Desktop.
Find the number of 1 in binary.
int upperBit(x)
{
int count = 0;
while(x)
{
count++;
x = x & (x-1);
}
return count;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment