I'm trying to Parse a potential Long value from a binary String, yet I still get an error when trying to do so.
public String func1(String B, String C, String D)
{
long b = Long.parseLong(B, 2);
long c = Long.parseLong(C, 2);
long d = Long.parseLong(D, 2);
String value = Long.toString((b & c) | (b & d), 2);
return value;
}
Exception in thread "main" java.lang.NumberFormatException:
For input string: "1010101010101010101010101010101010101010/*....*/10101011"
at java.lang.NumberFormatException.forInputString(Unknown Source)
at java.lang.Long.parseLong(Unknown Source)
...
Can anyone explain this? Thanks!
A constant holding the maximum value a long can have, 2^63 - 1.
So, the last String which you can convert to Long with 2 radix is: "111111111111111111111111111111111111111111111111111111111111111"
If you will try parse value bigger than it, you will get java.lang.NumberFormatException