For an algorithm i am developing, i need to use a pairing function $ f: \mathbb{N}\times\mathbb{N} \rightarrow \mathbb{N}$ to deterministically map two values to one. Inputs to $ f$ , call them $ n, m$ are 32-bit unsigned integers. What the function computes at the moment is a simple concatenation $ n|m$ , thus the output is a 64-bit unsigned integer. Example:

$ f(1, 2) = f(0…01, 0…10) = 0…010…10$

I was wondering if it is possible to do better than 64-bits output.

Given that the number of unique pairs $ f$ will be used on, is ** guaranteed** to be in $ [0, 2^{31}-1]$ (by the algorithm), i.e there are maximum $ 2^{32}-1$ possible outcomes, is it possible to construct a pairing function with 32-bit inputs and 32-bit output? Or perhaps some postprocessing of the 64-bit result to bring it in 32-bit range?