C allows three signed integer encodings:
- two's complement
- one's complement
- sign/magnitude
Though all but the most esoteric or antique architectures use two's complement (related question).
Two's Complement
Take a simplified example of a 2 bit integer range -2 to 1. To change the sign in two'd complement you invert the bits and add one. So:
n invert +1(-n)
00 11 00 --- 0 == -0
01 10 11
10 01 10 --- -2 == -2
11 00 01
One's Complement
For one's complement, the bits are simply inverted and the ranbe is -1 to +1.
n invert(-n)
00 11
01 10
10 01
11 00
Here there there are two encodings for zero (-0 and +0), so there are not values for which n == -n
Sign/magnitude
In sign/magnitude, the sign bit changes:
n !sign(-n)
00 10
01 11
10 00
11 01
And again there are no values for n == -n (and again also two encodings for zero).