“>"是什么意思?符号在Java中意味着什么? [英] What does the ">>" symbol mean in Java?
本文介绍了“>"是什么意思?符号在Java中意味着什么?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我在查看的某些代码中看到一行,上面写着(12 >> 1)-1).我打印出该值,结果为5.如果我将12更改为5,则结果为1.
I see a line in some code I'm looking at and it says (12 >> 1) - 1). I print that value out and it comes out as a 5. If I change the 12 to 5, it comes out as a 1.
">>"符号到底在做什么?
What is the ">>" symbol doing exactly?
推荐答案
12是 1100
(二进制).右移一位(>>是按位右移运算符)会产生
12 is 1100
in binary. A right shift (>> is the bitwise right shift operator) by one bit produces
1100 -> 0110
结果是6.
因此,我们拥有了
6 - 1 = 5
这篇关于“>"是什么意思?符号在Java中意味着什么?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文