Skip to content

Instantly share code, notes, and snippets.

@peroon
Created October 9, 2018 18:48
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 peroon/cd3962db704f8ac09679079d8abf0a54 to your computer and use it in GitHub Desktop.
Save peroon/cd3962db704f8ac09679079d8abf0a54 to your computer and use it in GitHub Desktop.
static int Pow2(uint n)
{
--n;
int p = 0;
for (; n != 0; n >>= 1) p = (p << 1) + 1;
return p + 1;
}
// Pow(31) -> 32
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment