ConceptStep · learning platform for computer science

Subtraction with two's complement

Number systems · Lesson

← ConceptStep

Subtraction with two's complement

8-bit method

To calculate A − B: represent A and B on 8 bits, compute C2(B), then perform A + C2(B). Discard any carry beyond 8 bits and interpret the result as signed.

Example: 25 − 37

A = 00011001

B = 00100101

Invert B → 11011010

+1 → 11011011

00011001+11011011=11110100

Signed result: -12.

Practice

Progress: 0 / 5 — correct: 0

Calculate using 8 signed bits: 23 − -11

23=00010111; -11=11110101; invert the second value: 00001010; +1: 00001011; add on 8 bits: 00100010.

Overflow

With 8 signed bits the result must remain between −128 and +127. A result outside that range causes overflow.

Your competency map

What you need to know for Subtraction with two's complement

ConceptStep separates what is required from what is recommended or useful as reinforcement. Only required prerequisites block your progress.

Current topic Strong skill Review due Needs reinforcement To be mastered Optional support

Relationships: solid line = required · dashed line = recommended · dotted line = reinforcement.

GUIDED LEARNING PATHS

Want to choose the next skill to develop?