What is the best algorithm to achieve the following:
0010 0000 => 0000 0100
The conversion is from MSB->LSB to LSB->MSB. All bits must be reversed; that is, this is not endianness-swapping.
What is the best algorithm to achieve the following:
0010 0000 => 0000 0100
The conversion is from MSB->LSB to LSB->MSB. All bits must be reversed; that is, this is not endianness-swapping.
This is for 32 bit, we need to change the size if we consider 8 bits.
Reading the input integer "num" in LSB->MSB order and storing in num_reverse in MSB->LSB order.
You might want to use the standard template library. It might be slower than the above mentioned code. However, it seems to me clearer and easier to understand.