leading fffff's locking controller

Hello,

I have a temperature controller that takes high and low bytes.

My code looks like this:

int myTemp

lowByte = myTemp & 0xFF;
highByte = ( myTemp >> 8 ) & 0xFF;


cout << hex << (int)lowByte << endl;
cout << hex << (int)highByte << endl;


Problem:

myTemp = 128

outputs:

ffffff80
0

the leading f's cause my controller to lockup.

For example:

myTemp = 127

outputs:

7f
0

Which does not have leading f's and everything works fine?

My question is how to I get rid of these leading f's?

Use unsigned types.
Topic archived. No new replies allowed.