0

I am confused when I read the details section that says 1 byte which is 8 bits gives us a potential of 2^8 or 256 possible values. (https://en.wikipedia.org/wiki/8-bit_computing)

If i am doing the math correctly

2^0 = 1
2^1 = 2
2^2 = 4
2^3 = 8
2^4 = 16
2^5 = 32
2^6 = 64
2^7 = 128

Total = 255

The way i see it there is total or possible 255 values.

Dinero
  • 1,070
  • 2
  • 19
  • 44

1 Answers1

2

0 is also a value so for 8 bits, the value range is 0-255.

00000000 is the lowest and 11111111 (255) is the highest.

2^x gives you the total number of possible values for x bits. You should be using 2^x to get the number of possible combinations only where x > 0. If x = 0, it points to a no-bit scenario which is irrelevant.

For your case, it is not correct to sum values from 2^0 to 2^7. The correct approach should be just calculating 2^8, which is 256.

e-mre
  • 3,305
  • 3
  • 30
  • 46
  • am i not including 0 when i do 2^0 – Dinero Feb 05 '20 at 11:44
  • 1
    Actually no, 2^0 gives the number of possible alternative states when there are no bits (0 bits). It does not make sense from a computing perspective but from a mathmetical perspective it points to a single state with no alternatives, so it is 1. 2^1=2 so with a single bit you can have 2 states, 0 and 1 .... so on. – e-mre Feb 05 '20 at 11:47