Bit Twiddling Hacks: intercalar bits da maneira óbvia [fechado]
estou interessado neste problema
Intercalar bits da maneira óbvia(porhttp://graphics.stanford.edu/~seander/bithacks.html)
unsigned short x; // Interleave bits of x and y, so that all of the
unsigned short y; // bits of x are in the even positions and y in the odd;
unsigned int z = 0; // z gets the resulting Morton Number.
for (int i = 0; i < sizeof(x) * CHAR_BIT; i++) // unroll for more speed...
{
z |= (x & 1U << i) << i | (y & 1U << i) << (i + 1);
}
alguém pode me explicar como isso funciona com um exemplo?
por exemplo, se tivermosx = 100101
ey = 010101
, qual será o resultado?