书上说:对于int型整数a,a>>33和a>>1结果是一样的,我不明白!书上还说:a>>32的结果还是a原来的数字。经事实验证,确实是这样,可是书上是这样说的:对Java来说,有符号的数据(Java语言中没有无符号的数据类型)用“>>”移位时,如果最高位是0,左边移空的高位就填入0,如果最高位是1,左边移空的高位就填入1。所以我就不明白了,希望有明白的师兄能给予指导,谢谢啦!!
解决方案 »
- C:\%e6%96%b0%e5%bb%ba\UTF-8\xxxx.txt 这是什么编码?怎么转换成中文字符串?
- 初学请教问题:could not create java virtual machine?
- 内部类对象可以调用外部类类成员嘛?
- 二进制文件中,一个整数有可能只占2个字节吗?
- 求教!!求教!!求教!!求教!!求教!!
- jbuilder 9 的applet 如何在网页用HTML调用?
- javaMail端口问题
- 为什末我的IE不能支持java?
- 在JB6的Swing组的jlabel的icon属性中,为什么无法选中已经添加到工程中的.gif图形文件?
- java 基础:Swing中的按钮太难看了,怎样改变模式呢?
- HttpURLConnection无法打开含有中文的链接???
- 写前台html页面时,实现代码关键字变色怎么办??
对于long型整数的移位,使用右边操作数的低6位。
可以参看java 语言规范 15.19 shift operators.
of the right-hand operand are used as the shift distance. It is as if the right-hand
operand were subjected to a bitwise logical AND operator & (§15.22.1) with the
mask value 0x1f (0b11111). The shift distance actually used is therefore always in
the range 0 to 31, inclusive.
If the promoted type of the left-hand operand is long, then only the six lowestorder
bits of the right-hand operand are used as the shift distance. It is as if the
right-hand operand were subjected to a bitwise logical AND operator & (§15.22.1)
with the mask value 0x3f (0b111111). The shift distance actually used is therefore
always in the range 0 to 63, inclusive.
现在很多学编程开发的,特别是学JAVA和C#的一票人,很多计算机基础都不知道就开始开工,真是让人无语,这也太民工化了。
对于long型整数的移位,使用右边操作数的低6位。====好像有道理