Меня интересует эта проблема
Перемещает бит очевидным способом
(из http://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); }
может кто-нибудь объяснить мне, как это работает с примером?
например, если мы имеем x = 100101
и y = 010101
, что будет результатом?