The arithmetic used in lesson6 exercise1 puzzled me.

In exercise1 lesson6,the step 10 add a picture to show what the number in two registers mean.

And in step 11, the temp is calculate by the way as follow:

int temp = ((int)temp_reading[1] * 256 + ((int)temp_reading[0] & 0xF0)) / 16;
if(temp > 2047)
{
	temp -= 4096;
}

But,ad the follow picture,When the temperature is -1℃,the high byte is 0x81 and the low byte is 0x00.So that the final temp should equal to -2032.

However,in order to get -1℃,the temp should equal to 16.It puzzled me.

Parents Reply Children
Related