Left shift(<<) and right shift(>>) operators
This is a quick answer for what a left shift(<<) and right shift(>>) operators do in Java.
A left shift operator returns a value that is obtained by multiplying the left hand operand with 2 raised to the power of right hand operand. eg. 5 << 3 =" 5">> 2 = 5 / (2 raised to the power 2) = 2.
There are several factors that decides the behaviour of the operation. One is the sign of the integer.
A left shift operator returns a value that is obtained by multiplying the left hand operand with 2 raised to the power of right hand operand. eg. 5 << 3 =" 5">> 2 = 5 / (2 raised to the power 2) = 2.
There are several factors that decides the behaviour of the operation. One is the sign of the integer.
Comments
Post a Comment