TOPICS
Search

Ones' Complement


The ones' complement of a fixed-width binary numeral is obtained by interchanging its digits 0 and 1. Equivalently, if it has n bits and unsigned value a, its ones' complement has unsigned value 2^n-1-a. In an n-bit ones'-complement representation, a positive integer has leading digit 0, and the representation of the corresponding negative integer is the ones' complement of its string. Thus the 8-bit representation of 11 is (00001011)_2, while that of -11 is (11110100)_2.

The representable integers satisfy -(2^(n-1)-1)<=x<=2^(n-1)-1. Both the all-zero and all-one bit strings represent zero, so this value has two representations. addition uses an end-around carry. If an addition overflows beyond the leading digit, the overflow is returned to the least significant digit. For example, 17-11 gives

 (00010001)_2+(11110100)_2=(100000101)_2->(00000110)_2=6.

The apostrophe positions in "ones' complement" and two's complement reflect different definitions. An n-bit ones' complement is taken with respect to the string of n ones, whose value is 2^n-1, whereas the latter is taken with respect to the single power 2^n. The variant spelling "one's complement" treats one as a numeral by analogy with the latter term. The numeral spelling "1's complement" is common in engineering, while the unpunctuated form "ones complement" occurs when typography omits apostrophes. All these forms for the ones' complement denote the same operation or representation.


See also

Binary, Binary Expansion, Bit, Carry, Encoding, Negabinary, Sign-and-Magnitude Representation, Two's Complement, Zero

Explore with Wolfram|Alpha

WolframAlpha

More things to try:

References

Knuth, D. E. "Positional Number Systems." §4.1 in The Art of Computer Programming, Vol. 2: Seminumerical Algorithms, 3rd ed. Reading, MA: Addison-Wesley, p. 203, 1998.

Cite this as:

Weisstein, Eric W. "Ones' Complement." From MathWorld--A Wolfram Resource. https://mathworld.wolfram.com/OnesComplement.html

Subject classifications