Computer Science
Advanced
Two's Complement
Represents negative integers in binary by inverting bits and adding one.
Formula
Variables
NBinary number
Example
In 8-bit two’s complement, −5 is ~00000101 + 1 = 11111011.
Did You Know?
Two's complement lets computers subtract by adding — which is why almost every CPU uses it for signed integers.