Is there a template for the standard way of permuting bits in accordance with the permutation table, which sets the result for each bit position - which position is taken from the source.
those. table 0322will create the result 0011from0010
My current strategy was to read each table entry - create a bitmask, and then execute the binary code AND the mask and source, OR, which with a cumulative result.
to process the first record in the table:
result |= ( ( (int) pow(2,table[0]) & source)
It just seems expensive and repetitive and homegrown. Am I missing some obvious standard easier way?
source
share