I have a certain binary number for example: 11110000 And a mask with exactly 4 bits set: 10101010 Im searching for a fast operation that would return the 4 bits of the input corresponding to the positions where the mask is set:
11110000 10101010 output:1100
In here I use a u8 to u4 but imagine this for u64 to u32. Is there a fast way to do this (in Rust or C) without looping?
I tried looping the indexes, and linear decomposition. Both are very slow as one requires looping the other requires a matrix decomposition.