How many bits....How do I calculate this?


I am new to this and I just don’t understand how to find these answers. I have looked for videos or other examples but I have not had any luck. I understand using the flippy do but this just doesn’t make sense

“What is the minimum number of bits you would need to encode the 26 letters of the alphabet plus a space - a total of 27 characters?”

“8 bits is enough to represent 256 different numbers. How many total bits do you need to represent 512 (twice as many) numbers?”


I believe you’ll find the answers here:

I’ll take a crack at the explanation…
When looking for the number of bits needed to represent a given number of characters (letters, numbers, or symbols), you need to look at the powers of 2. For example, the reason that 5 bits are required to represent 27 characters is that 2^2=4 (4 is not enough), 2^3 is 8 (still not enough)… 2^5 is 32. Since 32 > 27, at 2^5, or 5 bits, you now have enough unique permutations to represent all 27 characters.


For both questions, it is helpful to know how many values you can represent with different quantities of bits. The flippy-do is 8 bits. You can count from 0-255 (or 00000000 to 11111111 in binary) so 256 different values. This formula may be helpful for you. It works with binary, decimal, hex or any number system:

So for the first question, how many bits do you need for the alphabet and a space? Or in other words, how many bits are needed to represent at least 27 values? Well, 4 bits can only give you 16 possible values. (2^4 = 15). 5 bits (2^5) gives you 32 unique values, which is enough unique values to hold the alphabet and a space. Answer is 5 bits.

The second question, you can do without needing math by knowing that every additional bit doubles the amount of values you can have. 8 bits, 2^8 = 256, as the problem says, and 2^9 = 512, so 9 bits would double the amount of values to 512.