Hi,
I have a problem with some bits. I have two bytes (surprise surprise) with 12 bits (they are padded with four zeros). The bytes SHOULD look like this (x and n represent bits):
| x n x n x n x n | x n x n 0 0 0 0 |
However, they are coming in as such:
| n x n x n x n x | 0 0 0 0 n x n x |
Obviously, this is backwards. I am trying to figure out how to basically reverse the bits so I can manipulate them correctly. I've tried looking at two's complement, bit shifting, bitwise operations, etc., and I don't know how to do this. I found an external library that apparently can do this, but at this point, I'm just dying to know how the algorithm works; I don't just want a reverse() method.
Can anyone offer any advice/tutorials/whatever?
Thanks