JAVA的正码反码与补码

package work01;

public class Example01 {
public static void main(String[] args) { short a = 138;
//正数的原码、反码与补码相同
byte b, c = 0; b = (byte)a;
//显式转换,采用补码赋值,降低数据精度
System.out.println("b=" + b); c += a++;
//等价于 c = c + a; a++;
System.out.println("c=" + c);
System.out.println("a=" + a); byte d = (byte)(b + b);
//表达式中类型自动提升,采用补码相加,高位溢出
System.out.println("d=" + d);
}
}

WRITTEN BY: