Reputation: 590
So this was one of the questions in my textbooks, we haven't got there yet but i'm interested in how this all works,
For the first bit here, my understanding of one's complement is you flip so where there are 1's you put 0's and 0's you put ones. This has to be 8 bit so i added a zero to the binary at the start Therefre 01001001 Write down the following binary representations of +73:
8-bit unsigned: 01001001
8-bit signed-magnitude: 01001001
8-bit one's complement: 10110110
8-bit two's complement: 10110111
8-bit excess-128: 10110111
These are the answers I came up with, but i'm fairly certain i did them wrongly. Any clarification on this?
Secondly, how the heck to I do it with a negative so -73, the binary is just -01001001 so I assume that is the signed, do you do the same technique as above( assuming i have got them correct)
8-bit signed-magnitude: -01001001
8-bit one's complement:
8-bit two's complement:
8-bit excess-128:
Thanks in advance for any help
Upvotes: 0
Views: 7839
Reputation: 126120
+73 is 01001001 in all the representations you named except excess-128. In excess-128 its 11001001 (add 128 to it). Sign magnitude, one's complement, and two's complement are all the same for positive numbers and only differ for negative numbers. The value of -73 in those representations is:
8-bit sign magnitude 11001001
8-bit one's complement 10110110
8-bit two's complement 10110111
8-bit excess-128 00110111
the one's complement 'flip all bits' is how you negate a number in one's complement notation. So if you have n, to get -n you flip all the bits.
'flip all bits and add 1' is how you negate a number in two's complement.
Both one's complement and two's complement have one odd value. For one's complement that's -0 (all bits set), which is really the same as 0 -- or you can treat it as invalid and special case negating 0. For two's complement, that's -2^(n-1) -- -128 for 8-bit -- which is a number that negates to itself due to overflow.
Upvotes: 1