Skip to content

Instantly share code, notes, and snippets.

@bysreg
Created February 10, 2016 00:34
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 bysreg/bfcf5846dcb4679c1ba2 to your computer and use it in GitHub Desktop.
Save bysreg/bfcf5846dcb4679c1ba2 to your computer and use it in GitHub Desktop.
next power of 2 for integer
static inline int nextPow2(int n)
{
n--;
n |= n >> 1;
n |= n >> 2;
n |= n >> 4;
n |= n >> 8;
n |= n >> 16;
n++;
return n;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment