Skip to content

Instantly share code, notes, and snippets.

@blankyao
Created July 22, 2011 07:30
Show Gist options
  • Save blankyao/1099032 to your computer and use it in GitHub Desktop.
Save blankyao/1099032 to your computer and use it in GitHub Desktop.
返回不小于num的最小2的幂指数
static unsigned int nextpow2(unsigned int num) {
--num;
num |= num >> 1;
num |= num >> 2;
num |= num >> 4;
num |= num >> 8;
num |= num >> 16;
return ++num;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment