Formula for calculating the << and >>

In java, a number of shift left by n bits, this number is multiplied by 2 ^ n, this right is divided by 2 ^ n.

 

Such as:

8>>2 = 2  (8/2^2)

15 << 3 = 120  (15*(2^3))

 

2 & 3 = -2 (minus the complement is also involved in operation)

Guess you like

Origin www.cnblogs.com/linliquan/p/11433698.html