I understand the concept of a range of -127 to 128 and why it might be handy to preserve twos complement. Nonetheless, for this purpose, while adding 128 will work, it will result in an array that has the first 128 bytes flipped with the second 128 bytes; one that defeats the point of having an array indexed by character number. You can flip them back, but my solution is to write a method that adds 256 if the value of the byte is negative and returns it casted if positive. This can easily be implemented as a filter, making its application straightforward. |