Bitwise Operation : Operators Introduction
Bitwise Operation and Operators Introduction
- Sometimes it is mandatory to consider data at bit level.
- We have to operate on the individual data bit.We have to turn on/off particular data bit, at that time we must use bitwise operator for doing this task.
- C Programming provides us different bits for manipulating of bits.
Note : Bitwise Operator
- C Programming provides us 6 operators for manipulation of data a bit level
- These operators operates on Integer,character but not on float,double
- Using Bitwise Operators we can manipulate individual bits
Following are 6 bitwise Operators :
Operator |
Name of Operator |
~ |
One’s Compliment |
>> |
Right Shift |
<< |
Left Shift |
& |
Bitwise AND |
| |
Bitwise OR |
^ |
Bitwise XOR |
Rules of Bitwise Operators :
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 :
- One’s Compliment Operator is used to turn on or off any individual bit.
- Right Shift and Left Shift Operator is used to shift bit.
- AND Operator is used to Mask Particular Part of the Bit Pattern.