Cover

Proof of max integer encoded by two's complement

17 May 2015

Two’s-complement is the most common binary way of encoding positive and negative integers in computers. In this post I will prove that the maximum integer encoded by $n$ bits using two’s complement encoding is:

The two’s complement encoding ($TC$), implements the normal binary system except the most significant bit has a negative weight. Here are some examples with 4 bits:

Therefore the maximum integer encodable with 4 bits is 7:

two's complement

Therefore for $n$ bits, the largest number encodable $MaxInt(n)$ is the sum of the base 2 bits excluding the left most bit:

For brevity, let us refer to the $MaxInt(n)$ sum as $S(n)$ for now:

Applying the proof of the geometric series to this particular case, lets double the geometric series and add up each term in the series for $2S(n)$:

Simplifying:

Notice what is in red is actually $S(n)$ except it is missing the first term ($2^0$), lets call this part in red $y$:

Substituting in:

comments powered byDisqus
Click me!