Converting a positive denary number to two's complement

Tip: Choose Save as PDF in the print dialog to download. Use A4 paper size.

Converting a positive denary number to two's complement

Name:
Date:
Class:

Quick Questions

Shade in the A or B circle for each question.

1. Which is 5 written in 8-bit two's complement?
A 00000101
B 10000101
2. What is the leftmost (sign) bit of every positive number in 8-bit two's complement?
A 1
B 0
3. Which is 65 written in 8-bit two's complement?
A 1000001
B 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
5. Which is 100 written in 8-bit two's complement?
A 01100100
B 11100100

Match the Pairs

Draw a line connecting each item on the left to its match on the right.

Left columnRight column
100101101 AThe denary number 45 in 8-bit two's complement, with a leading 0 sign bit
201111111 BThe binary is not padded to 8 bits. It should be 00001101, so that the leftmost sign bit is 0.
3Denary 5 is 101 in binary, so it is padded with leading zeros to fill 8 bits C130 is above 127, so it cannot be stored in 8-bit two's complement. A leading 1 would mean a negative number (-126).
4Denary 100 is written as ordinary binary (64 + 32 + 4) with the leftmost sign bit set to 0 D127, the largest positive number that 8 bits can store in two's complement
513 = 1101 E01100100
6130 = 10000010 F00000101

Definitions

positive two's complement

Fill in the Blanks

Complete each line of code by filling in the missing parts.

1.
65 in 8-bit two's complement: _1000001
2.
127 in 8-bit two's complement = ________
3.
13 = 8 + 4 + 1, so 8 bits are ________
4.
Pad 1101 to 8 bits: ____1101
5.
IF number > ___ THEN OUTPUT "Too big for 8 bits" ENDIF

Spot the Error

Shade in the letter of the line that contains an error.

Question 1
A Number: 45
B 45 = 32 + 8 + 4 + 1
C 8-bit: 10101101
D Sign bit is 0, so positive
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
Question 3
A Number: 127
B Largest positive 8-bit value
C 127 = 11111111
D Sign bit is 0
Question 4
A Number: 5
B 5 = 4 + 1
C Binary: 101
D Pad to 8 bits: 10100000
E Leftmost bit is 0
Question 5
A IF number <= 255 THEN
B Write ordinary binary
C Pad with 0s to 8 bits
D ELSE
E OUTPUT "Cannot store"

Answer Key

Converting a positive denary number to two's complement
Section A: Quick Questions
Q1
A — 00000101
Q2
B — 0
Q3
B — 01000001
Q4
A — No, the largest positive value is 127
Q5
A — 01100100
Section B: Match the Pairs
Q1
00101101 → The denary number 45 in 8-bit two's complement, with a leading 0 sign bit
Q2
01111111 → 127, the largest positive number that 8 bits can store in two's complement
Q3
Denary 5 is 101 in binary, so it is padded with leading zeros to fill 8 bits → 00000101
Q4
Denary 100 is written as ordinary binary (64 + 32 + 4) with the leftmost sign bit set to 0 → 01100100
Q5
13 = 1101 → The binary is not padded to 8 bits. It should be 00001101, so that the leftmost sign bit is 0.
Q6
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).
Section C: Definitions
Q1
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.
Section D: Fill in the Blanks
Q1
65 in 8-bit two's complement: 01000001
Q2
127 in 8-bit two's complement = 01111111
Q3
13 = 8 + 4 + 1, so 8 bits are 00001101
Q4
Pad 1101 to 8 bits: 00001101
Q5
IF number > 127 THEN OUTPUT "Too big for 8 bits" ENDIF
Section E: Spot the Error
Q1
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.
Q2
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.
Q3
C — 127 is 01111111 in 8-bit two's complement. 11111111 has a sign bit of 1 and means -1.
Q4
D — The padding zeros go on the left of the binary number, giving 00000101. Adding zeros on the right changes the value.
Q5
A — In 8-bit two's complement the largest positive number is 127, not 255. The condition should be number <= 127.