Bitwise Right Shift
operators (>>):
If a=10, calculate a>>2
means 2:
This operator shifts the bits
of the number towards right a specified number of positions. The symbol for
this operator is >>, read it as double greater than. If we write
a>>n, the meaning is to shift the bits of a towards right n positions.
Following diagram shows Shifting bits towards right 2 times:
This Operator shifts the bits of the number towards right a specified number of positions. If we write a>>n , means shift the bits of a towards right n positions.
#Example program on all the
Bitwise operators
a=10
b=11
print('~a=',~a) #
print('a&b=',a&b)
print('a|b=',a|b)
print('a^b=',a^b)
print('a<<2=',a<<2)
print('a>>2=',a>>2)
"""output
==================
~a= -11
a&b= 10
a|b= 11
a^b= 1
a<<2= 40
a>>2= 2
>>>
"""
Related Video: https://www.youtube.com/watch?v=Ui8F9tCTl1U&feature=youtu.be
Next topic:Bitwise
XOR Operator (^)
Previous topic:Bit
wise Left shift operator (<<)
No comments:
Post a Comment