Public Group

# Simple data type question

This topic is 3795 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

## Recommended Posts

I'm reading this book, it says that bits have two values 0 and 1. Now it says byte is 8 bits long. But it has a range of 0 to 255. I don't really see how 8 bits is equivalent to storing 256 possible values. If a bit only has 2 values, and a byte is 8 bits.. wouldn't it be 8 times 2... 16? This makes me feel pretty stupid, not grasping simple basics, but if anyone would help explain it.. in a way I could understand. I'd be grateful.

##### Share on other sites
Someone can undoubtedly give you a better explanation but basically, since each bit's value is independent of the others it is 2^8 (256) not 2*8(16). Anyone else with more depth?

##### Share on other sites
Think of it this way: The number of values you can store with a number of bits is just the number of different combinations you can achieve with those bits.

For example, with 1 bit you have 2 combinations: 0 and 1
With 2 bits you have 4: 00,01,10,11
With 3 bits, you have 8: 000,001,010,011,100,101,110,111
With 4 bits, you have 16, and so on and so on

Generally with n bits you have 2^n different values. So for 8 bits you have 2^8=256.

##### Share on other sites
Think about counting in decimal you have the digits 0-9(10 digits). If you have an 8 digit number you can count higher than 80(8*10) right?
In fact you can count to 10^8.
In this case it is the same thing except you only have 2 digits.

1. 1
Rutin
65
2. 2
3. 3
4. 4
5. 5

• 16
• 10
• 29
• 20
• 9
• ### Forum Statistics

• Total Topics
633415
• Total Posts
3011766
• ### Who's Online (See full list)

There are no registered users currently online

×