The bitwise operators are the operators used to perform the operations on the data at the bit-level. When we perform the bitwise operations, then it is also known as bit-level programming. It consists of two digits, either 0 or 1. It is mainly used in numerical computations to make the calculations faster.
We have different types of bitwise operators in the C programming language. The following is the list of the bitwise operators:
Operator -Meaning of operator
& -Bitwise AND operator
| - Bitwise OR operator
^- Bitwise exclusive OR operator
~ -One's complement operator (unary operator)
<< -Left shift operator
>>- Right shift operator
Bitwise AND operator
Bitwise AND operator is denoted by the single ampersand sign (&). Two integer operands are written on both sides of the (&) operator. If the corresponding bits of both the operands are 1, then the output of the bitwise AND operation is 1; otherwise, the output would be 0.
For example,
We have two variables a and b.
a =6;
b=4;
The binary representation of the above two variables are given below:
a = 0110
b = 0100
When we apply the bitwise AND operation in the above two variables, i.e., a&b, the output would be:
Result = 0100
As we can observe from the above result that bits of both the variables are compared one by one. If the bit of both the variables is 1 then the output would be 1, otherwise 0.
Let's understand the bitwise AND operator through the program.