I know there are similar questions on this site, however, I couldn't seem to find something that really helped me out with the issue i'm having.
So far:
I have 1-byte (8-bits) that could be any combination of 1's and 0's.
Ex: 11000010 is my byte of data. (Little-Endian)
What i need to do is determine if the Most Significant Bit (MSB), in this case the 11, is either a 00, 01, 10, 11 and from there do some other things.
I have so far gotten the program to output the Byte as 11000010 (stored in a string) and am trying to extract the 11 from it. (If i can figure that out then creating a switch case or if statement to check what the contents is simple enough on my own).
**I haven't been so good with C++ which is why i'm asking for assistance.
Any help is greatly appreciated.
It seemes that you want to get the value of first two most significant bits.
This can be done by filtering them out and moving the value 6 bits to the left:
unsigned char input;
unsigned char output;
input = whatever_you_want;
output = input & 0xc0; //0xc00 = 0b11000000
output = output >> 6;
Collected from the Internet
Please contact [email protected] to delete if infringement.
Comments