@Test public void testint2ubyte() { int i; int[] controlInts = {0, 2, 4, 8, 16, 32, 64, 127, 128, 129, 255}; byte[] expectedBytes = {(byte) 0x00, (byte) 0x02, (byte) 0x04, (byte) 0x08, (byte) 0x10, (byte) 0x20, (byte) 0x40, (byte) 0x7f, (byte) 0x80, (byte) 0x81, (byte) 0xff}; for (i = 0; i < controlInts.length; i++) { assertEquals(expectedBytes[i], BitConverters.int2ubyte(controlInts[i])); } }
public static byte int2ubyte(int in) { in &= 0xff; return (in < 128) ? (byte) in : (byte) (in - 256); }
BitConverters { public static byte int2ubyte(int in) { in &= 0xff; return (in < 128) ? (byte) in : (byte) (in - 256); } }
BitConverters { public static byte int2ubyte(int in) { in &= 0xff; return (in < 128) ? (byte) in : (byte) (in - 256); }  }
BitConverters { public static byte int2ubyte(int in) { in &= 0xff; return (in < 128) ? (byte) in : (byte) (in - 256); }  static String int16bit2hex(int i16); static int hex16bit2int(String in); static int nibble2Int(byte nibble); static byte int2Nibble(int in); static int ubyte2int(byte in); static byte int2ubyte(int in); static String byte2hex(byte ubyte); static byte[] uint2bytes(int in); static String bytes2hex(byte[] bytes); }
BitConverters { public static byte int2ubyte(int in) { in &= 0xff; return (in < 128) ? (byte) in : (byte) (in - 256); }  static String int16bit2hex(int i16); static int hex16bit2int(String in); static int nibble2Int(byte nibble); static byte int2Nibble(int in); static int ubyte2int(byte in); static byte int2ubyte(int in); static String byte2hex(byte ubyte); static byte[] uint2bytes(int in); static String bytes2hex(byte[] bytes);  }