<p>You could apply sort of compression technique as described <a href="https://github.com/ajauhri/bignum_compression" rel="nofollow noreferrer">here</a>. Start from section 2 of the <a href="https://arxiv.org/pdf/1509.05505.pdf" rel="nofollow noreferrer">paper</a>. </p>

<p>Disclaimer -- I am one of the authors of the paper. Feel free to drop a line here if it seems like a good option for your problem, and you have any queries. </p>
Most efficient encoding of a point with X, Y into one unique number
<p>I am trying to make a function which converts 2D coordinates <strong>(X, Y)</strong> into one single number (Does not matter if integer or float), but what matters is speed because I need to call that function more than 50 times per frame and 60 frames a second. Which is a lot. Additionally the function can not mirror itself. What I mean by that is I need a different answer when using something like (10, 50) or (-10, -50).</p>

<p>Because with something like <code>x * y</code> and numbers <strong>(10, 50)</strong> the output is <code>500</code>, now when we change the numbers into opposite of that <strong>(-10, -50)</strong> the output is still <code>500</code> witch is not wanted.</p>

<p>But at the same time anything with exponencional growth is too slow, something like <code>2 ** x * (2 * y + 1)</code> ,even though it is not mirroring it has the problem of being too slow with large numbers <strong>(100 000 and more)</strong> and I would like to push that lag free zone as far as possible.</p>

<p>I hope I explained it clearly enough.</p>