package lecture11; public class Main { public static void unpackShort(short num) { // regard num as upper lower where they // mean the obvious thing int lower = num & 0xFF; // upper stuff is 0 num = num >> 8; int upper = num & 0xFF; // send this out via FLAP // send upper first, then lower } public static void unpack(int num) { // // ____________________________ // | b0 | b1 | b2 | b3 | == num // ---------------------------- // // << high end low end >> // // so num == 1 ==> b0==0, b1==0, b2==0, b3==1 // int b0=0, b1=0, b2=0, b3=0; // // set b3 as the lowest byte of data from num? // b3 = num & 0xFF; num = num >> 8; b2 = num & 0xFF; num = num >> 8; b1 = num & 0xFF; num = num >> 8; b0 = num & 0xFF; System.out.println("b0 = " + b0); System.out.println("b1 = " + b1); System.out.println("b2 = " + b2); System.out.println("b3 = " + b3); // if num were a FLAP seq number // send out b2 and then b3 } public static void main(String[] args) { int num=0x0102030F; unpack(num); } }