L
LLLOS.ai
Learn
L

Ask Your Tutor · Computer Science

How do you find the two's complement of a number?

From NCERT Asked by Anonymous from Bordeaux, France 23 Oct 2026, 7:26 PM IST Updated

In one line

Two's complement is a way to write negative numbers in binary by flipping the bits and adding one.

The rule

To find the two's complement of a binary number: Invert all the bits, then add 1 to the result.

Let's understand it simply

Imagine you are playing a game with coins. Heads means 1, tails means 0. If you want to "flip" all your coins, you turn every head to tail and every tail to head. This is called inverting the bits. After flipping, you add 1 more coin to your total. This is how computers show negative numbers using two's complement.

How it works

  1. Write the binary number (example: 0101 for 5).
  2. Flip each bit (0 becomes 1, 1 becomes 0). Now 0101 becomes 1010.
  3. Add 1 to the flipped number. 1010 + 1 = 1011.
  4. The result (1011) is the two's complement, which represents -5 if you started with 5.
Finding Two's Complement
  1. Write the binary number
  2. Flip all bits (0↔1)
  3. Add 1 to the result

The story behind it

Two's complement was developed in the early days of computers to make subtraction and negative numbers easy for machines. Before this, computers used other methods, but two's complement made calculations simpler and faster. It is now the standard way computers store negative numbers.

Where you see it in real life

-

  • When a computer subtracts numbers, it uses two's complement to handle negatives.
  • When you store a negative number in a programming language like C or Python, it uses two's complement inside the computer.
  • Microcontrollers in washing machines or cars use two's complement to process sensor data.
  • Calculators use it to show negative results.
  • Digital clocks use it to adjust time backwards.

Why it matters

  • Makes addition and subtraction of positive and negative numbers easy for computers.
  • Saves space: No need for extra symbols for negative numbers.
  • Used in almost all modern computers and devices.
  • Helps you understand how programming languages store and process numbers.

Worked example

Let's find the two's complement of 6 (in 4 bits):

Given: 6 in binary = 0110
Step 1: Invert all bits      0110 → 1001
Step 2: Add 1                1001 + 1 = 1010
Answer: Two's complement = 1010 (which is -6 in two's complement)

Common mistakes

  • Forgetting to add 1 after flipping the bits. Always add 1 at the end.
  • Not using enough bits. Always use the same number of bits as the original number (like 4 bits, 8 bits, etc.).
  • Mixing up one's complement (just flipping) with two's complement (flipping and adding 1).

Remember it

Flip all the bits, then add one — that's two's complement!

Check yourself

What is the first step to find the two's complement of a binary number?

Flip all the bits (0 becomes 1, 1 becomes 0).

Why do we add 1 after flipping the bits?

Adding 1 completes the process and gives the correct negative value.

Find the two's complement of 0011 (4 bits).

1101 (flip: 1100, add 1: 1101).

What mistake happens if you forget to add 1 after flipping?

You get one's complement, not two's complement, so the value is wrong.

Quick recap

  • Two's complement is used to represent negative numbers in binary.
  • Flip all bits and add 1 to find two's complement.
  • It makes subtraction and negative numbers easy for computers.
  • Always use the same number of bits as the original number.
Written by the LLOS.ai tutor, checked against NCERT chapters. Asked by Anonymous from Bordeaux, France on 23 Oct 2026, 7:26 PM IST