标签:style blog ar color sp for on div log
1 // Demonstrate the bitwise NOT. 2 class NotDemo { 3 public static void main(String[] args) { 4 byte b = -34; 5 6 for(int t = 128; t > 0; t = t/2) { 7 if((b & t) != 0) System.out.print("1 "); 8 else System.out.print("0 "); 9 } 10 System.out.println(); 11 12 // reverse all bits 13 b = (byte) ~b; 14 15 for(int t = 128; t > 0; t = t/2) { 16 if((b & t) != 0) System.out.print("1 "); 17 else System.out.print("0 "); 18 } 19 } 20 }
执行结果:
1 1 0 1 1 1 1 0
0 0 1 0 0 0 0 1
标签:style blog ar color sp for on div log
原文地址:http://www.cnblogs.com/fatoland/p/4171460.html