Teachers' Portal  /  IGCSE Computer Science 0478  /  Data representation  /  Two's complement for negative numbers
Lesson pack · IGCSE Computer Science 0478 · 1.1 · IGCSE

Two's complement for negative numbers

Negative numbers in binary. A register has no space for a minus sign, so the computer has to show negative numbers with bits alone.

Student lesson Lab, full screen
At a glance

The shape of the lesson

Topic
Data representation
Syllabus reference
Cambridge IGCSE Computer Science 0478, 1.1
Level
IGCSE
Duration
45 minutes, lab-led; stretches to a 60 minute block (see the contingency notes)
Position in topic
Lesson 5 of 10 in Data representation; follows Logical binary shifts; leads into Representing text: ASCII and Unicode
Central model
Fig. 1: in two's complement the leftmost bit is worth −128, so 11101100 is −20
Cooperative structure
Assessment
Stage 1 check and the exam-style plenary from the student lesson, plus the worksheet as the exit task
Learning objectives

By the end of the lesson, learners can

Section by section
  • A negative place value: In the lab, switch the bits on and off.
  • Flip and add one: The lab's negate button shows the method in two steps.
  • Positive and negative side by side: Every positive number from 0 to 127 has a negative partner.
Key points to leave on the board
  • Place values: −128, 64, 32, 16, 8, 4, 2, 1.
  • Sign: leftmost bit 1 means negative, 0 means positive.
  • Make a negative: write the positive in 8 bits, flip every bit, add 1.
  • Check: add up the place values, starting from −128.
The core visual model

One picture every idea returns to

In 8-bit two's complement the most significant bit has the place value −128; the other bits are 64, 32, 16, 8, 4, 2, 1 as usual. So a number starting with 1 is negative and one starting with 0 is positive. The range is −128 to +127. To make a negative number, write the positive version in 8 bits, flip every bit, then add 1.

8-bit two’s complement place values −128643216 8421 1110 1100 −128 + 64 + 32 + 8 + 4 = −20 most significant bit 1 = negative, 0 = positive range −128 to +127
Fig. 1: in two's complement the leftmost bit is worth −128, so 11101100 is −20
Lesson sequence

Forty-five minutes, phase by phase

TimePhaseWhat happens in the roomGrouping
0 to 5 minHook: predictOpen with the question in the title, Negative numbers in binary.. A register has no space for a minus sign, so the computer has to show negative numbers with bits alone. Put the figure on the board: it is the one picture every idea in the lesson returns to.Whole class, then pairs
5 to 13 minTeach and check: A negative place valueIn the lab, switch the bits on and off. Project tab 5 of the lab (Two's complement register) and let a student drive it while the class predicts. Model the worked example Two's complement to denary on the board, one line at a time.Whole class, then pairs
13 to 21 minTeach and check: Flip and add oneThe lab's negate button shows the method in two steps. Project tab 5 of the lab (Negate by flip and add 1) and let a student drive it while the class predicts. Model the worked example Denary to two's complement on the board, one line at a time. Your turn: Convert −100 to an 8-bit two's complement integer.Pairs
21 to 30 minTeach and check: Positive and negative side by sideEvery positive number from 0 to 127 has a negative partner.Rally Coach
30 to 36 minCheckThe four Stage 1 questions from the student lesson, answered on mini whiteboards or by show of fingers. Re-teach the one most get wrong.Individual, then whole class
36 to 43 minPlenaryThe exam-style questions from Stage 2, one at a time: thirty seconds alone, then a random call. The feedback lines in the key give the examiner's wording.Individual, random call
43 to 45 minExit and homeworkSet the worksheet below (6 questions, 13 marks). Learners self-assess against the objectives before they leave.Individual
Timing and contingency

Protect the parts that carry the learning

The sequence carries about fifty minutes of material, so the lab is driven by one student while the class predicts rather than explored freely. Times are a guide.

Protected: the check at 30 minutes. It is the only individual read on whether the key idea landed, and it is not cut.

Cut first if the build overruns: the last check in Positive and negative side by side, never the check or the plenary.

In a 60 minute block: run worksheet questions 1 to 3 in class as a Rally Coach set and model both the hardest worked example and its check live.

Running the cooperative task

Rally Coach

Pairs share one worksheet. One partner solves the first question aloud while the other coaches, checking each line and offering a prompt rather than the answer; they swap roles for the next question.

The full structure, with its variations and the other twelve, is on the cooperative-learning page.

Examiner traps to pre-empt

What to head off, and how

Trap learners fall intoTeaching move that pre-empts it
Do not read the leftmost 1 as just a minus sign. 10000101 is −128 + 5 = −123, not −5.Return to A negative place value: ask a pair to state the correct version and show it on the lab before moving on.
+128 cannot be stored in 8-bit two's complement.The largest positive value is +127.
Worksheet

Two's complement for negative numbers: worksheet

6 questions, 13 marks. Written in the style of the papers; no past paper question is reproduced.

NameClassDate
Q1 · convert[2 marks]

Convert −27 to an 8-bit two's complement integer. Show your working.

Q2 · convert[2 marks]

Convert the 8-bit two's complement integer 11001110 to denary.

Q3 · explain[2 marks]

Explain how you can tell whether an 8-bit two's complement integer is positive or negative.

Q4 · recall[2 marks]

(a) State the range of values that can be stored as an 8-bit two's complement integer. (b) Explain why +200 cannot be stored.

Q5 · convert[2 marks]

Give the 8-bit two's complement representation of (a) +84 and (b) −84.

Q6 · analysis[3 marks]

A student represents −12 in 8-bit two's complement as 10001100. Explain the error, give the correct answer, and state what the student's answer actually represents.

Answer key and marking notes
Q1 · 2 marks
  • 27 = 00011011; flipped = 11100100.
  • Add 1: 11100101.
Q2 · 2 marks
  • −128 + 64 + 8 + 4 + 2.
  • = −50.
Q3 · 2 marks
  • Look at the most significant (leftmost) bit, which has a place value of −128.
  • If it is 1 the number is negative; if it is 0 the number is positive (or zero).
Q4 · 2 marks
  • (a) −128 to +127.
  • (b) 200 is greater than the largest value, +127.
Q5 · 2 marks
  • (a) 01010100.
  • (b) 10101100 (flip 01010100 to 10101011, then add 1).
Q6 · 3 marks
  • The student only changed the leftmost bit to 1, as if it were just a minus sign.
  • Correct: 12 = 00001100; flip 11110011; add 1: 11110100.
  • 10001100 = −128 + 12 = −116.
Quiz

6 multiple-choice questions on this lesson

From the topic question bank. Assign them in the app for a marked score in your gradebook, or run the topic as a class game.

Q11 mark

In an 8-bit two's complement integer, what is the place value of the most significant (leftmost) bit?

  • A−128
  • B+128
  • C−1
  • D−127
Q21 mark

What is the denary value of the 8-bit two's complement integer 11010010?

  • A−46
  • B−82
  • C210
  • D−45
Q31 mark

Which is −25 as an 8-bit two's complement integer?

  • A11100111
  • B10011001
  • C11100110
  • D00011001
Q41 mark

What is the largest positive number that can be stored as an 8-bit two's complement integer?

  • A+127
  • B+255
  • C+128
  • D+64
Q51 mark

A student tries to store −20 in 8-bit two's complement by writing 10010100. What denary value does this pattern actually represent in two's complement?

  • A−108
  • B−20
  • C148
  • D−107
Q61 mark

An 8-bit two's complement register holds 01111111. 1 is added using ordinary binary addition. What value does the result represent?

  • A−128
  • B+128
  • C−127
  • D0
Quiz key
Q1: A

The leftmost bit is worth −128, so 11111111 = −128 + 127 = −1. +128 is its value in an unsigned integer. Treating it as −1 (or as a plain minus sign) is the sign and magnitude mistake. −127 is the smallest value in sign and magnitude, not a place value.

Q2: A

−128 + 64 + 16 + 2 = −46. −82 treats the first bit as only a minus sign in front of 1010010. 210 reads the number as unsigned. −45 comes from flipping the bits but forgetting to add 1.

Q3: A

+25 = 00011001; flipping gives 11100110; adding 1 gives 11100111. Check: −128 + 64 + 32 + 4 + 2 + 1 = −25. 10011001 only changes the first bit to 1. 11100110 forgets to add 1 (it is −26). 00011001 is +25.

Q4: A

The largest positive value is 01111111 = 127. 255 needs the top bit, which would make the number negative. +128 would also need the top bit. +64 is just the value of the second bit.

Q5: A

−128 + 16 + 4 = −108. The student only changed the leftmost bit, which works in sign and magnitude but not in two's complement (−20 is really 11101100). 148 is the unsigned value. −107 comes from flipping the bits without adding 1.

Q6: A

01111111 + 00000001 = 10000000, which in two's complement is −128. +128 is outside the range −128 to +127, so it cannot be stored; the true answer has overflowed into the sign bit. −127 would be 10000001. The result is not 0 because no carry left the register.

Lab and demo

What to project

The student lesson embeds these tabs. Open them full screen on the projector; every slider has a drag handle on the stage.

Slides

Slides for this lesson

A projectable deck for every pack is on the way. Until then, present the student lesson full screen: its sections, figure and lab tabs follow the same order as the plan above.

Also for this topic

Everything else you can use

Original work by the TheLucidSTEM team. The worksheet items are written in the style of the papers; no past paper question is reproduced.
Previous lessonLogical binary shifts