T
TC
Here is a puzzle. I need a function Z = F(X,Y) where X and Y are
signed 32-bit integers and Z is a 64-bit integer (either signed or
unsigned -- I don't care). The function has to meet only one
requirement: Z must be unique for each unique combination of X and Y.
I thought this would be easy, but it is harder than I expected. So
far, the best I can do is this:
Z = 2147483648 + 4294967296 * X + Y
However, that seems inelegant. I think there may be a better solution
which uses bitwise operators, but I can't find it. Any suggestions?
-TC
signed 32-bit integers and Z is a 64-bit integer (either signed or
unsigned -- I don't care). The function has to meet only one
requirement: Z must be unique for each unique combination of X and Y.
I thought this would be easy, but it is harder than I expected. So
far, the best I can do is this:
Z = 2147483648 + 4294967296 * X + Y
However, that seems inelegant. I think there may be a better solution
which uses bitwise operators, but I can't find it. Any suggestions?
-TC