Search code examples
binary

Calculating the total number of possibilities in binary?


How would you calculate the total number of possibilities that binary can have in one byte?

00000000 through 11111111 = num_of_possibilities


Solution

  • The total number is 2 to the power of the number of bits. So, eight bits has 28 possible values.

    If you really mean "how to compute it", consider that each bit has two possible values.

    So one bit implies 2 values.

    Two bits has one set of two values of each possible value of the other bit, so

    00
    01
    10
    11
    

    which means a total of 4 (= 2×2) values.

    Three bits gives four values twice, or 8 (=4×2) values. Four bits, 8×2; five bits, 16×2, and so on.

    So eight bits is 2×2×2×2×2×2×2×2 or 256.