what's the reason for adding "1"?

Discussion in 'Math' started by PG1995, Oct 10, 2011.

  1. PG1995

    Thread Starter Active Member

    Apr 15, 2011
    753
    5
    Hi

    Please check the attachment. You can find my question there. I understand that "1" should be added to get "-23" but what's the reason for this? Why did we end up "-24" in the first place rather than "-23"?

    Thank you for your help.

    Regards
    PG
     
  2. steveb

    Senior Member

    Jul 3, 2008
    2,433
    469
    That's just the nature of 1's complement numbers, the negative numbers are shifted by one if you determine the binary value by that method.

    Take the example of zero. Positive zero is 0000 in 4 bit representation. Now take the 1's complement to get negative zero, and it is 1111. Now use the rule

    The value is -2^3+2^2+2^1+2^0 = -8+4+2+1 =-1

    Clearly the value is shifted down by one and you need to add one to get negative zero.

    The shift by one shows up because the number zero is represented twice in this encoding method. 0000 and 1111 both represent zero because positive zero and negative zero are equal to each other.

    As you know, 2's complement representation gets rid of the redundancy.
     
    PG1995 likes this.
  3. Papabravo

    Expert

    Feb 24, 2006
    10,137
    1,786
    It is precisely the end-around-carry that I mentioned in my previous post. A carry out of the MSD (Most Significant Digit) gets added back into the result.
     
    PG1995 likes this.
  4. PG1995

    Thread Starter Active Member

    Apr 15, 2011
    753
    5
    Thank you, Steve, Papabravo.

    Hi

    Perhaps I might sound dumb but that's what I sound like in many of the threads! :)

    Okay. Positive zero is 0000 and negative zero is 1111 in 4 bit number size. It might help you to understand my confusion if you have a look on this thread here. Referring again to the attachment in my first post above. "1" wasn't added to the result when the final answer was a positive number. But it was when answer was negative. Could you please elaborate a little on this? Thanks.

    Best wishes
    PG
     
Loading...