Unable to open this exercise
Common exam pitfall
Students often forget to add 1 after inverting the bits when finding a negative two's complement value.
Two's complement is the universal method used by digital computers to represent both positive and negative integers in binary.
Learning Objectives
- Understand the concept and need for two's complement signed representation.
- Convert between denary integers and 8-bit two's complement binary across the range $-128$ to $+127$.
- Explain the engineering advantages of two's complement over sign-and-magnitude representation.
Core Syllabus Theory
1. Why Two's Complement is Needed
Unsigned binary representation can only store positive integers (e.g. 8 bits represent $0$ to $255$). Computer processors require a reliable system to represent negative numbers as well.
An older approach called sign-and-magnitude used the leftmost bit as a sign indicator ($0 = +, 1 = -$). However, sign-and-magnitude has two major design flaws:
- Two representations for zero: $+0$ ($00000000$) and $-0$ ($10000000$), wasting code space and complicating logic equality comparisons.
- Complex hardware: Standard binary addition hardware fails when adding negative numbers; dedicated subtraction circuitry is required.
Two's complement solves both problems:
- There is only one representation of zero ($00000000$).
- Subtraction can be performed using standard addition circuitry: $A - B = A + (-B)$.
2. Positional Place Values for 8-Bit Two's Complement
In an 8-bit two's complement register, the Most Significant Bit (MSB) carries a negative weight of $-128$. All other positions carry positive binary weights:
- Positive integers (MSB = 0): Range from $00000000_2 \ (0_{10})$ to $01111111_2 \ (+127_{10})$.
- Negative integers (MSB = 1): Range from $11111111_2 \ (-1_{10})$ down to $10000000_2 \ (-128_{10})$.
- Total range: $-128$ to $+127$ ($256$ distinct values).
3. Converting Negative Denary to 8-Bit Two's Complement
To convert a negative denary number (e.g. $-38$) to 8-bit two's complement, follow the Invert and Add 1 algorithm:
- Step 1: Write the positive binary number in full 8 bits:
- Step 2: Invert all bits ($0 \to 1$ and $1 \to 0$) to obtain One's Complement:
- Step 3: Add 1 to the inverted binary string:
4. Converting Two's Complement Binary to Denary
Method A: Direct Positional Place Value Addition
Evaluate $11110100_2$:
Method B: Invert and Add 1 (Magnitude Retrieval)
- Invert $11110100 \to 00001011$.
- Add $1$: $00001011 + 1 = 00001100_2 = 12_{10}$.
- Attach the negative sign: $-12_{10}$.
Exam Tips & Common Pitfalls
Note: Always Write 8 Full Bits: When converting positive numbers, never omit leading zeros before inverting. Inverting $100110$ is completely wrong; you must invert the full 8-bit representation $00100110$. Checking Negative One: $-1$ in two's complement is always represented by all 1s ($11111111_2$).
Key Terminology Glossary
- Two's Complement: A method of encoding signed integers where the MSB has a negative place value.
- One's Complement: The intermediate binary value obtained by inverting all bits of a binary number.
- Sign Bit: The leftmost bit (MSB), where 0 indicates positive and 1 indicates negative.
Written practice and self-review
Explain two distinct reasons why computer processors use two's complement representation rather than sign-and-magnitude representation to store signed integers in hardware.
Write an explanation before checking the theory. Check that each claim answers the question, uses the correct concept and explains why it applies. Discuss uncertain points with a teacher. The structured exercise below checks specific facts; it does not automatically mark this explanation.
AI Socratic Tutor
Need guidance? Ask a question or use the hint below.
AI Socratic Tutor is an All-Access Benefit
Unlock step-by-step Socratic hints, algorithm trace table walkthroughs, and error diagnostics for every Cambridge exercise.
You're chatting with an AI tutor, not a person. AI can make mistakes, so double-check its answers.
Exam-Style Question: Two's Complement Conversions
- Represent denary -38 as an 8-bit two's complement binary number.
- Convert 8-bit two's complement 11110100 to denary.
- Convert 8-bit two's complement 01001100 to denary.
- Denary -38 in two's complement: [Space 1]
- Denary value of 11110100: [Space 2]
- Denary value of 01001100: [Space 3]
Sign in or create a free account to test your solution and track XP.