No, this is not a mistake. This is the nature of integer arithmetic.
For example, take a signed byte value that is between -128 and 127 .
127(0x7f)+1 = 128(0x80) . However, 0x80 is actually a binary representation of -128 .
So for byte 128(0x80) = -128(0x80)
So -128(0x80) * -1 = 128(0x80) = -128(0x80)
Torlack Sep 01 '10 at 21:45 2010-09-01 21:45
source share