10

Operator - Generalized Symmetric Difference

If you take binary xor and generalize it to other radices you can do so by the absolute value of the difference of each element in a radix vector. However this doesn't have the same properties as the binary symmetric differene. The reason is that in throwing away the "sign" of the difference we are unable to reconstruct an operaand given the result and the other as we can in binary xor. So we lose the nice property

ABA = B

However we keep other nice properties like

A0 = A

AA = 0

There is a way to maintain this property. However, as far as I can tell it involves emitting 3 vectors for any result. The first vector is the usual symmetric difference, the other two vectors are binary vectors of equal length to the first that record the sign of the result, one such vector for each order of the operands, on being the binary complement of the other. In this way, an original operand can be recovered, given the result and the other opernad, AND that other operands "sign" vector.

For example :

Say we have 2 base 10 vectors corresponding to the numbers 1137 and 9284, what i s the xor of these two numbers in base 10?

        7  3  1  1              4  8  2  9


        4  8  2  9              7  3  1  1

Signed
Result  3 -5 -1 -8             -3  5  1  8

Sign
Vector  0  1  1  1              1  0  0  0

Symmetric
Difference              3 5 1 8

Recover 1137 given 8153 and 9284

3  5  1  8
+  -  -  -
4  8  2  9

7  3  1  1

My question is : is there a better construction of generalized symmetric difference in any radix > 2 such that we don't need to 'remember the sign' ?

1 Answers1

6

The most common definition of xor is $a\oplus b=(a+b)\bmod 2$, on vertices applied to every coordinate seperately of course. In base-10 case, you have to introduce two operations: $a\oplus b=(a+b)\bmod 10$ and $a\ominus b=(a-b)\bmod 10$. (Notice that in base-2 case they coincide). Now you have

$$c=a\ominus b \quad\text{for coding}\quad\text{and}\quad a=c\oplus b \quad\text{for decoding.}$$


Actually, you can use $\ominus$ for both operations, just a bit cleverer:

$$c=b\ominus a \quad\text{for coding}\quad\text{and}\quad a=b\ominus c \quad\text{for decoding.}$$

This works because $a=b\ominus c=(b-c)\bmod 10=(b-(b\ominus a))\bmod 10 $ $= (b-(b-a)\bmod 10)\bmod 10=a\bmod 10=a$.

yo'
  • 311
  • 1
  • 10