开发者

Ever any performance different between Java >> and >>> right shift operators?

Is there ever reason to think the >> (signed) and >>> (unsigned) right bit-shift operators in Java would perform differently? I can't detect any difference on my machine.

This is purely an academic question; it's never going to be the bottleneck I'm sure. I know: it's best to write what you mean foremost; use开发者_StackOverflow >> for division by 2, for example.

I assume it comes down to which architectures have which operations implemented as an instruction.


No. Your compiler will translate these to bytecode and the JVM will interpret the bytecode for your architecture. I think it is safe to assume that your architecture has an instruction set which includes both operations be done in few clock cycles.

Anyway, there is a difference in the behavior of these operators, so it isn't like you can just interchange them.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜