UnsignedNumberUtil { public static boolean isWithinUnsignedLong(BigInteger value) { return value.bitLength() <= 64 && value.compareTo(BigInteger.valueOf(0)) >= 0; } 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 isWithinUnsignedLong_test() { assertAll( () -> assertThat(UnsignedNumberUtil.isWithinUnsignedLong(UnsignedNumberUtil.UNSIGNED_LONG_MAX)).isTrue(), () -> assertThat(UnsignedNumberUtil.isWithinUnsignedLong(BigInteger.valueOf(0))).isTrue(), () -> assertThat(UnsignedNumberUtil.isWithinUnsignedLong(new BigInteger("18446744073709551616"))).isFalse(), () -> assertThat(UnsignedNumberUtil.isWithinUnsignedLong(BigInteger.valueOf(-1))).isFalse() ); }