Given N bits, how many integers can be represented in binary?

后端 未结 2 1368
傲寒
傲寒 2021-01-29 05:15

Suppose you have 14 bits. How do you determine how many integers can be represented in binary from those 14 bits?

Is it simply just 2^n? So 2^14 = 16384?

Please

2条回答
  •  臣服心动
    2021-01-29 06:13

    Yes, it's that easy as 2^n.

    A bit can have 2 distinct values: 0 and 1.

    If you have 2 bits, than you have 4 distinct values: 00, 01, 10, 11. The list goes on.

    Combinatorics has the simple counting formula

    N = n_1 ⋅ n_2 ⋅ ... ⋅ n_k
    

    Since n_1 = n_2 = n_k = 2 you can reduce the formula to

    N = 2 ^ k 
    

提交回复
热议问题