
为什么不为此使用Java功能:
如果您的数字较小(小于您的数字),则可以使用:
Integer.parseInt(hex, 16)将十六进制-字符串转换为整数。
String hex = "ff" int value = Integer.parseInt(hex, 16);
对于像您这样的大数字,请使用
public BigInteger(String val, int radix)
BigInteger value = new BigInteger(hex, 16);
@See JavaDoc:
- Integer.parseInt(字符串值,int基数)
- BigInteger(字符串值,int radix)
欢迎分享,转载请注明来源:内存溢出
微信扫一扫
支付宝扫一扫
评论列表(0条)