Josh Simmons:
> You could also just...
>
> uint32_t next_pow_2(uint32_t n)
> {
> n -= 1;
> n |= n >> 1;
> n |= n >> 2;
> n |= n >> 4;
> n |= n >> 8;
> n |= n >> 16;
> return n + 1;
> }
My version with bsr is faster.
Bye,
bearophile