DIGITAL · TOOL

Sign-Magnitude / One's / Two's Complement Converter

The three codes of a signed integer — sign-magnitude, one's complement, two's complement at a glance.

Basic No backend · 100% client-side

What it does: Convert a signed integer into sign-magnitude, one's complement, and two's complement (at a chosen bit width).

When to use it: When learning computer organization, debugging signed numbers, or reading negative values in registers.

→ two's complement 11111011
Next

You might also need

How to

How to use the sign-magnitude / complement converter

Enter an integer, pick the bit width.

  1. 01

    Enter an integer

    Positive or negative, e.g. -5, 127.

  2. 02

    Pick the bit width

    8 / 16 / 32 bits are common. It sets the representable range.

  3. 03

    Read the three codes

    Get sign-magnitude, one's complement, and two's complement at once (plus the two's-complement hex).

Reference

Three-code definitions

All three are identical for positive numbers; they only differ for negative numbers.

CodePositiveNegative
Sign-magnitudesign bit 0 + magnitudesign bit 1 + magnitude
One's complementsame as sign-magnitudesign bit unchanged, magnitude bits inverted
Two's complementsame as sign-magnitudeone's complement + 1 (= 2ⁿ + value)

Standard definitions from computer organization.

FAQ

Common questions, answered in 3 minutes

Why do computers use two's complement?

Two's complement unifies addition and subtraction into addition and has only one zero (sign-magnitude / one's complement have +0 and −0), so the hardware is simplest — that's why CPUs store signed integers in two's complement.

Why doesn't −128 have a sign-magnitude / one's complement form?

8-bit sign-magnitude / one's complement range is −127 to +127 (one bit is reserved for the sign), while two's complement can represent one extra value, −128. So −128 only has the two's complement 10000000; sign-magnitude / one's complement would need 9 bits.

How do I find a two's complement quickly?

For a negative number: invert all bits then add 1, or "find the first 1 from the right and invert everything to its left." This tool gives the result directly.

What happens if I pick the wrong bit width?

Too few bits causes an overflow error (e.g. 8 bits can't hold 200). Choose 8/16/32 to fit the value range.

Data Provenance

Standards and sources referenced by this tool

Item Value / Formula Source
Sign-magnitude / one's / two's complement sign-magnitude / one's complement / two's complement computer organization

Per standard computer-organization definitions, no external API.

⚡ Powered by Circflow