Hi,
I'm receiving two bytes across a serial link (from a PIC ucontroller). They are interpreted as 2s complement and stored in an integer variable. The two bytes are in fact the high and low bytes of a 16bit value, and I want to reconstruct them as such when they arrive.
I assume I need to cast the int to a byte, then use binary shift operators somehow, but am getting a bit stuck - any help would be wonderful.
Cheers,
Ben
I'm receiving two bytes across a serial link (from a PIC ucontroller). They are interpreted as 2s complement and stored in an integer variable. The two bytes are in fact the high and low bytes of a 16bit value, and I want to reconstruct them as such when they arrive.
I assume I need to cast the int to a byte, then use binary shift operators somehow, but am getting a bit stuck - any help would be wonderful.
Cheers,
Ben