As the title of this question tells I want to know the best way to mix blocks of bits within an integer (especially 64bit unsigned)
for example I have 8bit integer, where it's bits are 0000 1111 mix 4bits by 4 bits = 0101 0101
example 2: 0010 0110
0 1 1 0 right *0.0.1.0 left* = 00011100 mix 4bits by 4 bits = 0001 1100 Simple is, . places filled with bits of right block
What I am doing rightnow:
uint64_t mix32(uint64_t v) {
uint64_t ret=0;
int x=0;
for(int i=0; i<32; i++) {
setbit(ret, x, getbit(v, i));
x++;
setbit(ret, x, getbit(v, i+32));
x++;
}
return ret;
}
where setbit is a macro that sets or clears the bit on certain position. What exactly I need is mix each 32bits with next 32bits mix each 16bits with next 16bits mix each 16bits with after next 16bits mix each 8bits with next 8bits etc... I hope I can do rest if one example of such bit operations is available. I have looked on google a lot, but ended up with tutorials which do not demonstrate such scenario.
Stay well.