Complement operations are run on a single number in any given base, and can simplify succeeding operations in digital circuits.
Given a number $N$ in base $r$ having $n$ digits, the $(r-1)$’s complement of $N$, i.e., its diminished radix complement is defined as $(r^n - 1) - N$
Note: n is the number of digits that we choose for all of our representations (most often the word size in our hardware representation)
The $r$’s complement of an n-digit number $N$ in base $r$ is defined as $r^n - N$ for $N \neq 0$ and as 0 for $N = 0$.
Comparing with the diminished radix complement, we can achieve one from the other by subtracting 1.
If the original number N contains a radix point, the point should be removed temporarily in order to form the r’s or (r - 1)’s complement.
The radix point is then restored to the complemented number in the same relative position.
In other words, we pretend the radix point doesn’t exist while complementing numbers with radix points.
Complementation makes it easier for use to perform subtractions in digital hardware.
Let’s suppose we have to perform $M - N$ in base $r$:
Take the radix complement of N: $r^n - N$
Add this to M: $(r^n - N) + M = r^n + (M - N) = r^n - (N - M)$
If you get a carry in the $(n + 1)$th digit, then the result is positive, discard the carry and you have the result.
Since $r^n$ will be represented as 1, followed by n 0s, so removing the carry is equivalent to ignoring the $r^n$, and we are left with only $(M - N)$
If you do not get a carry in the $(n + 1)$th digit, then the result is negative. Take the radix complement of the number to get the answer, then put a negative sign.
Since $r^n - (N - M)$ is the complement of $(N - M)$, so taking the radix complement of this again, we get $(N - M)$ back. Then putting a negative sign in front of it, we get $(M - N)$, the result we wanted.
Though it may seem a bit convoluted, this method removes the need for borrowing, which requires us to know the value of the next digit in the number.
Similarly for diminished radix complements.
Take the diminished radix complement of N: $r^n - 1 - N$
Add this to M: $r^n - 1 - N + M = r^n + (M + N - 1) = (r^n - 1) - (N - M)$
If you get a carry in the $(n + 1)$th digit, then the result is positive, add the carry to the result and you are done.
If you do not get a carry in the $(n + 1)$th digit, then the result is negative, take the diminished radix complement of the number to get the answer then put a negative sign.
Additional resource: Radix and Reduced Radix subtraction