What is the arithmetic left shift of Java – 01001?

I think this is 00010010

On the other hand, the logical left shift of 1 bit will be 10010

Is it correct?

Solution

For left shift, arithmetic and logical shift are the same

The only difference is shift right, where arithmetic shift right will copy the old MSB to the new MSB after the shift, so as to keep the negative number converted to positive during the shift

Wikipedia has a more detailed explanation

The content of this article comes from the network collection of netizens. It is used as a learning reference. The copyright belongs to the original author.
THE END
分享
二维码
< <上一篇
下一篇>>