Reading bitswise for 'FALSE' In the sketch I'm working on, I'm storing several 1-bit values representing different boolean states in a single byte, trying to save precious RAM.
(example for 5 boolean states: dec10 = b00001010, the five states are 0, 1, 0, 1, 0)

I'm then using an if statement to determine if the relevant bit is TRUE or FALSE:
if ((options&gt;&gt;3) &amp; 1 == 1)  

The above will evaluate true when the relevant bit is 1, so if I want to carry out something in that case, great, no problem!  

However, if I want my if statement to evaluate TRUE in the event that the relevant bit is 0, I can't work out what code I need.



I thought the problem might be that the other 'non-relevant' bits were interfering, so I tried bit shifting the LSB all the way to MSB position and then shifting back to LSB:
if ((options&lt;&lt;4&gt;&gt;7) &amp; 1 == 0)
but this still isn't doing what I'm trying to achieve (and seems like a lot of work for the processor).

It also feels like I've tried just about every combination of ~&amp;0, !&amp;0, ==0, !=0, ~&amp;1, !&amp;1, ==1, !=1 there is, but I must have missed something...  

Can anyone tell me how I get an if statement to evaluate true in the event that the bit is a zero?
The simplest thing is just to mask an individual bit, not do any shifting:

if (options &amp; 0x04) {
    // Do something if true
} else {
    // Do something if false
}


Or, to invert it:

if (!(options &amp; 0x04)) {
    // Do something if false 
} else {
    // Do something if true.
}


The thing with C is that 0 is false, and anything else is true.  So if your options variable contains 0b00001010 and you AND it with 0x04 (which is HEX for 0b00001000) you end up with 0b00001000.  That is 0x04, which is something other than 0, so it's true.  

If options contains 0b00000010 and you AND it with 0x04, you get 0b00000000, which is 0. Since 0 is false the result is false.

You don't care what the actual number is - you only care if it's 0.