I have to solve few simple equation like this: $$ 117 = 86 \oplus x $$ I don't know how to move x to one side and calculate its value. How to do it?
-
2Xor both members with 86. – Aug 06 '14 at 08:47
-
Hint: Write $117$ and $86$ as binary numbers and determine which bit in $x$ has to interact with the bit of $86$ to get the bit of $117$. A zero bit in $x$ leaves the respective bit in $86$ unchanged. A one bit inverts it. – Axel Kemper Aug 06 '14 at 09:04
3 Answers
$$ 117 = 86 \oplus x $$
$$ 86 \oplus 117 = 86 \oplus (86 \oplus x) $$
because $\oplus$ operator is associative , we can write that
$$ 86 \oplus 117 = (86 \oplus 86) \oplus x $$
We know that $a \oplus a=0$ Thus
$$ 86 \oplus 117 = 0 \oplus x $$
We know that $a \oplus 0=0 \oplus a=a$ Thus
$$ 86 \oplus 117 = x $$
As bit process, xor defined as $$ 0 \oplus 0=0 $$
$$ 0 \oplus 1=1 $$
$$ 1 \oplus 0=1 $$
$$ 1 \oplus 1=0 $$
Thus
Now you need to write all numbers in binary expression to do xor logic operation . $$ x= 86 \oplus 117 = (1010110)_2 \oplus (1110101)_2 = (0100011)_2=35 $$ Note that this binary process is equivalent to addition without carry in binary.
Your question remind me the application of XOR operator to recover the data if a hard-disk failure in Raid system.
Please check the example: reference link is here If a drive in the array fails, remaining data on the other drives can be combined with the parity data (using the Boolean XOR function) to reconstruct the missing data. For example, suppose two drives in a three-drive RAID 5 array contained the following data:
Drive 1: 01101101 Drive 2: 11010100 To calculate parity data for the two drives, an XOR is performed on their data:
01101101 XOR 11010100
10111001
The resulting parity data, 10111001, is then stored on Drive 3. Should any of the three drives fail, the contents of the failed drive can be reconstructed on a replacement drive by subjecting the data from the remaining drives to the same XOR operation. If Drive 2 were to fail, its data could be rebuilt using the XOR results of the contents of the two remaining drives, Drive 1 and Drive 3: Drive 1: 01101101 Drive 3: 10111001 as follows: 10111001 XOR 01101101
11010100
The result of that XOR calculation yields Drive 2's contents. 11010100 is then stored on Drive 2, fully repairing the array. This same XOR concept applies similarly to larger arrays, using any number of disks. In the case of a RAID 3 array of 12 drives, 11 drives participate in the XOR calculation shown above and yield a value that is then stored on the dedicated parity drive.
- 10,058
-
Many thanks for your answer, you deserve an upvote! However, how would you do it if it were and AND (
^in programming) operator ? – Revolucion for Monica May 03 '21 at 10:10 -
@RevolucionforMonica Hello, We cannot do such solution if we use OR or AND operator because ($x$ OR $1=1$) and ($x$ AND $0=0$ ) equations do not have one solution. x can be $0$ or $1$ in those equations if you check. It means solutions will be more than one for some cases. However, XOR binary operator has only one x solution for any combination of {0,1} bits for such equations as shown in the question. – Mathlover May 03 '21 at 13:54
You need to look up the algebraic properties of $\oplus$ and solve this like you would any equation. Note that:
- $\oplus$ is associative.
- $a \oplus 0=a$
- 27,819
- 7
- 63
- 129
xor with a number is its own inverse:
$$ (x \oplus y) \oplus y =x \oplus (y \oplus y) = x \oplus 0 = x $$
So you can simply undo the operation on the right.
- 15,781