structs and data types

I am trying to control a quadrotor device, and to do so I need my program to send command inputs via a struct. In the owner's manual, it oultines how to do this:

struct CTRL_INPUT {
short pitch;
short roll;
short yaw;
short thrust;
short ctrl;
short chksum;
};
struct CTRL_INPUT CTRL_Input;

CTRL_Input.chksum = CTRL_Input.pitch+ CTRL_Input.roll + CTRL_Input.yaw + CTRL_Input.thrust + CTRL_Input.ctrl + 0xAAAA;

My problem is, chksum is declared as a short but then gets 0xAAAA added to it, which corresponds to a value of 43690, much larger than a short can be. I'm pretty sure its meant to be a signed short, as it being 'unsigned' was not specified in the code. Further, the values for pitch, roll, and yaw can be negative, so they are most definitely signed. Is 0xAAAA not what I think it is? Is it not meant to be there in implementation? I'm a newb when it comes to structs (most of C++ actually), so any help is much appreciated.
0xAAAA can be a short, it would just be interpretted as signed. On 2's complement systems (probably what you're on), it would be the same as -21846.
Ah, that makes sense. Thanks for the tip. Follow up question: would it be okay if I just -21846 into the equation instead of writing out 0xAAAA?
As long as chksum is 16-bits wide, then yeah, there won't be any difference.

Though 0xAAAA is more clear IMO.
Topic archived. No new replies allowed.