We’re moving to a new home! Our website is currently in test mode while we update and transfer our content. Some pages and resources may be temporarily unavailable. We’ll be back with all resources shortly. Thank you for your patience.

CIE IGCSE | 1.1.6 Negative Numbers And Two’S Complement

Lesson objective

Represent positive and negative integers using 8-bit two’s complement and convert between binary and denary.

Learn

1.1.6 | NEGATIVE NUMBERS AND TWO’S COMPLEMENT

01 | HOW CAN BITS REPRESENT A NEGATIVE VALUE?

So far, an unsigned 8-bit pattern has represented a value from 0 to 255. But programs also need values below zero, such as a temperature of −5 or a negative change in a balance.

Two’s complement is a system for representing signed integers. The same bits can mean different values depending on the representation being used. You must know whether the question uses unsigned binary or two’s complement.

In this lesson we use exactly eight bits. The leftmost bit has a negative place value; the other seven keep their ordinary positive place values.

02 | THE LEFTMOST PLACE IS WORTH NEGATIVE 128

Eight-bit two’s complement place values
Stage-1286432168421
Example: −1011110110
11110110
= −128 + 64 + 32 + 16 + 4 + 2
= −10

A 1 in the first column contributes −128. It is not simply a minus sign followed by a seven-bit magnitude. Here, the remaining positive contributions total 118, giving −128 + 118 = −10.

A leading 0 means zero or a positive value. A leading 1 means a negative value in this eight-bit two’s complement system.

03 | THE RANGE IS −128 TO +127

Important eight-bit patterns
Stage-1286432168421
Largest positive01111111
Zero00000000
Most negative10000000
Negative one11111111

The greatest positive value is 64 + 32 + 16 + 8 + 4 + 2 + 1 = 127. The most negative value is −128 with no positive contributions.

There are still 256 possible patterns: 128 negative values, zero and 127 positive values. Two’s complement has one representation of zero.

Unsigned 8-bit binary ranges from 0 to 255. Eight-bit two’s complement ranges from −128 to +127. The width is the same; the interpretation is different.

04 | POSITIVE VALUES KEEP THEIR FAMILIAR FORM

Positive numbers in eight-bit two’s complement
Stage-1286432168421
+1000001010
+3700100101

For values from 0 to 127, use the ordinary binary pattern padded to eight bits. The leading bit is 0.

Do not invert and add one when the question asks for a positive value. Those steps below construct the corresponding negative representation.

05 | BUILD A NEGATIVE VALUE: INVERT, THEN ADD ONE

To represent −10, start with the eight-bit pattern for +10. Change every 0 to 1 and every 1 to 0, then add 1 using binary addition.

Constructing −10 using eight-bit patterns
Stage-1286432168421
+10: starting value00001010
Invert every bit11110101
Add this value00000001
−10: final pattern11110110

Inverting alone is not enough. 11110101 represents −11 in this system. The final addition produces 11110110, which represents −10.

Keep all eight bits throughout the method. Show the starting pattern, inversion and final answer clearly.

06 | ANOTHER EXAMPLE: NEGATIVE 37

Constructing −37
Stage-1286432168421
+3700100101
Invert11011010
Add one00000001
−3711011011
Check the signed place values:
−128 + 64 + 16 + 8 + 2 + 1 = −37

Use a different method to check your answer: read the negative place value and add the positive columns containing 1. This catches mistakes in either the inversion or the addition.

07 | READ A NEGATIVE PATTERN USING PLACE VALUES

Reading 10110100 as two’s complement
Stage-1286432168421
Given pattern10110100

The leading bit is 1, so include −128. The other 1s are in the 32, 16 and 4 columns.

10110100 = −128 + 32 + 16 + 4 = −76

This method works for any eight-bit two’s complement pattern, including the special case 10000000.

08 | OR FIND THE MAGNITUDE, THEN APPLY THE MINUS

For a negative pattern, you can invert and add one to find its magnitude, then attach a minus sign to the denary answer.

Finding the magnitude of 10110100
Stage-1286432168421
Given: −7610110100
Invert01001011
Add one00000001
Magnitude: 7601001100

01001100 is 76, so the original value is −76. Do not forget the minus sign. Use this method only after establishing that the original pattern is negative.

09 | HANDLE NEGATIVE 128 CAREFULLY

−128 is represented by 10000000. There is no +128 in eight-bit two’s complement: the greatest positive value is +127.

If you invert 10000000 and add one, you get 10000000 again in eight bits. Read that result as an unsigned magnitude of 128 when finding the magnitude, not as a positive signed value in the same eight-bit system.

The clearest check is the place-value method: −128 plus no positive contributions is −128.

10 | THE SAME PATTERN CAN HAVE TWO INTERPRETATIONS

Check the representation before interpreting the bits
Stage-1286432168421
Pattern11111111
Unsigned:        128 + 64 + 32 + 16 + 8 + 4 + 2 + 1 = 255
Two’s complement: −128 + 64 + 32 + 16 + 8 + 4 + 2 + 1 = −1

The bits have not changed. The assigned value of the leftmost column has changed. This is why a question must specify the representation.

Two’s complement also supports signed arithmetic, but signed overflow is not judged by the same rule as the unsigned overflow in 1.1.4. Do not assume any carry out always means signed overflow.

11 | TRY IT: READ ANY EIGHT-BIT PATTERN

Enter a pattern and predict its signed value. Compare the signed and unsigned interpretations and inspect which columns contribute.

PRACTISE | BUILD AND EXPLAIN

For the guided builder, choose a magnitude from 1 to 127 and reveal the steps in order. Then complete the activities and independent questions.

TWO’S COMPLEMENT CHALLENGE

Enter your answers. Binary patterns must keep the requested width; spaces and hex letter case are accepted.

MATCH THE TERMINOLOGY

Choose the term that matches each description.

Terminology

Terminology

Two’s complement

A binary representation of signed integers.

Signed 8-bit range

−128 to +127 inclusive.

Significant signed place value

The leading bit has place value −128 in eight-bit two’s complement.

Invert bits

Change every 0 to 1 and every 1 to 0.

Negating a bit pattern

Invert all bits and add 1 within the fixed width.

Interpretation

The agreed representation determines whether a pattern is unsigned or signed.

Questions

Questions

APPLY YOUR SKILLS

Enter your answers. Binary patterns must keep the requested width; spaces and hex letter case are accepted.

TICK-BOX QUIZ

Select all correct choices. Each exact set earns one point.

1. What is the signed 8-bit two’s complement range?
2. Which statements are correct?
3. What is 11111111 in two’s complement?
4. How is −5 represented in 8-bit two’s complement?
5. Which values fit signed 8-bit two’s complement?
6. What is 10000000?

WRITTEN QUESTIONS

Answer in your book first. These are practice questions and suggested answers, not official exam questions or mark schemes.

1. Represent −18 in 8-bit two’s complement. Show each step. [3 marks]

2. Convert 10110100 from two’s complement to denary. [2 marks]

3. Explain why 11111111 can mean either 255 or −1. [2 marks]

4. Explain why +128 is not a valid signed 8-bit value. [2 marks]

Flashcards

Flashcards

Click a card to flip it. Tick the cards you need to revisit.

0 cards selected for revision.

    Selections are kept while this page is open.

    Workbook

    Workbook

    A place to practise, explain and apply your learning.

    COMING SOON

    The workbook for 1.1.6 Negative Numbers And Two’S Complement is coming soon. For now, use the Questions tab and write your answers in your exercise book.