Skip to content

Two's Complement Converter

Convert between signed and unsigned, with the negation steps shown.

Decimal, or prefixed 0x, 0b or 0o.

Interpret as

Quick Tool Overview

The Two’s Complement Converter shows the invert-and-add-one steps rather than just the answer, and shows the same bit pattern read as signed and as unsigned — which is where the real bugs live, because nothing about the bits says which was meant.

What it does
Converts between signed and unsigned binary
You give it
A number and a bit width
You get back
The bits, both readings, and the working
Best for
Learning it, and debugging an overflow
Developer Tools Free, unlimited use No sign-up Runs in your browser

About the Two's Complement Converter

Two's complement is how every modern processor stores a negative integer, and it is much less mysterious once you see the three steps: write the magnitude in binary, invert every bit, add one. This shows those steps for any value at any width.

It also shows the same bit pattern read both ways, which is where real bugs live. The byte 11111011 is 251 if you read it unsigned and −5 if you read it signed; nothing about the bits says which is intended. That is the whole of the C signed/unsigned comparison trap, the reason a file size can come back negative, and why an overflowed value wraps to the far end of the range instead of saturating. The converter flags a value that does not fit in the width you chose and shows what it wraps to.

Key features of the Two's Complement Converter

The three steps shown

Magnitude, inverted, plus one — laid out in binary, which is what makes the algorithm implementable rather than memorised.

Both readings at once

11111011 is 251 unsigned and −5 signed. Seeing both is the whole of the signed/unsigned comparison trap.

Overflow flagged

A value too large for the width is reported, with what it wraps to — so 200 in a signed byte is shown becoming −56.

Four widths

8, 16, 32 and 64 bits, with the range for each so the asymmetry (−128 to 127) is explicit.

Any input base

Decimal, hex, binary or octal, with or without a prefix.

How to use the Two's Complement Converter

  1. 1

    Enter a number

    Positive or negative, in decimal, hex, binary or octal.

  2. 2

    Choose the width

    8, 16, 32 or 64 bits.

  3. 3

    Read the steps

    For a negative number, the magnitude, the inversion and the result.

  4. 4

    Compare both readings

    The same bits as a signed value and as an unsigned one.

Frequently asked questions

Because addition and subtraction work unchanged. The same adder circuit handles negatives with no special case, and there is only one representation of zero — a sign-and-magnitude scheme gives you both +0 and −0.

Reviews of the Two's Complement Converter

What people who use the Two's Complement Converter think of it. Reviews come from visitors and are posted as written.

No ratings yet

Yours would be the first.

  • 5 0 reviews rated 5 stars
  • 4 0 reviews rated 4 stars
  • 3 0 reviews rated 3 stars
  • 2 0 reviews rated 2 stars
  • 1 0 reviews rated 1 star

Write a review

Used this tool? Your rating helps the next person decide.

Your rating

Plain text only — links, email addresses and HTML are not accepted. Your name and review are shown publicly; nothing else is collected. See the privacy policy.

0 reviews

Newest first

No reviews yet

Be the first to rate the Two's Complement Converter. It takes half a minute and no account.

Write the first review

More developer tools