I have following structs:
struct ID
{
UINT id; // range from 0 to 10 000 000
UINT residentNb; // range same as for id (above).
};
struct FullID
{
ID myID;
ID systemID;
};
Now, UINT id
in above struct ID
have specified range in my system. This range is always from min 0 to max 10 000 000. I would like to transform struct FullID
to one number, UINT64
for example, and be able to encode/decode data from it - myID
and systemID
(like in above struct). Is it possible, and what is the best way to do it? Of course 10 000 000 limit can be rounded to some higher value if this is necessary for proper conversions.
Example
UINT64 encodedID;
(...)
FullID fullID = Decode(encodedID);
(...)
encodedID = Encode(fullID);