public static BigInteger decodeQuantity(String value) {
        if (isLongValue(value)) {
            return BigInteger.valueOf(Long.parseLong(value));
        }

        if (!isValidHexQuantity(value)) {
            throw new MessageDecodingException("Value must be in format 0x[0-9a-fA-F]+");
        }

        try {
            return parsePaddedNumberHex(value);
        } catch (NumberFormatException e) {
            throw new MessageDecodingException("Negative ", e);
        }
    }
@Test
    public void testQuantityDecode() {
        assertEquals(Numeric.decodeQuantity("0x0"), (BigInteger.valueOf(0L)));
        assertEquals(Numeric.decodeQuantity("0x400"), (BigInteger.valueOf(1024L)));
        assertEquals(Numeric.decodeQuantity("0x41"), (BigInteger.valueOf(65L)));
        assertEquals(
                Numeric.decodeQuantity("0x7fffffffffffffff"),
                (BigInteger.valueOf((Long.MAX_VALUE))));
        assertEquals(
                Numeric.decodeQuantity("0x99dc848b94efc27edfad28def049810f"),
                (new BigInteger("204516877000845695339750056077105398031")));
    }