Mathematics Stack Exchange is a question and answer site for people studying math at any level and professionals in related fields. It's 100% free, no registration required.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

As part of an answer to a Stack Overflow question I made the assumption that if I choose two distinct positive integers $m$ and $n$, them give you $m - n$ and $m$ XOR $n$, then you can uniquely determine what $m$ and $n$ were. For all the examples I've tried this seems to work correctly, though I have no reason to believe that this should work in general. Moreover, I'm not familiar enough with the interactions of differences (or sums, for that matter) and XOR to deivse a proof or counterexample.

Is my claim true? If so, how would you go about proving it? If not, is there a nice counterexample?

Thanks so much!

share|cite|improve this question
up vote 9 down vote accepted

I believe this is false.

Let $2^r \gt m \gt n$.


$2^r + m$ and $2^r +n$ have same difference and XOR as $m,n$.

share|cite|improve this answer

How about (2,3) and (16,17)? plus some characters

share|cite|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.