1. Number system
IGCSE Computer Science (0478)
  • Data Representation
    • Introduction
    • Why computers use binary (how binary represents data)
    • Number system
      • Introduction
      • Number Conversions
      • Addition of Binary Numbers
      • Logical binary shifts (positive 8-bit integers)
      • Two’s Complement (Signed: Positive and Negative Numbers)
      • Use of the Hexadecimal System
    • Text, Sound and Image
      • Text, Sound and Images
      • File Types
    • Data storage and File compression
      • Measurement of the Size of Computer Memories
      • Lossless and Lossy File Compression
  1. Number system

Two’s Complement (Signed: Positive and Negative Numbers)

Two’s Complement (Positive and Negative Numbers)#


What is Two’s Complement?#

Two’s complement is a way to represent signed numbers (both positive and negative) in binary. It helps computers easily perform addition and subtraction with positive and negative numbers.

Range of values for n bits#

For n bits, the range of numbers is:
−2n−1to+2n−1−1
For 8 bits, the range is:
−128 to +127

How to find the Two’s Complement (negative of a number)#

To represent a negative number in two’s complement:
1.
Write the positive number in binary using n bits.
2.
Invert the bits (change 0 to 1, and 1 to 0).
3.
Add 1 to the inverted bits.

Example: Find −5 in 8-bit two’s complement#

Write +5 in 8 bits:
0000 0101
Invert bits:
1111 1010
Add 1:
1111 1010 + 1 = 1111 1011
So, 1111 1011 represents −5 in two’s complement.

Practice Questions & Answers#


1. Convert +13 to 8-bit binary, then find −13 in two’s complement#

+13 decimal → binary:
Divide by 2QuotientRemainder
13 ÷ 261
6 ÷ 230
3 ÷ 211
1 ÷ 201
Reading remainders bottom to top: 1101
Add leading zeros for 8 bits: 0000 1101
Find −13 two’s complement:
Invert bits: 1111 0010
Add 1: 1111 0010 + 1 = 1111 0011
Answer:
+13 = 0000 1101
−13 = 1111 0011

2. What decimal number does 1000 0000 represent in 8-bit two’s complement?#

1000 0000 starts with 1 → negative number.
To find the value:
Invert bits: 0111 1111
Add 1: 0111 1111 + 1 = 1000 0000 (decimal 128)
So, 1000 0000 = −128

Summary Table: Two’s Complement Range for 8 bits#

BinaryDecimal Value
0000 00000
0000 00011
......
0111 1111+127
1000 0000−128
1000 0001−127
......
1111 1111−1
Modified at 2025-08-11 06:30:00
Previous
Logical binary shifts (positive 8-bit integers)
Next
Use of the Hexadecimal System
Built with