Why is the range of bytes -128 to 127 in Java?
问题 I don't understand why the lowest value a byte can take is -128 . I can see that the highest value is 127 , because it's 01111111 in binary, but how does one represent -128 with only 8 bits, one of which is used for the sign? Positive 128 would already be 8-bit, i.e. 10000000 , and then you would need a 9th bit to represent the negative sign. Could someone please help explain this to me. 回答1: The answer is two's complement. In short, Java (and most modern languages) do not represent signed