Could anyone help me in converting an 18 digit string numeric to BigInteger in java
ie;a string "0x9999999999999999"
should appear as 0x9999999999999999
numeric value.
One way is to use the BigInteger(String value, int radix) constructor: String inputString = "290f98"; BigInteger result = new BigInteger(inputString, 16); assertEquals("2690968", result. toString()); In this case, we're specifying the radix, or base, as 16 for converting hexadecimal to decimal.
You can use the BigDecimal class to hold a double. BigDecimal k = BigDecimal. valueOf(doublevalue);
You can specify the base in BigInteger constructor.
BigInteger bi = new BigInteger("9999999999999999", 16);
String s = bi.toString(16);
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