求大于n且是2的幂的最小整数

1
2
3
4
5
6
7
8
9
10
int roundup_pow_of_two(int num)  
{
int n = 0;
while(num)
{
n++;
num = num >> 1;
}
return n==0? 1 : 1<<n;
}