How to de-interleave bits (UnMortonizing?)
Given that you know that every other bit is 0 in your application, you can do it like this: x = (x | (x >> 1)) & 0x33333333; x = (x | (x >> 2)) & 0x0f0f0f0f; x = (x | (x >> 4)) & 0x00ff00ff; x = (x | (x >> 8)) & 0x0000ffff; … Read more