Results 1 to 4 of 4

Math Help - 2's compliment

  1. #1
    Member Jskid's Avatar
    Joined
    Jul 2010
    Posts
    160

    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
    Follow Math Help Forum on Facebook and Google+

  2. #2
    Senior Member BAdhi's Avatar
    Joined
    Oct 2010
    From
    Gampaha, Sri Lanka
    Posts
    252
    Thanks
    6

    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
    Follow Math Help Forum on Facebook and Google+

  3. #3
    Member Jskid's Avatar
    Joined
    Jul 2010
    Posts
    160

    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?
    Follow Math Help Forum on Facebook and Google+

  4. #4
    MHF Contributor
    Joined
    Oct 2009
    Posts
    5,417
    Thanks
    718

    Re: 2's compliment

    Quote Originally Posted by Jskid View Post
    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.
    Follow Math Help Forum on Facebook and Google+

Similar Math Help Forum Discussions

  1. why can't arithmatic be done in one's compliment
    Posted in the Discrete Math Forum
    Replies: 0
    Last Post: January 9th 2012, 04:53 PM
  2. Replies: 0
    Last Post: December 11th 2011, 03:24 PM
  3. [SOLVED] Finite Compliment Topology
    Posted in the Differential Geometry Forum
    Replies: 2
    Last Post: March 9th 2011, 11:46 AM
  4. Representing two's compliment
    Posted in the Number Theory Forum
    Replies: 1
    Last Post: November 14th 2010, 08:41 AM
  5. Intersection, Union, and Compliment of sets
    Posted in the Discrete Math Forum
    Replies: 4
    Last Post: October 7th 2008, 09:34 AM

Search Tags


/mathhelpforum @mathhelpforum