What Is Bitwise Operator? Explain Left Shift And Right Shift.
3 years ago
C Programming
Bitwise Operator: – bitwise operator are used for manipulating the data at bit level, also called as (bit level programming) bitwise operator. Bit level programing consist at 0 and 1.
|
Operator |
Description |
|
& |
Bitwise And |
|
| |
Bitwise OR |
|
^ |
Bitwise Exclusive OR [XOR] |
|
<< |
Bitwise Left Shift |
|
>> |
Bitwise Right Shift |
Left Shit And Right Shift
Left shift: – the left shift operator is multiply by 2.
Ex-
|
0 |
0 |
0 |
0 |
1 |
1 |
1 |
0 |
14
14 << 1
|
0 |
0 |
0 |
1 |
1 |
1 |
0 |
0 |
Output = 28
Right shift: – the left shift operator is divided by 2.
Ex-
|
0 |
0 |
0 |
0 |
1 |
1 |
1 |
0 |
14
14 >>
|
0 |
0 |
0 |
0 |
0 |
1 |
1 |
1 |
Output = 28
Rusma Khadka
Dec 29, 2022