문제

I am not sure about signed hex division by decimal.

How can long type fff0bdc0 divided by 1000L turn to be fffffc18?

   long a = 0xfff0bdc0;
   a = a/1000L;
   UARTprintf("a = %x\n", a);

result of print : a = fffffc18

Thanks,

Jin

도움이 되었습니까?

해결책

Assuming that long is a 32-bit integer, and negative numbers are represented using the two's complement:

fff0bdc0 (hex) = -1000000 (decimal)
fffffc18 (hex) =    -1000 (decimal)

So your result looks correct.

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top