I have a 32-bit unsigned int and I need to extract bits at given positions and make a new number out of those bits. For example, if I have a 0xFFFFFFFF and want bits 0,10,11 my
Beware, untested code:
for(i = 0; i < count; i++) { bitmask = 1 << positions[i]; bit = (bytes & bitmask)!=0; result = (result << 1)|bit; }