-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathBitwiseOperator.java
More file actions
51 lines (44 loc) · 1.26 KB
/
BitwiseOperator.java
File metadata and controls
51 lines (44 loc) · 1.26 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
package classes;
class BitwiseOperator
{
public static void main(String[] args)
{
// 자바 메서드로 진법 변환
int data = 13;
System.out.println(Integer.toBinaryString(data));
System.out.println(Integer.toOctalString(data));
System.out.println(Integer.toHexString(data));
System.out.println();
System.out.println(Integer.parseInt("1101",2));
System.out.println(Integer.parseInt("15",8));
System.out.println(Integer.parseInt("D",16));
System.out.println();
// 다양한 진법 표현
System.out.println(13);
System.out.println(0b1101);
System.out.println(015);
System.out.println(0x0D);
System.out.println();
// 비트 연산자
// @AND 비트 연산자
System.out.println(3 & 10);
System.out.println(0b0011 & 0b1010);
System.out.println(0x03 & 0x0A);
System.out.println();
// @OR 비트 연산자
System.out.println(3 | 10);
System.out.println(0b0011 | 0b1010);
System.out.println(0x03 | 0x0A);
System.out.println();
// @XOR 비트 연산자
System.out.println(3 ^ 10);
System.out.println(0b0011 ^ 0b1010);
System.out.println(0x03 ^ 0x0A);
System.out.println();
// @NOT 비트 연산자
System.out.println(~3);
System.out.println(~0b0011);
System.out.println(~0x03);
System.out.println();
}
}