For the life of me I cannot figure out how to convert a (maximum) 12-bit number into 2 8-bit bytes (where one of the values will obviously not be able to exceed 4-bits).
For example, I can convert 7
(the 4-bit value) and 60
(8 bit value) integers into 3079
via:
7 + (60 << 8) & 0xfff;
But I cannot reverse this process, extracting 60
and 7
FROM 3079
.
I use the following for 16 bits, but I cannot figure out how to modify it for 12-bit values as they do not result in the original value:
(calcMSB << 8) | (calcLSB & 0xff)