Bitwise Operators in C
Bitwise operator is an operator used to perform bitwise operations on bit patterns or binary numerals that involve the manipulation of individual bits.
Bitwise operator are used in Low-level programming for applications such as device drivers, cryptographic software, video decoding software, memory allocators, compression software and graphics.
There are five types of Bitwise operator.
- AND BITWISE
- OR BITWISE
- EXCLUSIVE OR
- LEFT SHIFT
- RIGHT SHIFT
Implementation of Bitwise Operator
Result is true only if both operands are true. It can be used to set up a mask to check the values of certain bits.The symbol of this operator is &.
Result is true if any of the operands is true.The symbol of this operator is |.
It is based on AND or OR Operator.It also helps to swap two variables without using a third one. The symbol of this operator is ^.
Shifts first operand a number of bits to the left as specified in the second operand, shifting in zeroes from the right.The symbol of this operator <<.
Shifts first operand a number of bits to the right as specified in the second operand, and discards displaced bits and the symbol of this operator is >>.
Code for Bitwise Operator