Skip to content

Instantly share code, notes, and snippets.

@peterhpchen
Created August 22, 2018 06:41
Show Gist options
  • Save peterhpchen/2b067f9c513dfa2ea0974e43c697bf75 to your computer and use it in GitHub Desktop.
Save peterhpchen/2b067f9c513dfa2ea0974e43c697bf75 to your computer and use it in GitHub Desktop.
Use UInt to save two UShort
public static uint saveTwoUShortToSingleUInt(ushort low, ushort high)
{
uint result = low;
result += (uint)high << 16;
return result;
}
public static Tuple<ushort, ushort> convertSingleUIntToTwoUShort(uint integer)
{
ushort low = Convert.ToUInt16(integer & 0xFFFF);
ushort high = Convert.ToUInt16(integer >> 16);
return Tuple.Create(low, high);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment