2's Complement Calculator — Binary Conversion & Signed Arithmetic Made Easy

Free online 2's complement calculator for decimal-to-binary conversion, signed integer representation, addition, and subtraction. Supports 4-bit to 32-bit with step-by-step breakdowns and overflow detection.

Verified Formula Instant Results Privacy First

2's Complement Calculator

Convert between decimal and 2's complement binary, or perform signed binary addition and subtraction.

Range: -128 to 127
Select a mode, enter values, and click Calculate to see the result.

2's Complement Formula Explained

The 2's complement is the most common method for representing signed integers in binary. It allows both positive and negative numbers to be stored and manipulated using the same hardware circuits.

For a positive number: 2's complement = standard binary representation
For a negative number: 2's complement = (bitwise NOT of |N|) + 1
Alternative: 2's complement of N = 2n − |N| (for n-bit representation)

Key Concepts

  • Sign Bit (MSB): The leftmost bit indicates the sign — 0 for positive, 1 for negative.
  • Bit Inversion (1's Complement): Flip every bit (0→1, 1→0) of the positive binary magnitude.
  • Add 1: After inversion, add 1 to the least significant bit to obtain the final 2's complement.
  • Unique Zero: Unlike 1's complement, 2's complement has only one representation for zero (all bits 0).

How to Calculate 2's Complement

Follow these steps to find the 2's complement of any integer for a given bit width:

  1. Determine the bit width — Choose 4, 8, 16, or 32 bits based on the range needed.
  2. Convert the absolute value to binary — Write the magnitude in base-2, padded with leading zeros to fill the bit width.
  3. If the number is positive — You're done. The padded binary is the 2's complement representation.
  4. If the number is negative — Invert all bits (flip 0→1 and 1→0) to get the 1's complement.
  5. Add 1 — Perform binary addition of 1 to the inverted result. The final binary string is the 2's complement.

For example, to represent -5 in 8-bit 2's complement: |−5| = 5 = 00000101 → invert → 11111010 → add 1 → 11111011.

2's Complement Calculator Examples

Example 1: Positive Decimal to 8-bit 2's Complement

Convert +42 to 8-bit 2's complement.

42 in binary = 00101010
Since positive, result = 00101010

Example 2: Negative Decimal to 8-bit 2's Complement

Convert -13 to 8-bit 2's complement.

|−13| = 13 = 00001101
Invert: 11110010
Add 1: 11110010 + 1 = 11110011

Example 3: 2's Complement Binary to Decimal

Decode 11111011 (8-bit) to decimal.

MSB = 1 → negative number
Invert: 00000100
Add 1: 00000101 = 5
Result: -5

Example 4: 2's Complement Addition

Add 3 (00000011) and -2 (11111110) in 8-bit.

00000011 + 11111110 = 00000001 (carry discarded)
Result: 00000001 = 1

Real-World 2's Complement Applications

  • Computer Architecture: Nearly all modern CPUs use 2's complement for signed integer arithmetic in their ALU (Arithmetic Logic Unit).
  • Embedded Systems: Microcontrollers and firmware rely on 2's complement for efficient signed operations with minimal circuitry.
  • Digital Signal Processing: Audio, image, and sensor data processing use 2's complement fixed-point representation.
  • Compiler Design: Programming languages like C, C++, Java, and Rust use 2's complement as the standard signed integer format.
  • Network Protocols: TCP/IP checksums and data encoding often leverage 2's complement arithmetic.
  • Cryptography: Modular arithmetic in encryption algorithms uses 2's complement for handling negative residues.

People Also Ask

2's complement is a method for representing signed integers in binary where positive numbers use standard binary and negative numbers are formed by inverting all bits of the positive magnitude and adding 1. It eliminates the double-zero problem and simplifies arithmetic circuit design.
To find the 2's complement: (1) Invert every bit of the original binary number (0→1, 1→0). (2) Add 1 to the resulting binary using standard binary addition rules. For example, the 2's complement of 0101 is 1010+1 = 1011.
2's complement is superior because: (1) It has a unique zero representation (all zeros), avoiding the +0/-0 ambiguity of 1's complement. (2) Addition and subtraction use identical hardware. (3) It provides one extra negative value in the representable range. (4) Overflow detection is simpler.
An 8-bit 2's complement integer ranges from -128 (10000000) to +127 (01111111). Zero is 00000000. In general, an n-bit 2's complement number spans from -2^(n-1) to 2^(n-1)-1, giving 2^n total distinct values.
Overflow occurs when the result exceeds the representable range. The rule: if two numbers with the same sign are added and the result has the opposite sign, overflow has occurred. Equivalently, overflow happens when the carry into the sign bit differs from the carry out of the sign bit.

Frequently Asked Questions

1's complement inverts all bits (0↔1) without adding 1. It has two zeros (+0=0000, -0=1111). 2's complement adds 1 after inversion, yielding a single zero and one extra negative value. Modern computers exclusively use 2's complement.
Yes. Use the Bit Width dropdown to select 4-bit, 8-bit, 16-bit, or 32-bit representation. The range updates automatically. 16-bit covers -32,768 to 32,767, and 32-bit covers approximately -2.1 billion to +2.1 billion.
Subtraction in 2's complement is performed by taking the 2's complement of the subtrahend (B) and adding it to the minuend (A): A - B = A + (-B). This allows a single addition circuit to handle both operations, which is why 2's complement is so efficient in hardware.
The calculator will display an error indicating the number is out of range for the selected bit width. For example, -129 cannot be represented in 8-bit 2's complement (range: -128 to 127). Select a larger bit width to accommodate wider ranges.
Yes. The addition mode handles any combination of positive and negative binary strings. The calculator detects overflow when the sum of two negatives produces a positive result (or vice versa), which indicates the result exceeds the bit-width range.
Zero in 2's complement is always all zeros (e.g., 00000000 for 8-bit). Inverting all zeros gives all ones (11111111), and adding 1 wraps back to 00000000 (carry discarded). This unique zero representation is a key advantage of 2's complement.

2's Complement Glossary

2's Complement

A signed binary representation where negative values are the bitwise inversion of the positive magnitude plus 1.

Sign Bit (MSB)

The most significant bit indicating sign: 0 for positive/zero, 1 for negative numbers.

1's Complement

The bitwise NOT of a binary number, where all bits are flipped. Used as an intermediate step in 2's complement calculation.

Bit Inversion

Flipping every bit: 0 becomes 1, 1 becomes 0. Also called the bitwise complement or NOT operation.

Overflow

A condition where an arithmetic result exceeds the representable range for the given bit width, producing an incorrect wrapped value.

Signed Integer

An integer data type that can represent both positive and negative values, using the sign bit to distinguish them.

Bit Width

The number of bits used to represent a number, determining the range of representable values (e.g., 8-bit, 16-bit, 32-bit).

Carry Bit

A bit that is carried over to the next higher position during binary addition when two 1s are summed.

Arithmetic Logic Unit

The digital circuit within a CPU that performs arithmetic and logical operations, built around 2's complement arithmetic.

End-Around Carry

In 1's complement addition, the final carry-out is added back to the least significant bit. Not needed in 2's complement.

Editorial Review & Methodology

This 2's complement calculator was built and reviewed by the NumbrWiz Editorial Team. The 2's complement method is the universal standard for signed integer representation in modern computing, verified against IEEE standards, computer architecture textbooks, and CPU design documentation.

  • Formula verification: Cross-checked against authoritative sources including Hennessy & Patterson's computer architecture references and ISO C standards for signed integer representation.
  • Edge case testing: Tested with boundary values (most negative, zero, most positive), overflow scenarios, and various bit widths from 4 to 32 bits.
  • Overflow detection: Implemented standard sign-bit comparison method used in real ALU designs.

Transparency note: All calculations run client-side in your browser. No data is ever collected, stored, or transmitted. Results are for educational purposes; verify critical calculations independently.

Page last reviewed: May 2026 · NumbrWiz Editorial Team