Computers represent integers in binary with a finite width of
However, with signed integers, we need some way to indicate if the value is negative. Twoโs complement is a trick that makes certain arithmetic operations valid for both unsigned and signed binary: all bits are
Intuitively, this representation comes from the insight that due to the finite width
To negate a number, we have a simple rule:
where
and we notice that