2

Is there a mathematical function that converts two numbers into one so that the two numbers can always be extracted again?

Pratik Singhal
  • 211
  • 2
  • 7
  • 3
    For two real numbers, consider the function $f(x,y) = x+yi$. – peterwhy Jan 18 '14 at 10:17
  • Check out the Di Pasquale pairing function. It works for all positive integers as arguments, and argument order doesn't matter. It's about 60% as fast as the Cantor pairing function, but it's twice as efficient in terms of space. <x, y> = x * y + (|x - y| - 1)^2 / 4 = <y, x> – ma11hew28 Mar 10 '14 at 06:57