forked from algorithmzuo/algorithm-primary
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathCode01_PrintBinary.java
More file actions
65 lines (54 loc) · 1.03 KB
/
Code01_PrintBinary.java
File metadata and controls
65 lines (54 loc) · 1.03 KB
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
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
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);
}
}