public class DataDemo {

    /**
      A little utility for converting Java bytes into
      a string consisting of two hex digits. For example:

         toHexString((byte)9) = "0x09"
         toHexString((byte)42) = "0x2a"
         toHexString((byte)-1) = "0xff"

    */
	public static String toHexString(byte b) {
		// get 32 bit (8 chars) string:
		String result = Integer.toHexString(b);
		// chop off first 6 chars:
		int numChars = result.length();
		if (numChars == 1) {
			result = "0" + result;
		} else {
		    result = result.substring(numChars - 2);
		}
		// prepend 0x:
		result = "0x" + result;
		return result;
	}

	public static void displayResult(byte result) {
		System.out.println("hex = " + toHexString(result));
		System.out.println("dec = " + result);
		System.out.println("+++++");
	}

	public static void test1() {

		byte b1 = 12, b2 = (byte)225, b3 = 0x7b;
		byte mask = (byte)0xaa;

		displayResult(b1);
		displayResult(b2);
		displayResult(b3);

		displayResult((byte)(b1 ^ mask));
		displayResult((byte)(b1 | mask));
		displayResult((byte)(b1 & mask));
		displayResult((byte)(~b1));
		displayResult((byte)(b1 >> 1));
		displayResult((byte)(b1 << 1));
		displayResult((byte)(b1 + b3));

	}

	public static void main(String[] args) {
		test1();

	}


}