Bit Manipulation in C

Bitwise Operators

& AND
| OR
^ XOR
~ NOT

Truth Tables

AND (“&”)

truth table

+--------+--------+-----------------+
| bit a  | bit b  | a & b (a AND b) |
+--------+--------+-----------------+
|     0  |     0  |               0 |
|     0  |     1  |               0 |
|     1  |     0  |               0 |
|     1  |     1  |               1 |
+--------+--------+-----------------+

byte example

     11001000  
   & 10111000 
     -------- 
   = 10001000

Read more “Bit Manipulation in C”