← IGCSE Computer Science Paper 1

Converting a positive denary number to two's complement

A denary number from 0 to 127 is written as ordinary binary, padded with zeros to 8 bits so the leftmost sign bit is 0. Numbers above 127 cannot be stored.

Understanding Converting a positive denary number to two's complement in IGCSE Computer Science Paper 1

What it does: Padding with five zeros on the left makes 8 bits. The leftmost sign bit is 0, so the number stays positive. 65 = 64 + 1 is 1000001 in binary, which is only 7 bits. Pad with a leading 0 to make 8 bits: 01000001. Positive numbers need no inverting. 18 = 10010 in binary, which pads to 00010010. Invert and add 1 is for making negative numbers. The sign bit must be 0, so the other 7 bits give at most 127. 11111111 in two's complement is -1, not 255. In 8-bit two's complement the sign bit is 1 for negatives. Positive numbers only go up to 127, so 130 cannot be stored.

Common mistakes: A positive number must have a leading sign bit of 0. 45 in 8 bits is 00101101. Starting with 1 would make it a negative number. Padding adds 0s on the left, not 1s. The padded 8-bit value must be 01100100, so the sign bit stays 0 and the value is still 100.

Class: _____________________  ·  Name: _____________________  ·  Date: _________

Free printable worksheet with full answer key — or add this module to a class and your students practise it interactively.

This module's key terms are also in a printable crossword (Modules 28–41) and word search (Modules 28–58).

Take this worksheet further — free with Cloodit

Each concept is reinforced from every angle — learned, then applied, then tested.

Learning
Duo
Which is 5 written in 8-bit two's complement?
0000010110000101
Matches
13 = 1101
↓
The binary is not padded to 8 bits. It should be 00001101, so that the leftmost sign bit is 0.
Applying
Meanings
Term
positive two's complement
Meaning
A denary number from 0 to 127 is written as ordinary binary, padded with zeros to 8 bits so the leftmost sign bit is 0. Numbers above 127 cannot be stored.
Practice
Denary: 37
Testing
Gaps
65 in 8-bit two's complement: 1000001
Check Answer
Spots
245 = 32 + 8 + 4 + 1
38-bit: 10101101

Cloodit turns curriculum-aligned coding content into journeys students work through one biome at a time.

The 'Ermine' badge — Tundra Streak, one of Cloodit's 106 collectible badges
Students earn collectable badges

Over 100 of them, across seven natural biomes.

Study Buddy
Students build a real study resource

Turns their work into revision material ready for Flash Cards and Exam study.

Diamond Dash — one of Cloodit's live, competitive Sprint games
Students lock in with Sprints

Live, competitive practice for the start of the lesson or a teacher-led lesson finisher.

A Cloodit certificate of achievement, ready to personalise and print
Custom printable certificates

Honour your top performers, or encourage a student who's trying hard — ready to print in seconds.

Quick Questions

1. Which is 5 written in 8-bit two's complement?
A. 00000101 ✓
B. 10000101
A positive number is ordinary binary padded to 8 bits, so the leftmost sign bit is 0. 10000101 has a 1 sign bit, so it would be negative.
2. What is the leftmost (sign) bit of every positive number in 8-bit two's complement?
A. 1
B. 0 ✓
A sign bit of 0 means the number is positive or zero. A sign bit of 1 means the number is negative.
3. Which is 65 written in 8-bit two's complement?
A. 1000001
B. 01000001 ✓
65 = 64 + 1 is 1000001 in binary, which is only 7 bits. Pad with a leading 0 to make 8 bits: 01000001.
4. Can the denary number 200 be stored as a positive number in 8-bit two's complement?
A. No, the largest positive value is 127 ✓
B. Yes, 200 is less than 255 so it fits
The leftmost bit must stay 0 for a positive number, leaving 7 bits for the value. The largest is 127. 200 needs a leading 1, which would make it look negative.
5. Which is 100 written in 8-bit two's complement?
A. 01100100 ✓
B. 11100100
100 = 64 + 32 + 4, which gives 1100100. Pad with a leading 0 to get 01100100. A leading 1 would make the number negative.

Match the Pairs

00101101 → The denary number 45 in 8-bit two's complement, with a leading 0 sign bit
01111111 → 127, the largest positive number that 8 bits can store in two's complement
Denary 5 is 101 in binary, so it is padded with leading zeros to fill 8 bits → 00000101
Denary 100 is written as ordinary binary (64 + 32 + 4) with the leftmost sign bit set to 0 → 01100100
13 = 1101 → The binary is not padded to 8 bits. It should be 00001101, so that the leftmost sign bit is 0.
130 = 10000010 → 130 is above 127, so it cannot be stored in 8-bit two's complement. A leading 1 would mean a negative number (-126).

Key Term

positive two's complement
A denary number from 0 to 127 is written as ordinary binary, padded with zeros to 8 bits so the leftmost sign bit is 0. Numbers above 127 cannot be stored.

Fill in the Blanks

1. 65 in 8-bit two's complement: 01000001
Hint: Type the leftmost bit that every positive number has.
2. 127 in 8-bit two's complement = 01111111
Hint: Type the 8-bit pattern: a leading sign bit then seven 1s.
3. 13 = 8 + 4 + 1, so 8 bits are 00001101
Hint: Type the full 8-bit pattern, padded with leading zeros.
4. Pad 1101 to 8 bits: 00001101
Hint: Type the zeros added on the left to fill 8 bits.
5. IF number > 127 THEN OUTPUT "Too big for 8 bits" ENDIF
Hint: Type the largest positive value 8-bit two's complement can store.

Spot the Error

Question 1
A Number: 45
B 45 = 32 + 8 + 4 + 1
C 8-bit: 10101101
D Sign bit is 0, so positive
Line C — A positive number must have a leading sign bit of 0. 45 in 8 bits is 00101101. Starting with 1 would make it a negative number.
Question 2
A Number: 100
B 100 = 64 + 32 + 4
C Binary: 1100100 (7 bits)
D Pad to 8 bits: 11100100
E Leftmost bit is the sign bit
Line D — Padding adds 0s on the left, not 1s. The padded 8-bit value must be 01100100, so the sign bit stays 0 and the value is still 100.
Question 3
A Number: 127
B Largest positive 8-bit value
C 127 = 11111111
D Sign bit is 0
Line C — 127 is 01111111 in 8-bit two's complement. 11111111 has a sign bit of 1 and means -1.
Question 4
A Number: 5
B 5 = 4 + 1
C Binary: 101
D Pad to 8 bits: 10100000
E Leftmost bit is 0
Line D — The padding zeros go on the left of the binary number, giving 00000101. Adding zeros on the right changes the value.
Question 5
A IF number <= 255 THEN
B Write ordinary binary
C Pad with 0s to 8 bits
D ELSE
E OUTPUT "Cannot store"
Line A — In 8-bit two's complement the largest positive number is 127, not 255. The condition should be number <= 127.

Student with a class code? Join your class →