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 moreArithmetic 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 ZeroThe Number ZeroCounting to FiveCounting to 10Counting to 20Counting a Set of Objects Up to 20Cardinality: The Last Number CountedMatching Numerals to QuantitiesSubitizing Small QuantitiesAddition Within 10Number Bonds to 10Addition Within 20Doubles and Near DoublesDoubles Facts Within 10Near Doubles Facts Within 20Mental Math Strategies for AdditionMental Math: Adding and Subtracting TensAddition Within 100Repeated Addition as MultiplicationMultiplication as Equal GroupsMultiplication: ArraysBasic Multiplication Facts (0s, 1s, 2s, 5s, 10s)Multiplication Facts Within 100Division as Equal SharingDivision as Grouping (Measurement Division)Division: Grouping (Repeated Subtraction) ModelDivision: Fair Sharing ModelDivision as Equal SharingDivision as GroupingBasic Division FactsDivision Facts Within 100Multiplication and Division Fact FamiliesRelationship Between Multiplication and DivisionDivision Facts as Inverse of MultiplicationRemainders and Quotients in DivisionDivision Word ProblemsMulti-Step Word ProblemsSolving Multi-Step Word ProblemsMultiplication Word ProblemsDivision Word ProblemsIntroduction to Long DivisionFactors and MultiplesPrime and Composite NumbersEquivalent FractionsRelating Fractions and DecimalsDecimal Place ValueIntegers and the Number LineComparing and Ordering IntegersAbsolute ValueAdding IntegersSubtracting IntegersMultiplying IntegersIntroduction to ExponentsOrder of OperationsInteger Order of OperationsVariable ExpressionsThe Distributive PropertyVariables and Expressions ReviewIntroduction to PolynomialsAdding and Subtracting PolynomialsMultiplying PolynomialsFactorialPermutationsCombinationsCounting Principles: Addition and Multiplication RulesIntroduction to Graph TheoryPropositional Logic FoundationsLogical EquivalencesBoolean AlgebraBoolean Type and Truth ValuesComparison Operators and Boolean TestsLogical Operators and Boolean AlgebraBoolean Algebra and Fundamental LawsLogic Gates FundamentalsImplementing Boolean Functions with GatesKarnaugh Map SimplificationCombinational Circuit DesignFlip-Flops and LatchesBinary Counters: Design and AnalysisBinary ArithmeticFixed-Point Number RepresentationTwo's Complement Representation

Longest path: 82 steps · 336 total prerequisite topics

Prerequisites (6)

Leads To (4)