4

Original question:

A positive number has the same representation in one’s complement and in two’s complement. Suppose its representation is interpreted as two’s complement, and its additive inverse is determined. Now this representation is interpreted as one’s complement, and the additive inverse is determined. Whether interpreted as one’s complement or two’s complement, the result will be the same, since it is a positive number. What is the relationship between this result and the original number?

I don't know what he means by "what is the relationship between this result and the original number". I think I understand the process of what he wants us to do:

First take a binary (0101) then take the two's complement (1011) and then the one's complement of the two's complement (0100). What next?

Patrick Roberts
  • 49,224
  • 10
  • 102
  • 153
cinos
  • 117
  • 2
  • 8
  • 1
    Okay, you started with 0101 and got 0100. What happens if you start with 0001, 0010, or 0011, then what do you get for each of those? Do you see a pattern? – Eric Postpischil Feb 17 '20 at 16:26

1 Answers1

8

If I posted more than this, I'd be giving you the answer....

The resulting number will not be the same as the original number, but the difference between them will be consistent regardless of the value chosen as the original number. Work through several examples until you see the relationship. You've shown an example in binary, which may make it more difficult to see the relationship. Work through several examples in decimal format (convert to binary if that helps, but then convert back to decimal). Choose examples that start with even numbers, and other examples that start with odd numbers, so you don't come to the wrong conclusion about the relationship.

Then, as a bonus, see if you can figure out why that relationship exists. It has to do with the fact that the negation of a value in one of the formats is performed differently than the negation of a value in the other format.

phonetagger
  • 7,701
  • 3
  • 31
  • 55
  • 4
    Have an up-vote for not *completely* doing the OP's homework, but providing excellent guidance, instead. – Adrian Mole Feb 17 '20 at 16:27
  • 3
    Just for reference and maybe you want to quote it for future, similarily beatiful, answers: https://meta.stackoverflow.com/questions/334822/how-do-i-ask-and-answer-homework-questions – Yunnosch Feb 17 '20 at 16:29
  • @Yunnosch The Meta post you linked is something I've used for guidance. Maybe adding an answer there, linking this post, would be a nice addition? – Adrian Mole Feb 17 '20 at 16:39
  • Ah, I got it! I was looking specifically at binary only, but once I turned it to decimal and tried both negative and positive, after converting to twos and ones complement, the numbers will continuously descend until it reaches the point of overflow. I'm guessing the reason is because of the order of conversion, if you were to flip and do one's then two's, it would increase. Using one's complement on a integer doesn't exactly mirror the integer to it's other sign, but two's complement does, so it's either going to always increase or decrease when you use both conversions on a integer. – cinos Feb 17 '20 at 17:25