In C it is possible to perform logical operations on values and manipulate each bits of it. In the following, some of the operations will be show.
NOTE: For more information and examples on the practical use of bitwise operations, you should go through the ASM Tutorial as well.
The unary inverting operator ~ inverts each bit in a value. Use: res = ~ value.
The binary and operator & and's each bit of two values with each other. Use: res = value1 & value 2.
The binary or operator | or's each bit of two values with each other. Use: res = value1 | value 2.
The binary xor operator ^ xor's each bit of two values with each other. Use: res = value1 ^ value 2.
The binary rightshift >> operator shifts a value n bits to right. Use: res = val >> n.
The binary leftshift << operator shifts a value n bits to the left. Use: res = value1 << n.