The ones' complement of a fixed-width binary numeral is obtained by interchanging its digits 0 and 1. Equivalently,
if it has bits and unsigned value
, its ones' complement has unsigned value
. In an
-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
is
,
while that of
is
.
The representable integers satisfy . 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,
gives
The apostrophe positions in "ones' complement" and two's complement reflect different definitions. An -bit ones' complement is taken with respect to the string of
ones, whose value is
, whereas the latter is taken with respect to the single
power
.
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.