Doubt in two compiment

Discussion in 'Homework Help' started by bhuvanesh, Jul 19, 2014.

  1. bhuvanesh

    Thread Starter Member

    Aug 10, 2013
    268
    2
    i am thinking that 2'complient of '000'is 000.But everyone saying it is '1000'.HOW?
     
  2. MrChips

    Moderator

    Oct 2, 2009
    12,442
    3,361
    To form 1's complement, invert every bit.

    To form 2's complement, take the 1's complement and add 1.

    Hence the 2's complement of 000 is 000 with a carry. Hence 1000 is also correct if the register is only three bits.

    You have to define the size of the register.
     
  3. bhuvanesh

    Thread Starter Member

    Aug 10, 2013
    268
    2
    What do you say for this?
     
  4. MrChips

    Moderator

    Oct 2, 2009
    12,442
    3,361
    Why don't you try it and see if that works?
     
  5. bhuvanesh

    Thread Starter Member

    Aug 10, 2013
    268
    2
    It does not works.Then why the statement raised and widely being used in many books
     
  6. MrCarlos

    Active Member

    Jan 2, 2010
    400
    134
    Hello bhuvanesh

    Give a studied the content of the attached image.
     
  7. MrAl

    Well-Known Member

    Jun 17, 2014
    2,433
    490

    Hi,

    I think it does work, but the question comes up about why you would want to use it. To do it the other way, we would have to complement all the bits and then add 1, but adding 1 means we might generate a ripple carry that involves all the bits which means we might have to work on the bits twice and also the second time in sequence. Using the more abstract way, we would only have to look at the bits once and make a decision for each bit only once, so there may be an advantage with some types of processors. With modern processors however i dont think there is an advantage because they probably have a built in function already (which may actually already do it that shorter way) or even just one complement and one addition means just two quick integer instructions and it's done. This can be done on at least 64 bits at a time, possibly more.
     
Loading...