The ten's complement of a positive integer , at a fixed width of
decimal digits, is
, where
is a positive integer.
More generally, the radix complement of a positive
integer
in base
is
, where
is an integer. Complement
arithmetic permits subtraction to be performed by
addition followed by discarding a final carry.
At the same width, the ten's complement is one more than the nines' complement. Thus it can be computed by replacing each decimal
digit
by
and adding 1 to the result (Knuth 1998).