Sign-magnitude is conceptually simple, but messy to implement in hardware. For this reason, other possibilities were explored, including one's complement.

Positive values in one's complement are the same as unsigned binary or sign-magnitude.

To negate a one's complement value, we invert
*all* bits. Like sign-magnitude, one's
complement has two representations for zero, e.g.
+0 = 00000000 and -0 = 11111111.

The term "one's complement" can refer to the binary format (representation) or the negative of a one's complement binary value (the one's complement of 1011 is 0101, and negating is sometimes called "taking the one's complement"). Watch out for this and use the context of the sentence to understand which one we're talking about.

I've often wondered if people who create this kind of confusion are just evil, and intent on making students suffer. However, we should never ascribe to malice what can be explained by incompetence.

In this text, if we want you to negate a value, we will say negate the value. The term "one's complement" refers to the binary number system.

A more universal term for a value with all bits inverted
is simply the *complement*.
The complement of a binary value N is sometimes called
"N prime" and is written as N'. For example,
00110101' = 11001010 and 11001010' = 00110101.

What are the decimal values of the following 8-bit one's complement numbers? If the number is positive, which is indicated by a 0 in the leftmost bit, we just treat it like an unsigned integer. If the leftmost bit is 1, indicating a negative value, we invert it, convert the positive (unsigned) value, and add a '-' sign.

- 00001010 = +(8 + 2) = +10
- 10001010 = -(01110101) = -(1+4+16+32+64) = -117

Addition and subtraction work like unsigned for positive numbers. If negative numbers are involved, arithmetic is slightly complicated. One's complement is not generally used in hardware implementations for this reason.

Comparison works like unsigned if both values have the same sign. If the signs differ, the positive number is greater.

Perform the following conversions.

11111111 8-bit one's comp to decimal

01111111 8-bit one's comp to decimal

-7 decimal to 8-bit one's comp