C Programming Bitwise OperatorsPritesh
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
- Sometimes it become mandatory to consider data at bit level.
- 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.
- C Programming provides us different bitwise operators for manipulation of bits.
- Bitwise operators operates on Integer,character but not on float,double
- Using bitwise operators we can manipulate individual bits easily
- C programming supports 6 bitwise operators –
List of bitwise operators
|Operator||Name of Operator|
Bitwise operator rules
|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|