Fast 2D matrix of bits

bearophile bearophileHUGS at lycos.com
Tue Sep 20 00:22:36 PDT 2011


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


More information about the Digitalmars-d mailing list