Take the 2-minute tour ×
Mathematics Stack Exchange is a question and answer site for people studying math at any level and professionals in related fields. It's 100% free, no registration required.

I'm asking this question in the context of a program I'm trying to write, but the problem I'm having seemed to be more of a mathematical one. (Also, I'm not quite sure what tags should be applied to this question, so please feel free to edit them.)

I'm trying to figure out how to compute the number of possibilities in a given set of numbers, where certain number "bits" or "slots" can be binary, while others can be trinary.

First of all I know that I can do this: If I have say, two "bits". 00 And I know I can put two values into them: 1 or 0 The possible combinations are:

00, 01, 10, 11

Or four possibilities.

I can compute this beforehand by raising the number of spaces to the number of possibilities. (i.e. 2 to the 2nd (2^2)) If I had three "bits", it would be 3 to the 2nd (3^2) giving us nine possibilities. If I had four "bits" I could raise 4 to the second, and so on.

Now my question is this:

How do I compute a value where certain of the spaces (or "bits) are binary while others are trinary or even higher. For example:

0 0

Where one "bit" or slot can have a value of either 1 or 0
Slot 2 can be either 1 or 0 or 2

00, 01, 02, 10, 11, 12 are all of the possibilities.

In what way would I be able to calculate the number of possibilities beforehand?

share|improve this question
In "I can compute this..." you are backwards. If you have four bits, each of which can be in three states, there are $3^4$, not $4^3$ possibilities. –  Ross Millikan Mar 12 at 1:22

2 Answers 2

up vote 1 down vote accepted

If you have $n$ binary bits and $m$ ternary bits then the number of possibilities to form $n+m$ digit sequences if $2^n3^m$. For example you listed $2\cdot3 = 6$ possibilities when you had $n=1$ binary digit and $m=1$ ternary digit.

share|improve this answer
So say I have four bits, and the first two are binary, the third ternary, the fourth has four possible entries. I would compute this by: (2^2)*(3)*(4) Giving me 48. Is that correct? –  alex0112 Apr 23 '14 at 18:46
@alex0112 Yes that's correct.This is the basic law of multiplicativity for outcomes of joint events in terms of the number of outcomes of the individual events. –  user2566092 Apr 23 '14 at 19:09

There is an error in the original question. If you had 3 bits storing binary data the number of possibilities is $2^3$ or $8$ possibilities, not $3^2$ or $9$.

If B = the number of binary bits you have and T = the number of ternary bit you have then

Number of possibilities $= 2^B 3^T$

Notice that is multiplication of the two exponential calculations, not an addition.

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.