The inverse of XOR is XOR itself.
The XOR Function[1] was introduced in Excel 2013 and is available under Excel Logical functions. It is a logical “exclusive OR” function. For two given logical statements, the XOR function would return TRUE if one of the statements is true and FALSE if both statements are true.
First lets see the rules for XOR Rule 1 : If both bits are 1 then XOR'ed bit will be 0. Rule 2 : If both bits are 0 then XOR'ed bit will be 0. Rule 3 : If one bit is 0 and one bit is 1 XOR'ed bit will be 1. In the above example we find XOR'ed bit for each corresponding pair of bits.
The inverse is XOR!
If you have:
c = a^b;
You can get a
or b
back if you have the other value available:
a = c^b; // or b^c (order is not important)
b = c^a; // or a^c
For example if a = 5
, b = 3
(and thus c = 6
as you mentioned) you get:
b=0011 (3) a=0101 (5)
c=0110 (6) XOR or c=0110 (6) XOR
---------- ----------
a=0101 (5) b=0011 (3)
The inverse of XOR is XOR itself.
I came across a similar problem on leetcode. Leetcode-1720
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With