Encode positive and negative integers in two’s complement
Use a fixed 8-bit two’s complement representation for signed integers from −128 to +127.
Exam scope and assessment notes
This sequence follows Cambridge IGCSE Computer Science 0984, 2026–2028 syllabus Version 4. It covers subject content sections 1.1–1.3 only. The separately published 2029–2031 syllabus is not mapped here. Practice is original, self-checked and does not award an official Cambridge grade. Full timed papers and human subject-teacher review remain outstanding. Cambridge states that 0984 has the same 2026–2028 subject content as 0478, with 9–1 grading. In June and November, Cambridge lists 0984 in Administrative zone 3 and for centres in Oman and the UAE. Confirm availability for your centre and exam series with Cambridge International. The separately published 2029–2031 syllabus changes to Python 3 only and removes pseudocode; this 2026–2028 route does not cover those changes.
Before you begin
- No programming language is required. Be comfortable with place value and multiplication; each lesson introduces the computer-science notation it uses.
Work on paper. Try each question before revealing help, and explain why your method works.
Quick readiness check
What is +12 in eight-bit binary?
What you will learn
- Represent positive values as eight-bit two’s complement
- Convert a negative denary value by invert-and-add-one
- State the representable 8-bit signed range
Positive values use a leading zero
For positive integers, write the ordinary binary value in eight bits. The most significant bit is 0. The 8-bit two’s complement range is −128 to +127, so values outside this range cannot be represented.
Apply and check the rule
To encode a negative value, first write its positive magnitude in eight bits, invert every bit, then add 1. Keep the final result at eight bits.
Pause and explain
What range can an 8-bit two’s complement integer represent?
Worked example
Represent −38 as an 8-bit two’s complement value.
Show the worked solution
- 38 is 00100110.
- Invert the bits: 11011001.
- Add 1: 11011010.
Answer 11011010₂
Try a topic test
Choose Easy, Normal or Difficult. Save your answers and open worked review after finishing.
Test this topic →From guided practice to a new situation
Write your answer and reasoning first. Use a hint only if you are stuck. The model solution is for self-checking; your written work is not automatically marked.
Encode −18 in 8-bit two’s complement.
Give me a hint
Convert +18, invert all eight bits, then add one.
Compare my reasoning
- +18 is 00010010.
- Invert: 11101101.
- Add 1: 11101110.
11101110₂
Look for these in your work
- Positive magnitude correct
- All bits inverted
- One added
Write +91 as an 8-bit two’s complement value.
Give me a hint
Positive signed values use ordinary binary with a leading zero.
Compare my reasoning
- 91=64+16+8+2+1.
- The eight-bit pattern is 01011011.
01011011₂
Look for these in your work
- Value sums to 91
- Leading sign bit is 0
A device stores −73 in an 8-bit signed register. Find its pattern and check that the value is in range.
Give me a hint
Use invert-and-add-one on 73.
Compare my reasoning
- +73 is 01001001.
- Invert to 10110110, then add one to obtain 10110111.
- −73 is within −128 to +127.
10110111₂; it is within the representable range.
Look for these in your work
- Pattern correct
- Negative sign interpretation
- Range checked
Common mistakes
- Stopping after the inversion and forgetting to add one
- Representing positive 128 in eight-bit signed form
What can you explain now?
What is the 8-bit two’s complement representation of −5?
Compare with the explanation
11111011
00000101 inverted is 11111010; adding one gives 11111011.
After trying it yourself, choose your next review. This is your self-assessment.
Your review choice appears on Today. Sign in to sync it across devices.
Make it stick
Why does two’s complement have one more negative value than positive value?
If you needed the solution, close it and solve the problem again from a blank page. A correct answer is stronger when you can explain the reason for each step.