Is negating INT_MIN undefined behaviour?
问题 Let's say I have a variable i that comes from external sources: int i = get_i(); Assuming i is INT_MIN and two's complement representation, is -i undefined? 回答1: It depends on the platform. C supports three representations for negative numbers (see section 6.2.6.2 of the C99 standard): Two's complement. One's complement. Sign and magnitude. With one's complement and sign and magnitude, -INT_MIN is defined (and equal to INT_MAX ). With two's complement, it depends on whether the value with