range of bytes is -128 to 127 why this 128-1 in the positive side. why both side is not equal. why this one is subtracted from the right side.
byte 1 byte Stores whole numbers from -128 to 127
range of bytes is -128 to 127 why this 128-1 in the positive side. why both side is not equal. why this one is subtracted from the right side.
byte 1 byte Stores whole numbers from -128 to 127
[-128, 128] contains 257 values but 8 bits can only distinguish 28=256 values.
-128 to -1 is 128 values +
0 is 1 value +
1 to 128 is 128 values
That's because you count 0
as well!
1 byte is 8 bits, which is 2^8
i.e 256
numbers.
So we have 128 negative numbers (-1 to -128), a 0, and we left with only 127 positive numbers.