java:int的移位距离限制为31位 [英] java : shift distance for int restricted to 31 bits
本文介绍了java:int的移位距离限制为31位的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
知道为什么java中int的移位距离限制为31位(右手操作数的低5位)?
Any idea why shift distance for int in java is restricted to 31 bits (5 lower bits of the right hand operand)?
http://docs.oracle.com/javase/specs/jls /se7/html/jls-15.html#jls-15.19
x >>> n
我可以看到类似的问题 java位操作>>>转移但没有人指出正确答案
I could see a similar question java Bit operations >>> shift but nobody pointed the right answer
推荐答案
移位距离限制为31位,因为Java int有32位位。将 int
数字移动超过32位将产生相同的值(0或 0xFFFFFFFF
,具体取决于初始值值和您使用的班次操作。)
The shift distance is restricted to 31 bits because a Java int has 32 bits. Shifting an int
number by more than 32 bits would produce the same value (either 0 or 0xFFFFFFFF
, depending on the initial value and the shift operation you use).
这篇关于java:int的移位距离限制为31位的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文