Last active
January 8, 2019 14:43
-
-
Save shaunsales/4fd5bb028c3face1ad6c4f281d3b4f5c to your computer and use it in GitHub Desktop.
Packing two Int32s into an single Int32
This file contains 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
// 'ABC' as an int | |
var base26 = 731; | |
// '1234' | |
var base10 = 1234; | |
// Bitshift the base-26 int to left half, then OR the base-10 | |
int result = (base26 << 16) | base10 & 0xFFFF; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment