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?
2 Answers
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.
These are two separate questions.
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.
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 .