If I use one's complement to represent number, what result should I get?
For example, number 01110 ( a positive number),its one's complement should be 01110 or 10001?
if the number is 10001 ( a negative number), the one's complement value is 01110?
how to calculate the one's complement for positive and negative number?
53.6k views Asked by Dean Chen At
3
There are 3 answers
0
On
That's completely wrong one's complement, two's complement and signed magnitude are all the same for positive numbers. For negative numbers take the binary for the absolute value (positive number) of the negative number and inverse it to get the one's complement which will be different than two's complement and signed magnitude.
0
On
One's complement, two's complement and signed magnitude are all the same for positive numbers. For negative numbers take the binary for the absolute value (positive number) and reverse it to get the one's complement. Add one to the 1's complement to get 2's complement......And add 1 extra bit to the most left of the original to get Sign magnitude....
In your case, it would be 10001. Ones' complement means reversing all the bits in the number.
This also implies that it turns a positive number to a negative one, and vice versa. Also note that this gives some strange behavior, for example zero's complement isn't zero, but negative zero: 00000 becomes 11111. This makes arithmetic with 1's complement a bit tricky, and it is one of the reasons that computers today use 2's complement for negation.