Question

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

Was it helpful?

Solution

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.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top