# Thread: finding smallest and largest number given n binary bits

1. ## 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 $\displaystyle min=-2^{n-1}, max=2^{n-1}-1$ 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?

2. ## Re: finding smallest and largest number given n binary bits

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 $\displaystyle min=-2^{n-1}, max=2^{n-1}-1$ but is that only for numbers stored using two's compliment?
Yes.

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 $\displaystyle -(2^{n-1}-1)$ to $\displaystyle 2^{n-1}-1$" (Wikipedia). For the sign-and-magnitude method, the interval is the same because n - 1 bits represent the absolute value.

Originally Posted by Jskid
If a number is unsigned then it would be 2^n right?
The largest representable integer is not $\displaystyle 2^n$. Consider the example when n = 3 and the largest integer is $\displaystyle 111_2$.