Dinero
Dinero

Reputation: 1160

256 possible values in a 8 bits

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.

Upvotes: 0

Views: 3234

Answers (1)

e-mre
e-mre

Reputation: 3373

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.

Upvotes: 2

Related Questions