Signed Hex Division by Decimal

Jin

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

Martin R

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.

Collected from the Internet

Please contact [email protected] to delete if infringement.

edited at
0

Comments

0 comments
Login to comment

Related

TOP Ranking

HotTag

Archive