Professional Documents
Culture Documents
Bitwise Right Shift Operator in C
Bitwise Right Shift Operator in C
Bitwise Right Shift Operator in C
1.
2.
It is denoted by >>
Bit Pattern of the data can be shifted by specified number of
Positions to Right
3. When Data is Shifted Right , leading zeros are filled with zero.
4. Right shift Operator is Binary Operator [Bi two]
5. Binary means , Operator that require two arguments
Right Shift by 2
Leading 2 Blanks
Right ========>>>>>>
Syntax :
[variable]>>[number of places]
Output :
Number is Shifted By 1 Bit : 30
Number is Shifted By 2 Bits : 15
Number is Shifted By 3 Bits : 7
It is denoted by <<
Bit Pattern of the data can be shifted by specified number of Positions to Left
When Data is Shifted Left , trailing zeros are filled with zero.
Left shift Operator is Binary Operator [Bi two]
Binary means , Operator that require two arguments
Left Shift
Trailing Zeros
Replaced by 0
(Shown in RED)
<<<<<=======Left
Output :
Number is Shifted By 1 Bit : 120
Number is Shifted By 2 Bits : 240
Number is Shifted By 3 Bits : 480
Now after shifting all the bits to left towards MSB we will get following bit pattern
0000 0000 0011 1100
<< 1
------------------0000 0000 0111 1000
= 60
= 120
Decimal Value
Converted Value
0 Bit
2^0
1 Bit
2^1
2 Bits
2^2
3 Bits
2^3
4 Bits
2^4
16
5 Bits
2^5
32
6 Bits
2^6
64
7 Bits
2^7
128
8 Bits
2^8
256