calculatorplustools.com

2's Complement Calculator

Convert signed decimal integers to binary using 2's complement representation.

Input Value

Conversion Result

Enter a number to see the binary representation.

How to Use This Converter

  1. Select Mode: Choose whether you are converting from Decimal to Binary or Binary to Decimal.
  2. Enter Value: Type your number. For decimal, you can use negative numbers (e.g., -42).
  3. Choose Bit Length: Select the bit width (e.g., 8-bit, 16-bit) to ensure accurate overflow detection.
  4. Convert: Click the button to see the result and the step-by-step math behind it.

What is 2's Complement?

Two's complement is the standard way computers represent signed integers (positive and negative numbers). It solves the problem of having two zeros (+0 and -0) that existed in older systems and makes arithmetic operations like addition and subtraction much simpler for hardware.

How to Calculate it Manually

To convert a negative decimal number (e.g., -5) to binary:

  1. Step 1: Write the positive version of the number in binary.
    5 = 0000 0101
  2. Step 2: Invert all the bits (change 0s to 1s and 1s to 0s). This is called the "1's Complement".
    1111 1010
  3. Step 3: Add 1 to the result.
    1111 1010 + 1 = 1111 1011

Bit Ranges Table

The range of numbers you can store depends on the number of bits you use. In 2's complement, the most significant bit (leftmost) is the sign bit (0=positive, 1=negative).

Bits Name Min Value Max Value
4 Nibble -8 7
8 Byte -128 127
16 Short -32,768 32,767
32 Integer -2,147,483,648 2,147,483,647

More Math Tools

Need more conversions? Try our Binary Calculator or browse all Math Tools.