Java右移整数32 [英] Java right shift integer by 32

查看:86
本文介绍了Java右移整数32的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试将整数右移32,但结果是相同的数字. (例如5 >> 32是5.)

I am trying to right shift an integer by 32 but the result is the same number. (e.g. 5 >> 32 is 5.)

如果我尝试对Byte和Short执行相同的操作,则可以使用.例如,(字节)5 >> 8"为0.

If I try to do same operation on Byte and Short it works. For example, "(byte)5 >> 8" is 0.

整数有什么问题?

推荐答案

...如果左侧操作数的提升类型为int,则仅将右侧操作数的五个最低位用作移位距离.

... If the promoted type of the left-hand operand is int, only the five lowest-order bits of the right-hand operand are used as the shift distance.

所以移动32无效.

这篇关于Java右移整数32的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆