Can we solve for a and b, from

$a-b = x$

$a \oplus b = y$

Even when x and y can be negative?

I tried substituting the value of a in xor equation from the difference,

$\Rightarrow (b+x)\oplus b = y$

Since $b \oplus b$ is 0

$\Rightarrow x \oplus b = y$

But, then how to solve for b?

  • 1
    $\begingroup$ Unfortunately your method does not work, because you are assuming that $\oplus$ distributes across addition in $(b + x) \oplus b = x \oplus b$, which it certainly does not. $\endgroup$ – Jeremy Dover Feb 14 at 4:57
  • $\begingroup$ okay, Jeremy, That's helpful. But then how to proceed this? $\endgroup$ – Aniket Bhushan Feb 14 at 6:07
  • $\begingroup$ By solving for $b$ in the second equation and substituting into the first, you can see $a-x = a \oplus y$. This shows that the equations do not have a solution if $x$ and $y$ have opposite parity. Another easy case is if $y=1$, then all even $a$ are a solution if $x=-1$, and all odd $a$ are a solution if $x=1$. No other values of $x$ yield solutions when $y=1$. Because $\oplus$ and $+$ are both nonlinear over the additive group generated by the other, there is no general way to solve these equations. $\endgroup$ – Jeremy Dover Feb 14 at 13:10

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.