I am working with a system whereby I can send 1 32 bit int at a time. However I need to send two numbers at a time. What is the best way to do this in standard C?
I assume I will have to do some conversion to binary/hex and some masking?
Any ideas would be appreciated.
Thanks
You can encode two 16-bit unsigned numbers like this:
and decode them like this:
All this assumes that
intis at least 32 bits, thatin1andin2are in the 0-65535 range, and that anunsigned intcan be sent across correctly (w.r.t. endianness).