Search code examples
c++charbitwise-operatorsbit

How can I extract 12 bits from a 2 byte char array?


I am working on extracting data from binary files. One of the data values is packed into two bytes, but only 12 of the 16 bits contain the relevant information:Packed data structure.

Does anyone have a method to extract the 12 bits seen in this image? Let the two bits be stored in an unsigned char buffer[2].


Solution

  • > does with respect to a char the same thing it does with any other type - it returns 1 if the left side is greater than the right side, and 0 if it isn't.

    It doesn't make sense here.

    If you copied this from the Internet, I suspect the author wrote >> but the formatting got messed up by the website at some point.