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 decimal form,
I can convert a string to a bigInt w/o issues but when the string contains hex values i run into problems
BigInteger. toString() method returns the decimal String representation of this BigInteger. This method is useful to convert BigInteger to String. One can apply all string operation on BigInteger after applying toString() on BigInteger.
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 } }
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With