The Shift
Operators is used when we want to shift a binary bit either in the left
direction or right direction.
Shift Operators are classified into two categories C Language:
1. Left Shift Operator:
- Left Shift Operator performs operations on the binary bits. The left shift operator is a type of binary operator so we need two operands to shift the position of the bits to the left side and add zeroes to the empty space on the right side after shifting the bits.
2. Right Shift Operator:
- Right Shift Operator performs operations on the binary bits. The Right shift operator is a type of binary operator so we need two operands to shift the position of the bits to the right side and add zeroes to the empty space on the left side after shifting the bits.
Operator |
Name of the Operator |
What it does |
How it is used |
<< |
Left Shift Operator |
shifts the number of bits to the left side |
a << 1 |
>> |
Right Shift Operator |
shifts the number of bits to the right side |
a >> 2 |
Example : 25 << 2 // 25 = 00011001
Output: 100 // 01100100
Example : 25 >> 2 // 25 = 00011001
Output: 6 // 00000110
0 Comments
Post a Comment