1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47
| public class Integer_PrintBinrary { public static void main(String[] args) { int num = 83928328; print(num);
print(1<<1); print(1<<2); print(1<<4); print(1<<8);
print(-1); int min = Integer.MIN_VALUE; print(min);
int b = 11213; int c = ~b; print(b); print(c);
int bit1 = 1231221; int bit2 = 5342312; print(bit1); print(bit2); System.out.println("----------"); print(bit1 | bit2); }
private static void print(int num) { for (int i = 31; i >=0 ; i--) { System.out.print((num & (1 << i)) == 0 ? "0":1 ); } System.out.println(); } }
|