-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathblockTest.java
More file actions
36 lines (29 loc) · 897 Bytes
/
Copy pathblockTest.java
File metadata and controls
36 lines (29 loc) · 897 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
import java.util.*;
public class blockTest{
public static void main(String[] args){
byte bay[] = new byte [2];
bay[0] = (byte)1;
bay[1] = (byte)128;
int lowBlock = bay[1] & 0xff;
int highBlock = bay[0];
highBlock = highBlock << 8;
int total = highBlock | lowBlock;
total = total;
System.out.println("Low block: " + lowBlock);
System.out.println ("int of bay1 :" + (int)bay[1]);
System.out.println("Total: " + total);
int block2 = 128; //101100011
System.out.println("Block no is: " + block2);
int mask = 0xFF; //11111111
int block3 = block2 & mask;
//bay[2] = block3;
block2 = block2 >>> 8; //00000001
System.out.println("b2: " + block2);
System.out.println("b3: "+ block3);
System.out.println ("put them together");
int block = block2 << 8;
System.out.println("block shifted < 8: " + block2);
block = block | block3;
System.out.println (block);
}
}