Discover
Random

Two's Complement Calculator

Convert signed integers to two's complement binary, step by step.

Free Two's Complement Calculator

Our free two's complement calculator converts any signed decimal integer into its two's complement binary representation for a chosen bit width — 4, 8, 16, or 32 bits — and shows every step: writing the magnitude in binary, inverting the bits, and adding 1. It also works in reverse, decoding a two's complement binary string back to its signed decimal value.

Two's complement is the standard way computers represent negative integers, because it lets addition and subtraction use the same circuitry for both positive and negative numbers. The calculator flags overflow when a value falls outside the representable range for the selected bit width, so you can see exactly why a number wraps around.

Built for computer science students learning number representation, and for anyone debugging low-level code who needs a quick, reliable conversion. No sign-up, no downloads — just instant, accurate results.

About the Two's Complement Calculator

How It Works & Methodology

The Two's Complement Calculator converts a signed decimal integer into its two's complement binary representation for a chosen bit width, and vice versa, showing every intermediate step: writing the magnitude in binary, inverting the bits, and adding 1.

Features

Two-way conversion

Decimal to binary and binary to decimal, in the same tool.

Step-by-step working

See the magnitude, inversion, and add-1 steps laid out clearly.

Selectable bit width

4, 8, 16, or 32-bit representations.

Overflow detection

Flags values outside the representable range for the chosen width.

Mathematical Basis & Practical Verification

The Two's Complement Calculator is built on discrete mathematics, computer architecture, and algorithm analysis standards (including IEEE 754 floating-point rules, two's complement bit-width modular arithmetic, and asymptotic recurrence relations). Free two's complement calculator that converts signed decimal integers to two's complement binary and back, with step-by-step working. The interface validates every input parameter in real time and surfaces intermediate steps alongside the final result.

All computations for the Two's Complement Calculator follow the definitions established in IEEE Standard for Floating-Point Arithmetic (IEEE 754-2019) (IEEE Computer Society) and Dictionary of Algorithms and Data Structures (DADS) (National Institute of Standards and Technology (NIST)). Because the solver evaluates inputs locally in IEEE 754 double-precision arithmetic (53-bit significand, ~15–17 significant decimal digits) and is regression-tested against deterministic reference fixtures in tests/twos-complement.spec.ts, you can inspect boundary conditions, verify dimensional consistency across computer science units, and cross-check each intermediate step against textbook solutions.

Authoritative Sources & Standards

  1. IEEE Standard for Floating-Point Arithmetic (IEEE 754-2019) — IEEE Computer Society
  2. Dictionary of Algorithms and Data Structures (DADS) — National Institute of Standards and Technology (NIST)

Frequently Asked Questions

What is two's complement?

A method of representing signed integers in binary where negative numbers are formed by inverting the bits of the positive value and adding 1.

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

Because it lets the same binary addition circuitry work for both positive and negative numbers, with no separate subtraction logic needed.

How do I convert a negative decimal to two's complement?

Write the magnitude in binary, invert every bit, then add 1. The calculator shows each of these steps.

What bit widths are supported?

4-bit, 8-bit, 16-bit, and 32-bit.

What happens if my number is out of range?

The calculator shows an overflow message with the valid range for the selected bit width, e.g. -128 to 127 for 8-bit.

How is the sign determined in two's complement?

The leftmost (most significant) bit: 0 means non-negative, 1 means negative.

Can I convert binary back to decimal?

Yes, switch to Binary → Decimal mode and enter a two's complement bit string.

What is the range for an 8-bit signed number?

-128 to 127.

Embed Two's Complement Calculator

Copy and paste this HTML snippet to embed this interactive calculator on your website or blog:

Discover more tools

Surprise me