Why it matters
Two's complement powers all modern signed arithmetic. Understanding shapes overflow behavior.
Advertisement
The architecture
Encode: invert bits, add 1.
Range: -2^(n-1) to 2^(n-1)-1.
Overflow wraps; UB in C for signed.
Advertisement
How it works end to end
Modern CPUs use 2's complement.
Sign-extension via arithmetic right shift.
Overflow behavior differs C vs HW.