@Test public void testuint2bytes() { int control; byte[] observed; byte[] expected; control = 2145845231; expected = new byte[]{(byte) 0x7f, (byte) 0xe6, (byte) 0xff, (byte) 0xef}; observed = BitConverters.uint2bytes(control); assertTrue(bytesEqual(expected, observed)); }
public static byte[] uint2bytes(int in) { byte out[] = new byte[4]; if (in < 0) { in = 0 - in; } out[3] = int2ubyte(in & 0xff); in >>= 8; out[2] = int2ubyte(in & 0xff); in >>= 8; out[1] = int2ubyte(in & 0xff); in >>= 8; out[0] = int2ubyte(in & 0xff); return out; }
BitConverters { public static byte[] uint2bytes(int in) { byte out[] = new byte[4]; if (in < 0) { in = 0 - in; } out[3] = int2ubyte(in & 0xff); in >>= 8; out[2] = int2ubyte(in & 0xff); in >>= 8; out[1] = int2ubyte(in & 0xff); in >>= 8; out[0] = int2ubyte(in & 0xff); return out; } }
BitConverters { public static byte[] uint2bytes(int in) { byte out[] = new byte[4]; if (in < 0) { in = 0 - in; } out[3] = int2ubyte(in & 0xff); in >>= 8; out[2] = int2ubyte(in & 0xff); in >>= 8; out[1] = int2ubyte(in & 0xff); in >>= 8; out[0] = int2ubyte(in & 0xff); return out; }  }
BitConverters { public static byte[] uint2bytes(int in) { byte out[] = new byte[4]; if (in < 0) { in = 0 - in; } out[3] = int2ubyte(in & 0xff); in >>= 8; out[2] = int2ubyte(in & 0xff); in >>= 8; out[1] = int2ubyte(in & 0xff); in >>= 8; out[0] = int2ubyte(in & 0xff); return out; }  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[] uint2bytes(int in) { byte out[] = new byte[4]; if (in < 0) { in = 0 - in; } out[3] = int2ubyte(in & 0xff); in >>= 8; out[2] = int2ubyte(in & 0xff); in >>= 8; out[1] = int2ubyte(in & 0xff); in >>= 8; out[0] = int2ubyte(in & 0xff); return out; }  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);  }