AI & Computing

Two's Complement Calculator (Signed Binary)

Convert a signed number to two’s complement, or read a bit pattern as signed and unsigned.

Your numbers

Your results

Binary (two's complement)
Binary (two's complement)
—
Hexadecimal
—
Signed value
—
Unsigned value
—
Range for this width
—

Two's Complement Calculator (Signed Binary) by TheCalcTools

How the Two's Complement Calculator (Signed Binary) works

Two’s complement stores negative numbers as 2^width minus the magnitude, so the top bit acts as a sign. −42 in 8 bits is 256 − 42 = 214 = 11010110.

To negate a number by hand, flip all bits and add 1. The binary and hex shown include a leading 1 that marks the width; read the digits after it.

The formula

Pattern = value mod 2^width; signed = pattern − 2^width if the top bit is 1

Worked example

Using the default values shown in the calculator:

ConvertSigned decimal to two’s complement
Signed decimal-42
Binary pattern11010110
Width8-bit
  1. −42 in 8 bits is unsigned 214; with a marker bit the pattern is 111010110.

Result:

Binary (two's complement)111010110
Hexadecimal1D6
Signed value-42
Unsigned value214
Range for this width-128 to 127

Frequently asked questions

Why two's complement?

Addition and subtraction work the same for signed and unsigned numbers, and there is only one zero.

Sources and further reading

More in AI & Computing · All calculators

This calculator gives estimates for information only. Check important results independently before you rely on them. See our disclaimer.