Reputation: 449
It's easy to check if a single bit in variable is 1. Ex. check if the third bit of variable is 1, just do
variable & 0100 ==0100
How to check if a single bit is 0?
Upvotes: 1
Views: 1375
Reputation: 449
say you want to check the second bit is 0
targetBit = 0010
(~( variable) & targetBit ) == targetBit
Upvotes: 1