Why is the range of bytes -128 to 127 in Java?

Viewed 84728

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.

8 Answers

after taking two's compliment of number we always left with one state of representing number extra so we turn that state to -128.

Related