0
$\begingroup$

How many combination of "n" bits are there in terms of n? And if this is derived, Given 4 bits for representing negative and positive numbers, what is the largest positive number that can be represented?

$\endgroup$
1

2 Answers 2

3
$\begingroup$

Each bit can be either 0 or 1, so you have two choices per bit. That gives you 2^n combinations. E.g. n=1 implies 2^1=2 states, n=2 implies 2^2=4 states. You could arrive at this by 1) making a lexicographic list of all the combinations or 2) using a formula from combinatorics.

Your second question seems to address representing integers with binary numbers. You must first settle on an encoding scheme before that question can be answered. A popular encoding scheme is two's complement. The maximum positive integer represented in 4-bit two's complement is 0111, which is 7.

$\endgroup$
2
$\begingroup$

These are two separate questions.

  1. How many possible combinations of "n" bits are there? Well, bit 1 can take any of the two values (so there's 2 possibilities for bit 1); for any of them, bit 2 can take any of the two values (so there's 2*2 possibilities for bits 1,2); for any of the combinations of bits 1 and 2, bit 3 can take any of the two values, etc.

  2. That depends on the particular way you choose to represent numbers as bits. A popular way is, as pointed out by @didierc, https://en.wikipedia.org/wiki/Two%27s_complement .

$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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