Java convert a HEX String to a BigInt
Hi am trying to convert a hex string such as String hexStr = "1b0ee1e3"; to a bigInt, ideally i'd like to convert hexStr to a bigint in its d开发者_开发知识库ecimal form,
I can convert a string to a bigInt w/o issues but when the string contains hex values i run into problems
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
}
}
精彩评论