Two's Complement Calculator

Calculate two's complement for binary numbers. Essential for understanding negative number representation in computer systems.

Enter binary number (0 and 1 only)
Select the number of bits for representation

Two's Complement Result:

Original: 0101 = 5
Two's Complement: 1011 = -5

Step-by-Step Calculation:

1

Original binary number:

0101
2

Invert all bits (one's complement):

1010
3

Add 1 to the inverted number:

1010 + 1 = 1011

Understanding Two's Complement

What is Two's Complement?

Two's complement is a mathematical operation on binary numbers and the most common method of representing signed integers in computers. It solves the problem of negative number representation in binary systems.

Calculation Method

1

Invert Bits
Change all 0s to 1s and all 1s to 0s

2

Add 1
Add 1 to the inverted number using binary addition

3

Result
The final number is the two's complement

Number Range in Two's Complement

Bit Length Minimum Maximum Range
4 bits -8 7 16 numbers
8 bits -128 127 256 numbers
16 bits -32,768 32,767 65,536 numbers
32 bits -2,147,483,648 2,147,483,647 4,294,967,296 numbers

Advantages of Two's Complement

Single Zero Representation

Only one representation for zero (000...0)

🔢
Simple Arithmetic

Same circuit for addition and subtraction

Efficient Hardware

No special cases for negative numbers

Common Examples

4-bit: 0101 (+5)

0101 → 1010 → 1011

+5 → -5

8-bit: 00000101 (+5)

00000101 → 11111010 → 11111011

+5 → -5

4-bit: 1000 (-8)

1000 → 0111 → 1000

-8 → +8 → -8 (same)

🛠️ Free Smart Tools

English English