Each bit can take two values, 0 and 1.
Since you have eight bits, and each can take values independent of the other bits, an 8-bit variable can take 2*2*2*2*2*2*2*2 = 2**8 = 256 distinct values.
It's up to the programmer to decide whether those values come from the [-128; 127] range, or from the [0; 255] range (both contain 256 different values). We call the former "signed 8-bit integers" and the latter "unsigned 8-bit integers".
Signed values are usually represented using two's complement.
Java's byte
is an example of an 8-bit signed two's complement integer
but why is it 2 to 8 power? thats the key question. Instead of adding 128, 64, 32, 16, 8, 4, 2, 1
Those numbers that you list are all powers of two: 128=2**7, 64=2**6, 32=2**5, ..., 1=2**0
. It is easy to show algebraically that when you add them up you get the next power of two minus one: 128+64+32+16+8+4+2+1=256-1
.