alf » from archive
OMG, "unsigned int t = (v | (v - 1)) + 1; w = t | ((((t & -t) / (v & -v)) >> 1) - 1);" - http://graphics.stanford.edu/~seander/bithacks.html#NextBitPe...