http://stackoverflow.com/questions/8637142/what-does-this-bit-manipulating-function-do
unsigned long ccNextPOT(unsigned long x){ x = x - 1; x = x | (x >> 1); x = x | (x >> 2); x = x | (x >> 4); x = x | (x >> 8); x = x | (x >>16); return x + 1;} | |||||||||||||
|
2 Answers
2 | The OR and SHIFT statements fills with ones all bits of | ||||
|
0 | This function rounds x up to the next highest power of 2. It's exactly the code in unsigned int v; // compute the next highest power of 2 of 32-bit vv--;v |= v >> 1;v |= v >> 2;v |= v >> 4;v |= v >> 8;v |= v >> 16;v++; | |||
|