Skip to main content
math

Two's Complement Calculator

Convert between signed integers and their two's complement binary representation. Supports 8, 16, and 32-bit widths.

Reviewed by Chase FloiedUpdated

This free online two's complement calculator provides instant results with no signup required. All calculations run directly in your browser — your data is never sent to a server. Enter your values below and see results update in real time as you type. Perfect for everyday calculations, homework, or professional use.

How to Use This Calculator

1

Enter your input values

Fill in all required input fields for the Two's Complement Calculator. Most fields include unit selectors so you can work in your preferred unit system — metric or imperial, whichever matches your problem.

2

Review your inputs

Double-check that all values are correct and that you have selected the right units for each field. Incorrect units are the most common source of calculation errors and can produce results that are off by factors of 2, 10, or more.

3

Read the results

The Two's Complement Calculator instantly computes the output and displays results with units clearly labeled. All calculations happen in your browser — no loading time and no data sent to a server.

4

Explore parameter sensitivity

Try adjusting individual input values to see how the output changes. This is a quick and effective way to develop intuition about how different parameters influence the result and to identify which inputs have the largest effect.

Formula Reference

Two's Complement Calculator Formula

See calculator inputs for the governing equation

Variables: All variables and their units are labeled in the calculator interface above. Input fields accept values in multiple unit systems — select your preferred unit from the dropdown next to each field.

When to Use This Calculator

  • Use the Two's Complement Calculator when you need a quick mathematical result without writing out all the steps manually, saving time on repetitive calculations.
  • Use it to verify hand calculations on tests or assignments and catch arithmetic mistakes.
  • Use it when teaching or explaining mathematical concepts to others, demonstrating how changing inputs affects the result.
  • Use it to explore the behavior of mathematical functions across a range of inputs.

About This Calculator

The Two's Complement Calculator is a free mathematical calculation tool for students, educators, and professionals who need quick, reliable results. Convert between signed integers and their two's complement binary representation. Supports 8, 16, and 32-bit widths. The underlying algorithms implement well-established mathematical formulas and numerical methods. Results are computed instantly in the browser. This tool is useful for learning, verification of hand calculations, and rapid exploration of mathematical relationships. All computation happens locally — no data is sent to a server.

About Two's Complement Calculator

Two's complement is the standard way computers represent signed integers. In this system, positive numbers are stored normally in binary, while negative numbers are represented by inverting all bits and adding 1. The key advantage is that addition and subtraction use the same hardware circuit regardless of sign — the processor does not need separate logic for signed arithmetic. The most significant bit (MSB) serves as the sign bit: 0 for positive, 1 for negative. For n bits, the range is −2^(n−1) to 2^(n−1)−1. For example, 8-bit two's complement represents −128 to 127. This calculator converts any signed integer to its two's complement representation at your chosen bit width.

The Math Behind It

Two's complement of a negative number −n in w bits is 2^w − n. Shortcut: invert all bits (one's complement) and add 1. Properties: there is one representation of zero (all 0s), the MSB is the sign bit, and the most negative number (−2^(w−1), e.g., −128 for 8 bits) has no positive counterpart. Addition: A + B mod 2^w gives the correct signed result if no overflow. Overflow detection: if adding two positives gives negative, or two negatives gives positive, overflow occurred. Sign extension: to convert to a wider representation, replicate the MSB. Negation: −x = ~x + 1. This scheme was chosen over sign-magnitude and one's complement because it has a unique zero and simplifies adder design.

Formula Reference

Two's Complement (negative)

−n → 2^w − n (for w-bit representation)

Variables: w = bit width, n = absolute value

Two's Complement (shortcut)

Invert all bits of |n|, then add 1

Variables: Equivalent to 2^w − n

Range

−2^(w−1) to 2^(w−1) − 1

Variables: 8-bit: −128 to 127

Worked Examples

Example 1: Find 8-bit Two's Complement of −42

Represent −42 in 8-bit two's complement.

Step 1:42 in binary = 00101010
Step 2:Invert all bits: 11010101
Step 3:Add 1: 11010101 + 1 = 11010110

−42 in 8-bit two's complement = 11010110₂ = D6₁₆

Common Mistakes & Tips

  • !Forgetting to add 1 after inverting — one's complement is NOT two's complement.
  • !Not specifying bit width — −1 is 11111111 in 8 bits but 1111111111111111 in 16 bits.
  • !Confusing sign-magnitude with two's complement representation.
  • !Not checking for overflow when the result exceeds the representable range.

Related Concepts

Used in These Calculators

Calculators that build on or apply the concepts from this page:

Frequently Asked Questions

Why is two's complement preferred over sign-magnitude?

Two's complement has only one representation of zero (sign-magnitude has +0 and −0), and addition works the same for positive and negative numbers, simplifying hardware.

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

From −2^(n−1) to 2^(n−1) − 1. For 8 bits: −128 to 127. For 16 bits: −32768 to 32767. For 32 bits: −2,147,483,648 to 2,147,483,647.