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.

Comments

Popular posts from this blog

Multi Tenant applications using PostgreSQL Row Level Security

Recovering Dell Laptop Windows OS using factory image from Linux bootable USB drive

java.util.logging - Bad level value for property: org.openqa.level