Created
April 7, 2017 03:28
-
-
Save dailybird/a43fd96a3d42dbefc43b35f566099ce8 to your computer and use it in GitHub Desktop.
Find the number of 1 in binary.
This file contains 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 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