We have 1 byte
, which is 8 bits
, which is 2^8
. Now 2 bytes
should be 2 * 1 byte
, which is 2 * 2^8 = 2^9
, but actually 2 bytes is 2^16
. What am I missing here? It seems like 2 bytes
isn't 2 * 1 byte
, it's more like 1 byte * 1 byte
, but this should give you byte^2
, which doesn't make sense.
Can please someone explain to me what I am getting wrong here?
Best Answer
So far so good
Your use of "which is" here seems to be the root of your confusion. A more precise statement is:
Or generally:
If this is unclear, it may help you to think about decimal digits (0-9). One decimal digit can represent 10 distinct values (0-9), two decimal digits can represent 10^2=100 distinct values (0-99), N decimal digits can represent 10^N distinct values.
A bit is literally a binary digit. One bit can represent two distinct values (0-1), two bits can represent four distinct values, and N bits can represent 2^N distinct values.
So eight bits can represent 2^8 distinct values, and sixteen bits can represent 2^16 distinct values.