Please help me solve this exception:-
String strBinary="100000000000000001000000000000000000000000000000000000000000000000000000";
System.out.println("length is " + strBinary.length());
long intParse=Long.parseLong(strBinary, 2);
System.out.println("int parsed is " + intParse);
String hexString=Long.toHexString(intParse);
System.out.println(hexString);
Output is 72 along with NumberFormatException while parsing using Long.parseLong..
But till yesterday it was running absolutely fine for this input also..
does it have anything to do with the length…
I am actuallly trying to convert String into its equivalent Hex value.
Please help….
A
longcan hold 64 bit of data. The biggest value alongcan represent is 9223372036854775807 (or 263-1). The string you try to parse is a lot larger than that.You might be able to go somewhere by using the
BigIntegerclass, which can handle arbitrary-sized integer values (effectively restricted by memory, of course).