I'm trying to convert a long or int to a byte array. I'm restricted to using
Java 1.3. I'm first trying to use Long.toBinaryString(myLong), and then pass 8-character substrings into Byte.parseByte(mySubstring, 2), but I'm getting errors like:
java.lang.NumberFormatException: Value out of range. Value:"11110100" Radix:2
What am I doing wrong? A byte is 8-bit, two's complement right? So shouldn't it be able to handle the above
string?