Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to convert an 18 digit numeric string to BigInteger?

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.

like image 826
Raji Avatar asked Dec 11 '10 12:12

Raji


People also ask

How do I convert string to BigInteger?

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.

How do you convert double to BigInteger?

You can use the BigDecimal class to hold a double. BigDecimal k = BigDecimal. valueOf(doublevalue);


1 Answers

You can specify the base in BigInteger constructor.

BigInteger bi = new BigInteger("9999999999999999", 16);
String s = bi.toString(16);   
like image 94
Klark Avatar answered Oct 21 '22 13:10

Klark