Created
August 22, 2018 06:41
-
-
Save peterhpchen/2b067f9c513dfa2ea0974e43c697bf75 to your computer and use it in GitHub Desktop.
Use UInt to save two UShort
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
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