Education is not limited to just classrooms. It can be gained anytime, anywhere... - Ravi Ranjan (M.Tech-NIT)

This tutorial will explain you the basic idea behind C Programming Bitwise Operators. Why bitwise operators are introduced in C Programming.

C Programming Bitwise Operators

Byte Level Operations

Till now we have seen all the operators uses variables and constants for expression solving and they operate all the calculations at byte level. like –

```res = num1 + num2;
```

In the above line all are integers which requires two/four/eight bytes memory in C programming depending on the compiler.

Bit Level Operations

1. Sometimes it become mandatory to consider data at bit level.
2. We have to operate on the individual data bit. We also need to turn on/off particular data bit during source code drafting, at that time we must use bitwise operator for doing our task easier.
3. C Programming provides us different bitwise operators for manipulation of bits.
4. Bitwise operators operates on Integer,character but not on float,double
5. Using bitwise operators we can manipulate individual bits easily
6. C programming supports 6 bitwise operators –

List of bitwise operators

 Operator Name of Operator ~ One’s Compliment >> Right Shift << Left Shift & Bitwise AND | Bitwise OR ^ Bitwise XOR

Bitwise operator rules

 Input Bits AND OR XOR 0 0 0 0 0 0 1 0 1 1 1 0 0 1 1 1 1 1 1 0

Summary :

Operator Usage
One's compliment operator Used to turn a bit on/off
AND bitwise operator Used to mask particular part of byte
Left shift bitwise operator Used to shift the bit to left
Right shift bitwise operator Used to shift the bit to right