A topic in the Open Knowledge Graph — a free, open map of 15,290 topics and the order to learn them in.

Two's Complement Representation

College Depth 81 in the knowledge graph ☐ I know this ☆ Set as goal
231topics build on this
336prerequisites beneath it
See this on the map →
Binary ArithmeticAdding Integers+4 more→→Arithmetic Logic Unit (ALU)Floating-Point Representation (IEEE 754)+2 more
signed-integers twos-complement representation negative-numbers

Core Idea

Two's complement is the standard way to represent signed integers in binary. In an n-bit two's complement number, the most significant bit has a place value of −2n-1 rather than +2n-1, so the range is −2n-1 to 2n-1−1. To negate a number, flip all bits and add 1. The key advantage is that addition and subtraction hardware works identically for signed and unsigned numbers, eliminating the need for separate circuits.

How It's Best Learned

Convert small positive integers to their two's complement negatives by hand. Verify that adding a number and its negative produces zero with carry discarded. Check boundary values like the minimum negative number, which has no positive counterpart.

Common Misconceptions

Explainer

You already know how to represent positive integers in binary using place values: in an 8-bit number, the bits represent 128, 64, 32, 16, 8, 4, 2, 1 from left to right. Two's complement extends this system to handle negative numbers by making one simple change: the most significant bit (MSB) gets a *negative* place value. In an 8-bit two's complement number, the leftmost bit represents −128 instead of +128. So the bit pattern 10000000 equals −128 + 0 = −128, and 11111111 equals −128 + 64 + 32 + 16 + 8 + 4 + 2 + 1 = −1. If the MSB is 0, the number is non-negative and reads exactly like unsigned binary. If the MSB is 1, the number is negative.

The brilliant property of two's complement is that addition works identically for signed and unsigned numbers. Consider adding +3 (00000011) and −1 (11111111) in 8 bits: the binary sum is 100000010, but the leading 1 overflows beyond 8 bits and is discarded, leaving 00000010 = +2. The correct answer, with no special hardware needed. This is not a coincidence — it is the reason two's complement was chosen over alternatives like sign-magnitude (where a dedicated sign bit flags negative numbers) or ones' complement (where negation means flipping all bits without adding 1). Those systems require the ALU to check signs and handle special cases; two's complement lets a single adder circuit handle all signed and unsigned arithmetic.

To negate a two's complement number, you flip every bit and add 1. Why does this work? Consider the number +5 = 00000101. Flipping all bits gives 11111010. Notice that a number plus its bitwise complement always equals 11111111 (all ones), which in two's complement is −1. So if N + flip(N) = −1, then flip(N) = −N − 1, and flip(N) + 1 = −N. For +5: flip gives 11111010 (which is −6), and adding 1 gives 11111011 (which is −5). You can verify: −128 + 64 + 32 + 16 + 8 + 0 + 2 + 1 = −5. This trick works for every value except the most negative number: −128 (10000000) flipped is 01111111 (+127), and adding 1 gives 10000000 (−128 again). This asymmetry — the range is −128 to +127, not ±127 — is an inherent consequence of having an even number of bit patterns but wanting to include zero.

Understanding two's complement is essential for everything that follows in computer architecture. When you study adder circuits, you will see that subtraction is implemented as addition of the negated value — the ALU flips the bits of the second operand, sets the carry-in to 1, and uses the same adder. When you encounter the ALU's overflow detection, it checks whether two positive inputs produced a negative result (or two negatives produced a positive) — a condition that only makes sense through the lens of two's complement interpretation. And when you reach floating-point representation, you will see two's complement used again for the exponent field's bias encoding. The system is simple, elegant, and universal — which is why every modern processor uses it.

Practice Questions 5 questions

Prerequisite Chain

Understanding Zero → The Number Zero → Counting to Five → Counting to 10 → Counting to 20 → Counting a Set of Objects Up to 20 → Cardinality: The Last Number Counted → Matching Numerals to Quantities → Subitizing Small Quantities → Addition Within 10 → Number Bonds to 10 → Addition Within 20 → Doubles and Near Doubles → Doubles Facts Within 10 → Near Doubles Facts Within 20 → Mental Math Strategies for Addition → Mental Math: Adding and Subtracting Tens → Addition Within 100 → Repeated Addition as Multiplication → Multiplication as Equal Groups → Multiplication: Arrays → Basic Multiplication Facts (0s, 1s, 2s, 5s, 10s) → Multiplication Facts Within 100 → Division as Equal Sharing → Division as Grouping (Measurement Division) → Division: Grouping (Repeated Subtraction) Model → Division: Fair Sharing Model → Division as Equal Sharing → Division as Grouping → Basic Division Facts → Division Facts Within 100 → Multiplication and Division Fact Families → Relationship Between Multiplication and Division → Division Facts as Inverse of Multiplication → Remainders and Quotients in Division → Division Word Problems → Multi-Step Word Problems → Solving Multi-Step Word Problems → Multiplication Word Problems → Division Word Problems → Introduction to Long Division → Factors and Multiples → Prime and Composite Numbers → Equivalent Fractions → Relating Fractions and Decimals → Decimal Place Value → Integers and the Number Line → Comparing and Ordering Integers → Absolute Value → Adding Integers → Subtracting Integers → Multiplying Integers → Introduction to Exponents → Order of Operations → Integer Order of Operations → Variable Expressions → The Distributive Property → Variables and Expressions Review → Introduction to Polynomials → Adding and Subtracting Polynomials → Multiplying Polynomials → Factorial → Permutations → Combinations → Counting Principles: Addition and Multiplication Rules → Introduction to Graph Theory → Propositional Logic Foundations → Logical Equivalences → Boolean Algebra → Boolean Type and Truth Values → Comparison Operators and Boolean Tests → Logical Operators and Boolean Algebra → Boolean Algebra and Fundamental Laws → Logic Gates Fundamentals → Implementing Boolean Functions with Gates → Karnaugh Map Simplification → Combinational Circuit Design → Flip-Flops and Latches → Binary Counters: Design and Analysis → Binary Arithmetic → Fixed-Point Number Representation → Two's Complement Representation

Longest path: 82 steps · 336 total prerequisite topics

Prerequisites (6)

Leads To (4)