We believe math and science education should be free and accessible to everyone. Why education matters >

Two's Complement Calculator

Convert any signed integer to its two's complement binary representation and back. Choose 8-bit, 16-bit, or 32-bit width, and see the binary, hexadecimal, unsigned equivalent, and step-by-step conversion.

Two's complement is the standard method computers use to represent signed integers (positive and negative whole numbers) in binary.

How Two's Complement Works:

  • Positive numbers are stored the same as regular binary, with a leading 0 bit.
  • Negative numbers are stored by inverting all the bits of the absolute value and adding 1.

Example (8-bit):

The number -42:

  1. Start with 42 in binary: 00101010
  2. Invert all bits: 11010101
  3. Add 1: 11010110

So -42 in 8-bit two's complement is 11010110.

Why Two's Complement?

  • There is only one representation of zero (unlike sign-magnitude, which has +0 and -0).
  • Addition and subtraction use the same hardware circuit.
  • The most significant bit (MSB) acts as the sign bit: 0 for positive, 1 for negative.

Ranges:

  • 8-bit: -128 to 127
  • 16-bit: -32,768 to 32,767
  • 32-bit: -2,147,483,648 to 2,147,483,647

Did this solve your problem?

Frequently Asked Questions

Search Calculators

Search across all calculator categories