finding smallest and largest number given n binary bits

Given n bits that can hold 0s or 1s what is the largest and smallest integer they can hold? I know the formula but is that only for numbers stored using two's compliment? Is there a formula for one's compliment and signed magnitude? If a number is unsigned then it would be 2^n right?

Re: finding smallest and largest number given n binary bits

Quote:

Originally Posted by

**Jskid** Given n bits that can hold 0s or 1s what is the largest and smallest integer they can hold? I know the formula

but is that only for numbers stored using two's compliment?

Yes.

Quote:

Originally Posted by

**Jskid** Is there a formula for one's compliment and signed magnitude?

"An n-bit ones' complement numeral system can represent integers in the range to " (Wikipedia). For the sign-and-magnitude method, the interval is the same because n - 1 bits represent the absolute value.

Quote:

Originally Posted by

**Jskid** If a number is unsigned then it would be 2^n right?

The largest representable integer is not . Consider the example when n = 3 and the largest integer is .