When is xor of two numbers be equal to the difference between the numbers
Answers
Answered by
0
No.
If x=2n+1x=2n+1 and y=2ny=2n, then a=b=1a=b=1, but there is no way to determine nn.
It is easy to cook up more examples, if you arrange that you don't need to any "borrowing" (is that the correct English term?) when you do paper and pencil subtraction in base two. When that happens, subtraction gives the same result as XOR, but you cannot recover the positions of the cancelled bits.
If x=2n+1x=2n+1 and y=2ny=2n, then a=b=1a=b=1, but there is no way to determine nn.
It is easy to cook up more examples, if you arrange that you don't need to any "borrowing" (is that the correct English term?) when you do paper and pencil subtraction in base two. When that happens, subtraction gives the same result as XOR, but you cannot recover the positions of the cancelled bits.
Similar questions