十六进制输入的BigInteger NumberFormatException

时间:2018-10-01 15:06:53

标签: java biginteger numberformatexception

我不断收到java.lang.NumberFormatException.forInputString“ 9299ff” 我需要将其转换为十进制以使用乘法吗?我不确定为什么会一直收到此错误。

static BigInteger newP = new BigInteger("9299ff7061bff2d10d9b19653454453d6aed058b5331bea66a4b24e997aca5b6408e050f8e53d99be3f81f563a46b1dbfb51ff739c98f9ad38de2e2d48fdc6ba125604e15f6b76a03e3d64c09bfc7f5c635f80ca55747cf7d0f4839da6ceeb2c43e329021c6fd91f030251ef95180226d50dc1b4395471c69d60a676b263d2bb9f59884914db356bc6fe58d00a999c605a8cf6d246988531ffb79881501383dc092dcb97173c68d2548b7155006b31444cc7ab5c42b57128cd806d02c760e391");
static BigInteger newQ = new BigInteger("a3ec1a1cf64063fd97ad6a24e3509e6d04c36d5be75e3e567b4c713ee6bbbb3bbdcdfb6f89796a6e5d16624ccccff1d154a3b7e5d08a183be9b6e269031224f2d8e454541e22b6a71754a25385b5fdb1b54c69840d6336129d1f02bc39c155a849dfbed96bac2588a50b316499b84430b6104008852ba2b0c09601ca94aa591ff9f31fc6a8df338019e3bb83b5cad61a3bc76dede4d1224aed8c9d7883f8bbcb677164a2138592973af4dbd92bd9e7fcfcc4bbbf19e295bbb6ed14dc5c680311");
final static BigInteger newM = BigInteger.valueOf(65537);
static BigInteger newN = newP.multiply(newQ);


System.out.println(newN);

1 个答案:

答案 0 :(得分:6)

默认基数为10,您可以使用BigInteger​(String val, int radix)指定基数,尝试:

BigInteger newP = new BigInteger("your input", 16);