Created
May 28, 2020 16:19
-
-
Save RichardB01/02846cd91d72160afef3f65fd6726887 to your computer and use it in GitHub Desktop.
Function to combine two int32 into 1 int64.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
static int64_t Pack(int32_t inX, int32_t inY) | |
{ | |
int64_t x = static_cast<int64_t>(inX) << 32; | |
int64_t y = static_cast<int64_t>(inY); | |
// twos complement, therefore 32 msbs must be cleared. | |
if (inY < 0) | |
{ | |
y = y ^ 0xFFFFFFFF00000000; | |
} | |
return x | y; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment