Two’s (2’s) Complement Calculator

Use this Calculator to quickly find the two’s complement value of a decimal, hex, or binary number in the selected bit length.

Two’s Complement:

DEC:

HEX:

OCT:

How to Use the Calculator?

To use the calculator, simply enter your number, choose whether it is decimal, hex, or binary, and then select the bit length you want to use. The calculator will automatically display the two’s complement value. The equivalent values in decimal, hex, and octal will also be shown.

What Is Two’s Complement?

In ordinary decimal numbers, we already know how to show negatives: we simply place a minus sign in front, like $-5$ or $-12$. But computers do not store numbers with a little minus sign the way we do in notebooks. Inside a computer, everything must be represented using only $0$s and $1$s.

So the computer needs a smart system for representing both positive and negative integers using the same kind of binary digits. That system is called two’s complement.

How to Find the Two’s Complement

To find the two’s complement, follow this procedure:

  1. Write the given number in binary using the correct bit width.
  2. Invert every bit by changing zeroes to ones and ones to zero.
  3. Add $1$ to the result.

Suppose we want to find two’s complement of $5$ in 8-bit. First write $5$ in binary:

$$ 5 = 00000101 $$

Now invert all bits:

$$ 00000101 \rightarrow 11111010 $$

Then add $1$:

$$ 11111010 + 1 = 11111011 $$

So $5$’s two’s complement in 8-bit is:

$$ 11111011 = -5$$

Understanding Bit Length

While learning about two’s complement numbers, it is extremely important to understand that the number of bits matters. A 4-bit number and an 8-bit number are not interpreted in the same way, even if some of the digits look similar.

For example, $1111$ in 4-bit two’s complement form means $-1$. But $00001111$ in 8-bit two’s complement form means $15$. Even though both numbers end with the same four digits, they do not represent the same value. This shows why bit length must always be considered when reading signed binary numbers.

This is because, in an ordinary 4-bit unsigned binary number, each bit represents a positive power of two. For example, the decimal number $12$ is written as $1100$ in binary, because:

$$ 1 \cdot 2^3 + 1 \cdot 2^2 + 0 \cdot 2^1 + 0 \cdot 2^0 = 12 $$

In a 4-bit two’s complement number, however, the place values are slightly different. The rightmost three positions still represent $2^0$, $2^1$, and $2^2$, but the leftmost bit represents $-2^3$ instead of $+2^3$. This means that a 4-bit two’s complement number can be interpreted by adding signed place values instead of only positive ones.

So the 4-bit signed binary number $1100$ can be read as:

$$ 1 \cdot (-2^3) + 1 \cdot 2^2 + 0 \cdot 2^1 + 0 \cdot 2^0 = -4 $$

This is why $1100$ does not mean $12$ in 4-bit two’s complement. In this system, it represents $-4$. That is one of the most important ideas in signed binary: the same pattern of bits can represent different values depending on whether the number is unsigned or written in two’s complement form.

The Range of Values in Two’s Complement

Because the leftmost bit is used in a special way, a fixed number of bits can represent only a certain range of signed integers. In an $n$-bit two’s complement system, the smallest number is $-2^{n-1}$ and the largest number is $2^{n-1} – 1$.

$$ \text{Range for } n\text{-bit two’s complement} = -2^{n-1} \text{ to } 2^{n-1}-1 $$

For a 4-bit system, that becomes:

$$ -2^{4-1} \text{ to } 2^{4-1}-1 = -8 \text{ to } 7 $$

So the 4-bit two’s complement numbers represent values from $-8$ to $7$. That gives 16 total values, which matches the 16 possible 4-bit patterns.

For an 8-bit system, the range is from $-128$ to $127$. For a 16-bit system, it is from $-32768$ to $32767$.

This range is not perfectly balanced around zero, because there is one more negative number than positive number. That happens because zero takes up one of the non-negative spots. This detail is normal in two’s complement, and it is one reason why the most negative number behaves a little specially.

Building a 4-Bit Two’s Complement Table

A very useful way to understand the system is to look at all 4-bit combinations and their meanings. In 4-bit two’s complement, the values are arranged like this:

$$\begin{aligned} 0000 &= 0 \\ 0001 &= 1 \\ 0010 &= 2 \\ 0011 &= 3 \\ 0100 &= 4 \\ 0101 &= 5 \\ 0110 &= 6 \\ 0111 &= 7 \end{aligned}$$

Then the pattern continues, but now it wraps into negative numbers:

$$\begin{aligned} 1000 &= -8 \\ 1001 &= -7 \\ 1010 &= -6 \\ 1011 &= -5 \\ 1100 &= -4 \\ 1101 &= -3 \\ 1110 &= -2 \\ 1111 &= -1 \end{aligned}$$

It is worth spending time looking at this pattern. Notice that the positive numbers begin with $0$ and the negative numbers begin with $1$. Also notice that $1111$ means $-1$, not $15$, because we are interpreting the bits as signed 4-bit two’s complement, not unsigned binary. This is why context matters.

If you count upward from $0111$, which is $7$, the next pattern is $1000$, which is not $8$ but $-8$. This is the wraparound effect.

illustration of twos complement as a circular number system

So think of two’s complement as a circular number system. If a binary number gets too large, it wraps around. In an unsigned 4-bit system, the numbers go from $0000 = 0$ up to $1111 = 15$. But in a 4-bit two’s complement system, the same 16 bit patterns are shared between positive and negative values. The system wraps so that some patterns represent negative numbers. This wrapping is one of the key ideas that helps make arithmetic work smoothly.

8-Bit Two’s Complement Table

Here is the full list of 8-bit decimal numbers and their corresponding two’s complement for your quick reference.

DecimalTwo’s ComplementDecimalTwo’s Complement
11111 1111-10000 0001
21111 1110-20000 0010
31111 1101-30000 0011
41111 1100-40000 0100
51111 1011-50000 0101
61111 1010-60000 0110
71111 1001-70000 0111
81111 1000-80000 1000
91111 0111-90000 1001
101111 0110-100000 1010
111111 0101-110000 1011
121111 0100-120000 1100
131111 0011-130000 1101
141111 0010-140000 1110
151111 0001-150000 1111
161111 0000-160001 0000
171110 1111-170001 0001
181110 1110-180001 0010
191110 1101-190001 0011
201110 1100-200001 0100
211110 1011-210001 0101
221110 1010-220001 0110
231110 1001-230001 0111
241110 1000-240001 1000
251110 0111-250001 1001
261110 0110-260001 1010
271110 0101-270001 1011
281110 0100-280001 1100
291110 0011-290001 1101
301110 0010-300001 1110
311110 0001-310001 1111
321110 0000-320010 0000
331101 1111-330010 0001
341101 1110-340010 0010
351101 1101-350010 0011
361101 1100-360010 0100
371101 1011-370010 0101
381101 1010-380010 0110
391101 1001-390010 0111
401101 1000-400010 1000
411101 0111-410010 1001
421101 0110-420010 1010
431101 0101-430010 1011
441101 0100-440010 1100
451101 0011-450010 1101
461101 0010-460010 1110
471101 0001-470010 1111
481101 0000-480011 0000
491100 1111-490011 0001
501100 1110-500011 0010
511100 1101-510011 0011
521100 1100-520011 0100
531100 1011-530011 0101
541100 1010-540011 0110
551100 1001-550011 0111
561100 1000-560011 1000
571100 0111-570011 1001
581100 0110-580011 1010
591100 0101-590011 1011
601100 0100-600011 1100
611100 0011-610011 1101
621100 0010-620011 1110
631100 0001-630011 1111
641100 0000-640100 0000
651011 1111-650100 0001
661011 1110-660100 0010
671011 1101-670100 0011
681011 1100-680100 0100
691011 1011-690100 0101
701011 1010-700100 0110
711011 1001-710100 0111
721011 1000-720100 1000
731011 0111-730100 1001
741011 0110-740100 1010
751011 0101-750100 1011
761011 0100-760100 1100
771011 0011-770100 1101
781011 0010-780100 1110
791011 0001-790100 1111
801011 0000-800101 0000
811010 1111-810101 0001
821010 1110-820101 0010
831010 1101-830101 0011
841010 1100-840101 0100
851010 1011-850101 0101
861010 1010-860101 0110
871010 1001-870101 0111
881010 1000-880101 1000
891010 0111-890101 1001
901010 0110-900101 1010
911010 0101-910101 1011
921010 0100-920101 1100
931010 0011-930101 1101
941010 00100-940101 1110
951010 0001-950101 1111
961010 0000-960110 0000
971001 1111-970110 0001
981001 1110-980110 0010
991001 1101-990110 0011
1001001 1100-1000110 0100
1011001 1011-1010110 0101
1021001 1010-1020110 0110
1031001 1001-1030110 0111
1041001 1000-1040110 1000
1051001 0111-1050110 1001
1061001 0110-1060110 1010
1071001 0101-1070110 1011
1081001 0100-1080110 1100
1091001 0011-1090110 1101
1101001 0010-1100110 1110
1111001 0001-1110110 1111
1121001 0000-1120111 0000
1131000 1111-1130111 0001
1141000 1110-1140111 0010
1151000 1101-1150111 0011
1161000 1100-1160111 0100
1171000 1011-1170111 0101
1181000 1010-1180111 0110
1191000 1001-1190111 0111
1201000 1000-1200111 1000
1211000 0111-1210111 1001
1221000 0110-1220111 1010
1231000 0101-1230111 1011
1241000 0100-1240111 1100
1251000 0011-1250111 1101
1261000 0010-1260111 1110
1271000 0001-1270111 1111
-1281000 0000  
Amrit Prabhu

Amrit Prabhu

Amrit is an Electronics Engineer who loves making complex programming and hardware concepts accessible. He has more than 15 years of experience, having worked as a Senior Programmer Analyst at Mindtree Ltd. and Symantec on major projects like Windows 8, Wolters Kluwer CCH and NSE. Since 2018, he has authored hundreds of tutorials and guides for Last Minute Engineers, helping readers master everything from basic circuits to IoT. You can find him on LinkedIn