I am trying to convert a String
String sn = "71b01d67076bae7f77834fc8de6f7fd5d82c83118debce5b";
to Decimal format. The Decimal number appears to be to big to fit into the normal int so I attempted using the BigInteger class in java like so:
public static void main(String[] args){
BigInteger n;
try{
n = new BigInteger(Integer.toString(Integer.parseInt(sn, 16)));
}catch(NumberFormatException e){
System.out.println("Number Format Exception in main: ");
e.printStackTrace();
throw new RuntimeException(e);
}
}
And this is the exception I get:
Exception in thread "main" java.lang.RuntimeException: java.lang.NumberFormatException: For input string: "71b01d67076bae7f77834fc8de6f7fd5d82c83118debce5b" at ***.******.RSA.main(RSA.java:17) Caused by: java.lang.NumberFormatException: For input string: "71b01d67076bae7f77834fc8de6f7fd5d82c83118debce5b" at java.lang.NumberFormatException.forInputString(Unknown Source) at java.lang.Integer.parseInt(Unknown Source) at ***.******.RSA.main(RSA.java:13)
I haven't found any other examples to help convert such a large hexadecimal number to a BigInteger.
I am probably overlooking some minor aspect but could really use another pair of eyes right now.
Thanks,

New Topic/Question
Reply



MultiQuote




|