【发布时间】:2013-11-16 03:19:07
【问题描述】:
这是我的代码:
public class test {
public static void main(String[] args) {
byte a=(byte)127, b=2;
byte c=(byte)(a*b);
System.out.println(c);
}
}
为什么结果是-2?
【问题讨论】:
-
一个字节只有八位长。
-
字节溢出,二进制补码变为负数
-
您是否知道您的(64 位?)CPU 将很难摆弄字节?
标签: java