You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
66 lines
1.0 KiB
66 lines
1.0 KiB
package class01;
|
|
|
|
public class Code01_PrintBinary {
|
|
|
|
public static void print(int num) {
|
|
for (int i = 31; i >= 0; i--) {
|
|
System.out.print((num & (1 << i)) == 0 ? "0" : "1");
|
|
}
|
|
System.out.println();
|
|
}
|
|
|
|
public static void main(String[] args) {
|
|
// 32位
|
|
// int num = 4;
|
|
//
|
|
// print(num);
|
|
//
|
|
//
|
|
// int test = 1123123;
|
|
// print(test);
|
|
// print(test<<1);
|
|
// print(test<<2);
|
|
// print(test<<8);
|
|
//
|
|
//
|
|
// int a = Integer.MAX_VALUE;
|
|
// System.out.println(a);
|
|
|
|
// print(-1);
|
|
// int a = Integer.MIN_VALUE;
|
|
// print(a);
|
|
|
|
// int b = 123823138;
|
|
// int c = ~b;
|
|
// print(b);
|
|
// print(c);
|
|
|
|
// print(-5);
|
|
|
|
// System.out.println(Integer.MIN_VALUE);
|
|
// System.out.println(Integer.MAX_VALUE);
|
|
|
|
// int a = 12319283;
|
|
// int b = 3819283;
|
|
// print(a);
|
|
// print(b);
|
|
// System.out.println("=============");
|
|
// print(a | b);
|
|
// print(a & b);
|
|
// print(a ^ b);
|
|
|
|
// int a = Integer.MIN_VALUE;
|
|
// print(a);
|
|
// print(a >> 1);
|
|
// print(a >>> 1);
|
|
//
|
|
// int c = Integer.MIN_VALUE;
|
|
// int d = -c ;
|
|
//
|
|
// print(c);
|
|
// print(d);
|
|
|
|
}
|
|
|
|
}
|