This online calculator calculates radix complement (referred to as r's complement) and diminished radix complement (referred to as (r-1)'s complement) for the given number and the given radix (base).
Complement number is the number which, when added to its counterpart, makes some other number, usually a base (radix) of number system. In such case it is called radix complement. For example, 7 complements 3 to 10.
By definition, the formula of the radix complement of an n digit number y in radix b is
There is also a diminished radix complement, which is
Diminished radix complement is easy to get by simply replacing the digits of a number with digits needed to get radix - 1. For example, for the 2 digit decimal number 56 the diminished radix complement is 43. Then you can get radix complement by simply adding the one to the diminished radix complement: 43+1=44
For the decimal system radix complement is known as ten's complement (10's complement) and diminished radix complement is known as nines' complement (9's complement).
Generally, complements are used to represent a symmetric range of positive and negative integers. In other words, half of the range represents positive numbers, and their complements represent negative numbers. That is, for ten's complement, if we consider only one digit, i.e. range from 0 to 9, 3 represents +3 and 7 represents -3.
This allows technique known as method of complements, where you can calculate subtraction as addition of subtrahend complement, f.e. 622 - 451 is 622 + 549 = 1171 = 171 (the leading 1 is omitted from the result).
For the binary system radix complement is known as two's complement (2's complement) and diminished radix complement as one's complement (1's complement). One's complement can be obtained by simply inverting bits of a number. Two's complement is used in computers to represent negative integers. You can read more here: Binary, inverse and complement codes.