In previous posts I talked about what a bit is, how you can use it to represent information, and how you can extend the information quantity by combining bits. I also noted how many bits fits in a byte. In this other post, I mentioned what a shift is and how you can use it to set bit flags on micro's registers. I realized that I needed a concept before introducing to shift to unset bit flags, but the truth is that I wanted that way. So, If you think you missed the logic part of the whole thing, then reading what it follows maybe will be useful to you.
You are familiar with operations with numbers. You substract or add numbers by using an operation. Those numbers you use are called operands and the symbol used is called operator. So, if you add 2 and 3 and you write in our math notation (a.k.a. you are not E.T.) it's supposed to be:
There we have + as operator and number 2 and 3 as operands, and 6 being the result. The whole thing is an operation, and it's called addition. Although I didn't mentioned, operands can be an element of any kind of sets numbers: real, integer, natural, etc, and the result will depend upon that. I mean, when you add the integer 2 with a real number not integer, the result will be a real number. Well, this things do not happen with bits operations. Operands are bits and the result is another bit. Again, C bits operations are defined between bytes, so, you don't actually use a bit in those operations. But before talking about language specifics, let's present the most common bits operations.