快速判斷一個數是不是2的冪spa
#define is_power_of_2(x) (!((x) & (x - 1)))
已知一個數n,求m,使m >= n,且m是2的冪code
unsigned int fixsize(unsigned long size){ if(is_power_of_2(size)) return size; size |= size >> 1; size |= size >> 2; size |= size >> 4; size |= size >> 8; size |= size >> 16; return size + 1; }