[英]Java convert a HEX String to a BigInt
Hi am trying to convert a hex string such as String hexStr = "1b0ee1e3"; 您好我正在尝试转换十六进制字符串,如String hexStr =“1b0ee1e3”; to a bigInt, ideally i'd like to convert hexStr to a bigint in its decimal form, 对于一个bigInt,理想情况下我想将hexStr转换为十进制形式的bigint,
I can convert a string to a bigInt w/o issues but when the string contains hex values i run into problems 我可以将字符串转换为bigInt w / o问题,但是当字符串包含十六进制值时,我会遇到问题
Have you tried: 你有没有尝试过:
BigInteger bigInt = new BigInteger(hexString, 16);
For example: 例如:
import java.math.*;
public class Test {
public static void main(String[] args) {
String hexStr = "1b0ee1e3";
BigInteger bigInt = new BigInteger(hexStr, 16);
System.out.println(bigInt); // Prints 453960163
}
}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.