I am trying to read a 2's complement 9 bit integer (PS2 mouse). The code below generates an 'arithmetic overflow' warning on "x |= 0xFF00;" What is the correct way to do this, please?
Code:
int16_t x;
bool sign;
x = ReadByte(PS2); // The lower 8 bits
sign = ReadSign(PS2);
if (sign) // if value is negative
{
x |= 0xFF00; // Attempt to set high byte to all 1's
}