Math Help - 2's compliment

1. 2's compliment

If a number is negative are all the leading bits 1?
For example I tried converting -26 with 2's compliment and got 11100110 but my calculator converted as 1111100110

2. Re: 2's compliment

not all the leading bits. Only the MSB(most significant bit) has to be 1. you've used 8-bit number system. The calculator must be using 10-bit number systems. so in 8-bit system -26 is represented as 11100110 and in 10-bit system it is shown as 1111100110

3. Re: 2's compliment

So to convert from a lower bit to a higher bit, the leading bits of the higher bit are the same as the leading bit from the lower bit?
In the example to convert to 10 bit we added two 1 to the beginning because it was negative? if it had been positive we would have added two 0s to the beginning?

4. Re: 2's compliment

Originally Posted by Jskid
So to convert from a lower bit to a higher bit, the leading bits of the higher bit are the same as the leading bit from the lower bit?
In the example to convert to 10 bit we added two 1 to the beginning because it was negative? if it had been positive we would have added two 0s to the beginning?
Yes. If the number is positive, then it is clear it should be padded with zeros on the left.

Suppose that we have an n-bit negative number, i.e.,

$-2^{n-1}+a$

for some $0\le a<2^{n-1}$, and suppose we add k bits. Then if we pad them with ones, the resulting number is

$-2^{n+k-1}+(2^{n+k-2}+\dots+2^{n-1})+a$.

Now,

$2^{n+k-2}+\dots+2^{n-1} = 2^{n-1}(2^{k-1}+\dots+1)=2^{n-1}(2^k-1)=2^{n+k-1}-2^{n-1}$,

so the numbers are the same.