-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathbit.java
More file actions
42 lines (29 loc) · 819 Bytes
/
Copy pathbit.java
File metadata and controls
42 lines (29 loc) · 819 Bytes
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
public class bit {
public static void OddOrEven(int n){
int bitmask = 1;
if((n & bitmask) == 0){
System.out.println("Binary number is even");
}
else{
System.out.println("Binary number is not even");
}
}
public static int GetBit(int n, int i){
int bitmask = 1 << i;
if((n & bitmask) == 0){
return 0;
}
return -1;
}
public static void main(String args[]){
System.out.println( 6 & 7);
System.out.println( 7 | 8);
System.out.println( 8 | 9);
System.out.println( 7 ^ 8);
System.out.println( ~ 6);
System.out.println( 4 << 2);
System.out.println( 4 >> 2 );
OddOrEven(110);
System.out.println(GetBit(10, 2));
}
}