Two's complement
From Rice Wiki
Two's complement is a way to represent signed integers in binary. It is more widely used than its counterpart signed magnitude due to advantages like ease of operations.
Operation
In this system, think of the first bit in the bit pattern as negative. For example, 101 would be 4 + 1 = 5 as an unsigned number, but -4 + 1 = -3 as a signed number represented by 2's complement.
To negate signed numbers, flip all bits and add 1. This comes from math:
Advantages
The advantage of using 2's complement over signed magnitude is twofold:
- Normal binary arithmetic can be applied.
- There is no negative zero