TITLE: How to represent XOR of two decimal Numbers with Arithmetic Operators
QUESTION [11 upvotes]: Is there any way to represent XOR of two decimal Numbers using Arithmetic Operators (+,-,*,/,%).

REPLY [4 votes]: This is a summary of a similar longer answer I gave on StackOverflow...

Basic Logical Operators
NOT = (1-x)
AND = x*y
From those operators we can get...
OR = (1-(1-a)(1-b)) = a + b - ab
OR = a + b, if we know that a*b = 0 for all values of a & b

2-Factor XOR
Deriving from set of all truth conditions...
XOR = 1 - (1 - a(1-b))(1 - b(1-a)) = a + b - ab(3 - a - b + ab)
Deriving from compliment of truth conditions...
XOR = (1 - abc)(1 - (1-a)(1-b)(1-c)) = a + b - ab(1 + a + b - ab)

Because we can write (a & !b) || (!a & b) with mutually exclusive terms we can simplify the OR translation as simply + and get...
XOR = a + b - 2ab
For binary values we can condense this expression to
XOR = (a-b)²

Multi-Factor XOR
XOR = (1 - A*B*C...)(1 - (1-A)(1-B)(1-C)...)
Excel VBA example...
Function ArithmeticXOR(R As Range, Optional EvaluateEquation = True)

Dim AndOfNots As String
Dim AndGate As String
For Each c In R
    AndOfNots = AndOfNots & "*(1-" & c.Address & ")"
    AndGate = AndGate & "*" & c.Address
Next
AndOfNots = Mid(AndOfNots, 2)
AndGate = Mid(AndGate, 2)

'Now all we want is (Not(AndGate) AND Not(AndOfNots))
ArithmeticXOR = "(1 - " & AndOfNots & ")*(1 - " & AndGate & ")"
If EvaluateEquation Then
    ArithmeticXOR = Application.Evaluate(xor2)
End If

End Function


Any n of k
These same methods can be extended to allow for any n number out of k conditions to qualify as true.
For instance, out of three variables a, b, and c, if you're willing to accept any two conditions, then you want a&b or a&c or b&c. This can be arithmetically modeled from the composite logic...
(a && b) || (a && c) || (b && c) ...
and applying our translations...
1 - (1-ab)(1-ac)(1-bc)...
This can be extended to any n number out of k conditions. There is a pattern of variable and exponent combinations, but this gets very long; however, you can simplify by ignoring powers for a binary context. The exact pattern is dependent on how n relates to k. For n = k-1, where k is the total number of conditions being tested, the result is as follows:
c1 + c2 + c3 ... ck - n*∏
Where c1 through ck are all n-variable combinations.
For instance, true if 3 of 4 conditions met would be
abc + abe + ace + bce - 3abce
This makes perfect logical sense since what we have is the additive OR of AND conditions minus the overlapping AND condition. 
If you begin looking at n = k-2, k-3, etc. The pattern becomes more complicated because we have more overlaps to subtract out. If this is fully extended to the smallest value of n = 1, then we arrive at nothing more than a regular OR condition.