I\'m trying to convert a couple of binary strings back to int. However it doesn\'t convert all my binary strings, leaving me a java.lang.NumberFormatException
The bits for "~0" are 11111111111111111111111111111111 (32 1's). Normally, this represents the number -1. The bits for "~1" are 11111111111111111111111111111110 (31 1's followed by a zero). Normally, this represents the number -2.
I tried "01111111111111111111111111111111" (a 0 and 31 1's), which represents the highest signed integer, in parseInt and there was no error. But I tried "10000000000000000000000000000000", which represents the minimum signed integer, and there was the error again.
The parseInt method seems to expect a "-" in the input to indicate that a negative number is desired. It looks like this method is detecting overflow in the integer and throwing the NumberFormatException.