int next_power_of_2(int x) {
x--;
x |= (x >> 1);
x |= (x >> 2);
x |= (x >> 4);
x |= (x >> 8);
x |= (x >> 16);
x++;
return x;
}
转载于:https://my.oschina.net/luckykiddie/blog/100322
int next_power_of_2(int x) {
x--;
x |= (x >> 1);
x |= (x >> 2);
x |= (x >> 4);
x |= (x >> 8);
x |= (x >> 16);
x++;
return x;
}
转载于:https://my.oschina.net/luckykiddie/blog/100322