Question

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?

Was it helpful?

Solution

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.

OTHER TIPS

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....

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.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top