I have an unsigned char and I need to check bits 1 and 2 to find the status. What is the best way to determine the last 2 bits?
I am attempting to perform an OR, but my results aren’t correct. Any help would be appreciated. Thanks.
Example:
10101000 = off
10101001 = on
10101010 = error
10101011 = n/a
if(data_byte_data[0] | 0xfe)
//01
else if(data_byte_data[0] | 0xfd)
//10;
else if(data_byte_data[0] | 0xfc)
//11
else if(data_byte_data[0] | 0xff)
//00
I would do something like: