打印整数的补码

public class IntegerExchange {

    public static void main(String[] args) {
        int a = -6;
        for (int i=0; i<32; i++) {
            int t = (a & 0x80000000>>>i)>>>(31-i);
            System.out.print(t);

        }
        System.out.println();

        System.out.println(Integer.toBinaryString(a));
    }
}

 

posted @ 2017-12-06 10:53  R4mble  阅读(171)  评论(0编辑  收藏  举报