UnsignedNumberUtil { public static BigInteger getUnsignedLong(ByteBuffer byteBuffer) { byte[] buffer = new byte[8]; byteBuffer.get(buffer); return new BigInteger(1, buffer); } private  UnsignedNumberUtil(); static short getUnsignedByte(byte value); static int getUnsignedShort(ByteBuffer byteBuffer); static int getUnsignedShort(byte[] bytes); static long getUnsignedInt(ByteBuffer byteBuffer); static long getUnsignedInt(byte[] bytes); static BigInteger getUnsignedLong(ByteBuffer byteBuffer); static byte[] toBytes(int ushortValue); static byte[] toBytes(long uintValue); static byte[] toBytes(BigInteger unsignedLongValue); static boolean isWithinUnsignedByte(int value); static boolean isWithinUnsignedShort(int value); static boolean isWithinUnsignedInt(long value); static boolean isWithinUnsignedLong(BigInteger value); static final short UNSIGNED_BYTE_MAX; static final int UNSIGNED_SHORT_MAX; static final long UNSIGNED_INT_MAX; static final BigInteger UNSIGNED_LONG_MAX; }
@Test void getUnsignedLong_form_UNSIGNED_LONG_MAX_test() { byte[] bytes = new byte[8]; bytes[0] = (byte) 0xFF; bytes[1] = (byte) 0xFF; bytes[2] = (byte) 0xFF; bytes[3] = (byte) 0xFF; bytes[4] = (byte) 0xFF; bytes[5] = (byte) 0xFF; bytes[6] = (byte) 0xFF; bytes[7] = (byte) 0xFF; assertThat(UnsignedNumberUtil.getUnsignedLong(ByteBuffer.wrap(bytes))).isEqualTo(UnsignedNumberUtil.UNSIGNED_LONG_MAX); }