BinaryCon Binary Converter

2s Complement Calculator - Binary Two's Complement Online

Result

Binary 2's Complement Calculator

The Binary 2's Complement Calculator instantly computes the two's complement of any binary number. This free online tool is essential for computer science students, digital electronics engineers, assembly language programmers, and anyone working with signed binary number representations.

Two's complement is the standard method used by modern computers to represent signed (positive and negative) integers in binary. It simplifies arithmetic operations and eliminates the need for separate circuits to handle negative numbers.

Examples

4-bit: 1011 → 2's complement = 0101 (represents -5)
8-bit: 11110011 → 2's complement = 00001101 (represents -13)
4-bit: 0101 → 2's complement = 1011 (represents -5)

Definition

Two's complement is a binary encoding for signed integers in which the most significant bit (MSB) has a negative positional value, allowing both positive and negative numbers to be represented and used in arithmetic operations.

What is Two's Complement?

Two's complement is the most widely used method of representing signed integers in binary. In an N-bit two's complement system, positive numbers are represented identically to unsigned binary, while negative numbers are represented by inverting all bits (1's complement) and adding 1 to the result.

How to Calculate Two's Complement

  1. Write the binary number.
  2. Invert all bits (0 becomes 1, 1 becomes 0) — this gives the 1's complement.
  3. Add 1 to the 1's complement result.
  4. The result is the two's complement.

Two's Complement Formula

Two's Complement = 1's Complement + 1

OR equivalently:

Two's Complement = (2^N) - Value

where N is the number of bits

Example

Binary = 1011 (4-bit)

Step 1: Original  → 1011
Step 2: Invert    → 0100  (1's complement)
Step 3: Add 1     → 0101  (2's complement)

Value represented = -5

Two's Complement Conversion Table

4-bit Binary Unsigned Decimal Signed Decimal (2's comp)
000000
00011+1
01117+7
10008-8
10019-7
101010-6
101111-5
110012-4
110113-3
111014-2
111115-1

Applications of Two's Complement

  • Signed Integer Representation in CPUs
  • Assembly Language and Machine Code
  • ALU (Arithmetic Logic Unit) Design
  • Computer Architecture and Processor Design
  • Embedded Systems Programming
  • Fixed-Point Arithmetic
  • Digital Signal Processing (DSP)
  • Computer Science and Programming Education

Programming Examples

Python

# Two's complement of 1011 in 4 bits
n = 0b1011
bits = 4
twos = (~n & (2**bits - 1)) + 1
bin(twos)

Output

'0b101'  (i.e., 0101)
C

// Signed int automatically uses 2's complement
int x = -5;
printf("%d", x);

Frequently Asked Questions

What is a two's complement?

Two's complement is the standard binary representation for signed integers. It is computed by inverting all bits of a binary number and then adding 1 to the result.

How do I convert binary to two's complement?

Invert all bits of the binary number to get the 1's complement, then add 1. The result is the two's complement representation.

What is the two's complement of 1011?

The 1's complement of 1011 is 0100. Adding 1 gives 0101, which represents -5 in a 4-bit signed system.

Why do computers use two's complement?

Two's complement simplifies hardware design because addition and subtraction work the same way for both positive and negative numbers, eliminating the need for special subtraction circuits.

What is the range of an 8-bit two's complement number?

An 8-bit two's complement number can represent values from -128 to +127.

Is this Binary 2's Complement Calculator free?

Yes. This online Binary 2's Complement Calculator is completely free to use and works directly in your browser without any installation or registration.