Math

Two’s Complement Calculator

Convert a decimal number (including negatives) to its two's complement binary form.


Two’s Complement Calculator

Advertisement

The standard method computers use to represent negative integers in binary.

How it works

For a negative number, the binary representation is found by taking the two’s complement — inverting the bits of the positive equivalent and adding 1 — within a chosen bit width.

What this does not include

This does not include unsigned (always-positive) binary conversion — for that plain case, use this site’s binary calculator instead.

How to use this calculator

  1. Enter a decimal value (positive or negative) and choose a bit width.

A worked example

−5 in 8-bit two’s complement: 11111011.

5 in 8-bit two’s complement: 00000101 — a positive number looks identical to plain binary.

What the variables mean

Variable Meaning
Value The signed decimal number being converted
Bits How many bits the binary representation uses

Edge cases worth knowing

Positive numbers in two’s complement look exactly like plain binary — the representation only differs from ordinary binary for negative values, where the leading bit flips to signal a negative sign.

A value outside the representable range for the given bit count has no valid encoding. 8 bits can only represent −128 to 127, so 200 falls outside that range and the calculator declines to show a result.

Frequently asked questions

Why do computers use two’s complement instead of just a sign bit?

Two’s complement lets addition and subtraction use the exact same circuitry for both positive and negative numbers, without special-casing the sign — a major efficiency advantage in hardware design.

Why does bit width matter?

It determines the range of representable values — an 8-bit value can only represent numbers from −128 to 127, while wider bit widths allow a larger range.

What happens if I enter a number outside the representable range?

The calculator declines to show a result, since that number can’t be correctly represented in the chosen bit width without overflow.

Be the first to rate this

Written by

J. Adeyemi

Statistics writer

J. Adeyemi writes the statistics and probability calculators, from descriptive summaries through to distributions and conditional probability. The recurring theme is scope: each page states precisely which question it answers, because most statistical mistakes come from applying a correct formula to the wrong question. Related-but-different measures get separate pages rather than being quietly merged.

Reviewed by

T. Okafor

Calculator reviewer — mathematics

T. Okafor reviews the mathematics calculators, verifying algebraic correctness and, just as importantly, behaviour at the edges — division by zero, undefined results, and the floating-point cases where a formula technically returns a number that should be reported as undefined. Every test case is recomputed independently rather than taken on trust.

How we write and review

Related calculators