Created
July 22, 2011 07:30
-
-
Save blankyao/1099032 to your computer and use it in GitHub Desktop.
返回不小于num的最小2的幂指数
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
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