使用 C++,我需要将两个不同的 ID 组合成一个 16 位整数。然后稍后我需要将这个 16 位整数解码为两个原始 ID 值。
例子:
// Store two integers into one
unsigned short Identifier1 = 12793; //(maximum number 30000)
unsigned short Identifier1 = 5450; //(maximum number 30000)
unsigned short CombinedIDs = 34283; // this is example, I don't know the code for that
// Decode one integer into two
// At this point I only have CombinedIDs value, I need to extract it
// into the two original IDs
unsigned short OriginalIdentifier1 = ...CombinedIDs.. code to get 12793
unsigned short OriginalIdentifier2 = ...CombinedIDs.. code to get 5450