Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Just started learning C this semester, but I can't seem to understand what the professor wants from us in this question

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?

like image 822
cinos Avatar asked Jan 26 '23 07:01

cinos


1 Answers

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.

like image 159
phonetagger Avatar answered Jan 29 '23 08:01

phonetagger