Width, positional weights and range
N is the fixed word width and every bi is 0 or 1. The leftmost bit is not a separate minus sign attached to a positive magnitude: its positional weight is negative.[2]
Four bits have weights −8, +4, +2 and +1. Thus 10002 means −8 in four-bit two’s complement, while 01112 means +7. There is exactly one zero pattern, 00002. All 16 patterns are used, so the magnitude of the negative limit exceeds the positive limit by one. Ordinary positional representation remains valid for lower bits; only the highest bit changes interpretation.
u is the unsigned value of the same N-bit pattern. If the highest bit is 1, subtract 2ᴺ. This is an alternative to summing every signed positional weight.[1]
Encode negative values and change width
A representable negative value −a is encoded using the N-bit unsigned value 2ᴺ−a. Inverting bits and adding one is the corresponding modular operation; keep the result limited to N bits.[1]
The bit rule follows by subtraction: complementing all N bits gives unsigned 2ᴺ−1−u, and adding one gives 2ᴺ−u. Modulo 2ᴺ this is the additive inverse of u. However, negating the most negative number in the same width leaves its bit pattern unchanged because its positive counterpart is outside the range. In eight bits, +128 is unrepresentable even though −128 is representable.
To widen a signed value without changing it, prepend copies of its existing sign bit. The negative four-bit pattern 11012 becomes 111111012 in eight bits; both mean −3. Zero-extending to 000011012 would instead change the value to +13. Before narrowing a word, verify that the value fits the destination range.[2]
Carry and signed overflow
Here fixed-width N-bit addition stores the lowest N result bits. That is arithmetic modulo 2ᴺ rather than unbounded integer addition. Signed overflow occurs when the mathematical sum lies outside the N-bit range. For addition, two inputs with the same sign producing the opposite sign indicate overflow. A carry beyond the word alone is not a reliable signed-overflow test.[2][3]
This arithmetic model describes the bit representation. Whether a programming language wraps, raises an exception or follows other rules is a separate language contract. A hardware bit pattern therefore does not establish universal behavior for expressions in C, Java, Python or another language.
Two complete worked examples
Encode −37 in eight bits and decode it
- Given
- Value −37, fixed width N = 8.
- Find
- Find the bit pattern and verify its value.
Write positive 37 using eight bits.
Invert all eight bits and add one.
Check independently using the unsigned code.
Result: −37 is represented by 110110112 in eight bits.
Check: The direct method 28 − 37 = 219 gives the same code. −37 lies in the range −128 through +127.
A four-bit sum overflows
- Given
- 01012 + 01002, both interpreted as four-bit two’s complement.
- Find
- Compare the stored pattern with the mathematical sum.
The inputs mean +5 and +4.
Add the four-bit patterns.
Decode the result using the negative highest positional weight.
Result: The stored pattern 10012 means −7; the mathematical sum +9 does not fit four bits. Signed overflow has occurred.
Check: Both inputs are positive but the stored result is negative. The range −8 through +7 independently confirms overflow.
Recall the method later with the formula’s flashcards.
10 flashcards · English materials
Already have an account? Sign in for flashcardsAvailable from Essential. A ready-made formula set, no AI credits required. Article exercises are not all included.
Five exercises with solutions
Calculate · Foundation
Decode 111010102 as eight-bit two’s complement.
Show hint
Find the unsigned value first, then subtract 256.
Learning goal: Convert a negative bit pattern to decimal reliably.
Show solution and calculation
The unsigned value is 128 + 64 + 32 + 8 + 2 = 234, so x = 234 − 256 = −22.
Rearrange · Application
What minimum two’s-complement width can represent every integer from −200 through +200?
Show hint
Check the positive limit 2ᴺ−1 − 1.
Learning goal: Determine the required width from a requested range.
Show solution and calculation
Eight bits are insufficient because their positive limit is 127.
Nine bits range from −256 through +255 and cover the entire interval.
Nine bits is minimal.
Interpret · Application
Sign-extend 101102 from five to eight bits without changing its signed value.
Show hint
The leftmost bit is 1; repeat it on the left.
Learning goal: Explain sign extension as a value-preserving operation.
Show solution and calculation
101102 means 22 − 32 = −10.
Sign extension gives 111101102, which means 246 − 256 = −10.
Prepending zeros would change the value.
Error analysis · Application
In four bits, 11112 + 00012 gives 00002 with a carry beyond the word. Claim: every carry is signed overflow. Is this correct?
Show hint
First interpret both inputs as signed values.
Learning goal: Distinguish carry from signed overflow.
Show solution and calculation
No. 11112 is −1 and 00012 is +1.
Their mathematical sum 0 is representable, and 00002 is correct.
There is a carry but no signed overflow.
Transfer · Challenge
Negate the eight-bit pattern 100000002 by inverting and adding one. Why is the result not a representable positive counterpart?
Show hint
Compare −128 with the largest positive eight-bit value.
Learning goal: Apply the asymmetric range to the most negative value.
Show solution and calculation
Inversion gives 011111112, and adding one returns 100000002.
This still means −128.
Its mathematical opposite +128 exceeds the positive limit +127.
Widen to at least nine bits before computing a representable positive counterpart.
Check your understanding with the formula’s reference test.
6 test questions · English materials
Already have an account? Sign in for the testAvailable from Essential. A ready-made formula set, no AI credits required. Article exercises are not all included.
Sources for this explanation
Quanta · Updated November 7, 2026
- Thomas Finley, Cornell University, Two’s Complement
- HTW Dresden, Mathematik 1, 4.4 Zweierkomplement
- TU Dortmund, Einführung in die Informatik, Überlauf
Editorial responsibility: Quanta Study editorial team
Review scope
This explanation, 2 worked examples and 5 exercises are available in German and English. Structure, source references and mathematical notation undergo automated checks. Calculations, model assumptions and both language versions receive a separate AI review.
An independent, named human subject review has not yet been documented. Our exercise numbers are worked examples, rather than measurements published by the cited sources.
Editorial responsibility, sources and methodsChange history
- Added a DE/EN article covering negative positional weight, two encoding methods, sign extension, overflow checks, two examples and five exercises.
Cite this reference page
Quanta. Two’s-complement signed integer. Updated November 7, 2026. https://quanta-study.de/en/formula-sheet/zweierkomplement
When citing a specific scientific statement, also cite the specialist source linked to that statement.