For example, i have this binary number : 1011 1101

Now i wish to evaluate the decimal equilant using sign and magnitude, one's complement and two's complement.

Now for sign and magnitude, i know the answer would be like, take the left most bit as sign, in this case it is 1, so negative number. Take the rest of the bits as magnitude, which is 61. So the decimal equilant is -61.

How about the one's and two's complement. Do i need to flip all the bits, or do i need to keep the left most bit as it is, and flip the rest?.

Like for ones complement of the binary number above, would it be 11000010 or 01000010.


There are a plethora of (poorly-tagged) questions on math.SE about twos-complement binary numbers. In summary, the usual definition of twos complement is, to convert a negative number $-N$ to twos complement, you write $N$ (the magnitude of the number) in binary, "flip" (take the complement of) all the bits, then add $1$ (a number with $1$ in the least significant place and $0$ everywhere else).

The conversion in the reverse direction is: "flip" all the bits and add one, treat the result as a positive number, convert it to decimal, and then flip the sign of the number so that you get back the original negative number. So, for example, $1011\,1101$ in eight-bit twos-complement is $-0100\,0010_2 +1 = -0100\,0011_2 = -67_{10}.$

For ones complement you just flip all the bits. So, for example, $1011\,1101$ in eight-bit ones-complement is $-0100\,0010_2 = -66_{10}.$

Personally, I prefer to think of a twos-complement negative number $-N$ in $w$ bits as simply $2^w - N$. The ones-complement representation of $-N$ is then $(2^w - 1) - N$.

  • $\begingroup$ So regarding your explanation, for a binary number 10111101 the one's complement should be : keep the left most bit and swap the rest?. $\endgroup$ Apr 2 '15 at 14:47

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.