Wikipedia says:
A residue numeral system (RNS) is a numeral system representing integers by their values modulo several pairwise coprime integers called the moduli.
Bit widths of each of those "several integers" will be much smaller than the width of the represented integer, allowing efficient addition/subtraction and multiplication, at the cost of complicated division and value comparison.
Here is a hypothetical example. Suppose that we want to represent 30-bit integers using residues. We pick several co-prime numbers - e.g. 1023, 1024, 1025, and represent value N as a triple [N mod 1023, N mod 1024, N mod 1025]
. Note that the mod
operation always results values of the same sign as the divisor.
In this particular case converting from N to residue triple and back is easy, as N mod 1024
is just 10 lowest bits of N, N mod 1023
is (N[29:20] + N[19:10] + N[9:0]) mod 1023
which is very easy to calculate, and N mod 1025
is, similarly, (N[29:20] - N[19:10] + N[9:0]) mod 1025
, pretty much the same way as we mentally compute mod 9
and mod 11
of numbers expressed in decimal.
Then, adding or multiplying triples is done as adding or multiplying individual unsigned values mod 1023, 1024 or 1025 respectively. For addition, this requires shorter carry chains (10-deep) than would be used for 30-bit integers — or much smaller carry prediction trees, — and, for multiplication, just three 10x10 multipliers, one of them partial: we only need 10 lowest bits of the product to find out its mod 1024
.
Converting a triple back to an integer is akin to solving a simple linear equation, reversing the way the triple was constructed.
Division would be much more complex, and less-than comparisons would be done by converting triples back to integers.
However, it could still be beneficial to use it for specialized computations, and there was a project of a Soviet military computer for the anti-ballistic missile system using a residue number system: 5Э53, apparently unimplemented; a computer with a conventional number representation was used instead.
Were there any computers using a residue number system which made it to production?