How to map a long integer number to a N-dimensional vector of smaller integers (and fast inverse)?

Posted by psihodelia on Stack Overflow See other posts from Stack Overflow or by psihodelia
Published on 2010-05-20T12:06:49Z Indexed on 2010/05/20 12:30 UTC
Read the original article Hit count: 103

Filed under:
|
|

Given a N-dimensional vector of small integers is there any simple way to map it with one-to-one correspondence to a large integer number?

Say, we have N=3 vector space. Can we represent a vector X=[(int32)x1,(int32)x2,(int32)x3] using an integer (int48)y? The obvious answer is "Yes, we can". But the question is: "What is the fastest way to do this and its inverse operation?"

© Stack Overflow or respective owner

Related posts about c

    Related posts about math