Skip to content

Instantly share code, notes, and snippets.

@shaunsales
Last active January 8, 2019 14:43
Show Gist options
  • Save shaunsales/4fd5bb028c3face1ad6c4f281d3b4f5c to your computer and use it in GitHub Desktop.
Save shaunsales/4fd5bb028c3face1ad6c4f281d3b4f5c to your computer and use it in GitHub Desktop.
Packing two Int32s into an single Int32
// '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