Two's Complement Calculator
Here is the two's complement calculator (or 2's complement calculator), a fantastic tool that helps you find the opposite of any binary number and turn this two's complement to a decimal value. You have an opportunity to learn what the two's complement representation is and how to work with negative numbers in binary systems. In the text, you can also find how this two's complement converter works or how to turn any signed binary to decimal by hand.
🔎 If you only need to convert decimal to binary or vice versa, check Omni's binary converter!
How to work with negative numbers in binary? – 2's complement representation
In the binary system, all numbers are a combination of two digits, or . Each digit corresponds to a successive power of 2, starting on the right.
For example, in binary is , as (using scientific notation). The hexadecimal system is an extended version of the binary system(which uses base 16 instead of base 2). The latter is frequently used in many computer software and systems. If you want to read more, head to our decimal to hexadecimal converter.
Learning about binary leads to many natural questions: What about negative numbers in the binary system? Or how do I subtract binary numbers? As we can only use to show that something is present or to mean that there is a lack of that thing, there are two main approaches:
-
Two's complement representation, or, in other words, signed notation – the first bit tells about the sign. The convention is that a number with a leading is negative, while a leading denotes a positive value. In an 8-bit representation, we can write any number from -128 to 127. The name comes from the fact that a negative number is a two's complement of a positive one.
-
Unsigned notation – a representation that supports only positive values. Its advantage over the signed one is that, within the same 8-bit system, we can get any number from 0 up to 255.
The unsigned notation is good enough if we need to add or multiply positive numbers. But, usually, the more practical solution is to work with negative numbers as well. A useful thing about the 2's complement representation is that subtraction is equivalent to an addition of a negative number, which we can handle.
How to use two's complement calculator? Two's complement converter in practice
Whenever you want to convert a decimal number into a binary value in two's complement representation, follow these steps:
-
Choose the number of bits in your notation. The higher value, the broader range of numbers you can input.
-
Write any whole decimal within the range that appears under the
Decimal to binary
section. -
… and that's it – the 2's complement calculator will do the rest of the work! It shows the equivalent binary number and its two's complement.
Do you want to estimate the outcome by hand? This is how two's complement calculator does it:
-
Choose the number of bits in the binaries representation. Let's assume we want values in the 8-bit system.
-
Write down your number, let's say 16. 16 in binary is .
-
Add some leading 's so that the number has eight digits, . That's 16 in the two's complement notation.
And what about its counterpart, ?
-
Switch all the digits to their opposite ( and ). In our case, .
-
Add 1 to this value, .
-
in the two's complement representation is in decimal notation and is the 2's complement of .
Look, as long as you are proficient in switching digits and adding unity to a binary value, evaluating negative numbers in binary is not a big deal!
🔎 In case of adding binary numbers, you may find our binary addition calculator helpful.
Turning two's complement to decimal
Our 2's complement calculator can also work the other way around – converting any two's complement to its decimal value. Let's try to convert , a signed binary, to decimal. Two useful methods help you find the outcome:
Method 1
Convert this signed binary into a decimal, like normal, but multiply the leading digit by instead of . Starting from the right:
Method 2
We can see that the first digit is , so our number is negative. First, find its two's complement, then convert the value to a decimal, and come back to the original value:
- Reverse digits, .
- Add a unity, .
- Convert to a decimal (starting from the right),
- .
- As is the absolute value of our initial (negative) binary, add a minus sign in front of it.
- is in two's complement binary notation.
Signed binary to decimal table
If you want to find any whole number in the two's complement eight-bit representation, you may find this table handy. You can see both the value and its two's complement in the same row.
If you are interested in working with the values of a different number of bits, just use our two's complement calculator to save yourself time and effort!
Decimal | Binary | Decimal | Binary |
---|---|---|---|
0 | 0000 0000 | ||
1 | 0000 0001 | -1 | 1111 1111 |
2 | 0000 0010 | -2 | 1111 1110 |
3 | 0000 0011 | -3 | 1111 1101 |
4 | 0000 0100 | -4 | 1111 1100 |
5 | 0000 0101 | -5 | 1111 1011 |
6 | 0000 0110 | -6 | 1111 1010 |
7 | 0000 0111 | -7 | 1111 1001 |
8 | 0000 1000 | -8 | 1111 1000 |
9 | 0000 1001 | -9 | 1111 0111 |
10 | 0000 1010 | -10 | 1111 0110 |
11 | 0000 1011 | -11 | 1111 0101 |
12 | 0000 1100 | -12 | 1111 0100 |
13 | 0000 1101 | -13 | 1111 0011 |
14 | 0000 1110 | -14 | 1111 0010 |
15 | 0000 1111 | -15 | 1111 0001 |
16 | 0001 0000 | -16 | 1111 0000 |
17 | 0001 0001 | -17 | 1110 1111 |
18 | 0001 0010 | -18 | 1110 1110 |
19 | 0001 0011 | -19 | 1110 1101 |
20 | 0001 0100 | -20 | 1110 1100 |
21 | 0001 0101 | -21 | 1110 1011 |
22 | 0001 0110 | -22 | 1110 1010 |
23 | 0001 0111 | -23 | 1110 1001 |
24 | 0001 1000 | -24 | 1110 1000 |
25 | 0001 1001 | -25 | 1110 0111 |
26 | 0001 1010 | -26 | 1110 0110 |
27 | 0001 1011 | -27 | 1110 0101 |
28 | 0001 1100 | -28 | 1110 0100 |
29 | 0001 1101 | -29 | 1110 0011 |
30 | 0001 1110 | -30 | 1110 0010 |
31 | 0001 1111 | -31 | 1110 0001 |
32 | 0010 0000 | -32 | 1110 0000 |
33 | 0010 0001 | -33 | 1101 1111 |
34 | 0010 0010 | -34 | 1101 1110 |
35 | 0010 0011 | -35 | 1101 1101 |
36 | 0010 0100 | -36 | 1101 1100 |
37 | 0010 0101 | -37 | 1101 1011 |
38 | 0010 0110 | -38 | 1101 1010 |
39 | 0010 0111 | -39 | 1101 1001 |
40 | 0010 1000 | -40 | 1101 1000 |
41 | 0010 1001 | -41 | 1101 0111 |
42 | 0010 1010 | -42 | 1101 0110 |
43 | 0010 1011 | -43 | 1101 0101 |
44 | 0010 1100 | -44 | 1101 0100 |
45 | 0010 1101 | -45 | 1101 0011 |
46 | 0010 1110 | -46 | 1101 0010 |
47 | 0010 1111 | -47 | 1101 0001 |
48 | 0011 0000 | -48 | 1101 0000 |
49 | 0011 0001 | -49 | 1100 1111 |
50 | 0011 0010 | -50 | 1100 1110 |
51 | 0011 0011 | -51 | 1100 1101 |
52 | 0011 0100 | -52 | 1100 1100 |
53 | 0011 0101 | -53 | 1100 1011 |
54 | 0011 0110 | -54 | 1100 1010 |
55 | 0011 0111 | -55 | 1100 1001 |
56 | 0011 1000 | -56 | 1100 1000 |
57 | 0011 1001 | -57 | 1100 0111 |
58 | 0011 1010 | -58 | 1100 0110 |
59 | 0011 1011 | -59 | 1100 0101 |
60 | 0011 1100 | -60 | 1100 0100 |
61 | 0011 1101 | -61 | 1100 0011 |
62 | 0011 1110 | -62 | 1100 0010 |
63 | 0011 1111 | -63 | 1100 0001 |
64 | 0100 0000 | -64 | 1100 0000 |
65 | 0100 0001 | -65 | 1011 1111 |
66 | 0100 0010 | -66 | 1011 1110 |
67 | 0100 0011 | -67 | 1011 1101 |
68 | 0100 0100 | -68 | 1011 1100 |
69 | 0100 0101 | -69 | 1011 1011 |
70 | 0100 0110 | -70 | 1011 1010 |
71 | 0100 0111 | -71 | 1011 1001 |
72 | 0100 1000 | -72 | 1011 1000 |
73 | 0100 1001 | -73 | 1011 0111 |
74 | 0100 1010 | -74 | 1011 0110 |
75 | 0100 1011 | -75 | 1011 0101 |
76 | 0100 1100 | -76 | 1011 0100 |
77 | 0100 1101 | -77 | 1011 0011 |
78 | 0100 1110 | -78 | 1011 0010 |
79 | 0100 1111 | -79 | 1011 0001 |
80 | 0101 0000 | -80 | 1011 0000 |
81 | 0101 0001 | -81 | 1010 1111 |
82 | 0101 0010 | -82 | 1010 1110 |
83 | 0101 0011 | -83 | 1010 1101 |
84 | 0101 0100 | -84 | 1010 1100 |
85 | 0101 0101 | -85 | 1010 1011 |
86 | 0101 0110 | -86 | 1010 1010 |
87 | 0101 0111 | -87 | 1010 1001 |
88 | 0101 1000 | -88 | 1010 1000 |
89 | 0101 1001 | -89 | 1010 0111 |
90 | 0101 1010 | -90 | 1010 0110 |
91 | 0101 1011 | -91 | 1010 0101 |
92 | 0101 1100 | -92 | 1010 0100 |
93 | 0101 1101 | -93 | 1010 0011 |
94 | 0101 1110 | -94 | 1010 0010 |
95 | 0101 1111 | -95 | 1010 0001 |
96 | 0110 0000 | -96 | 1010 0000 |
97 | 0110 0001 | -97 | 1001 1111 |
98 | 0110 0010 | -98 | 1001 1110 |
99 | 0110 0011 | -99 | 1001 1101 |
100 | 0110 0100 | -100 | 1001 1100 |
101 | 0110 0101 | -101 | 1001 1011 |
102 | 0110 0110 | -102 | 1001 1010 |
103 | 0110 0111 | -103 | 1001 1001 |
104 | 0110 1000 | -104 | 1001 1000 |
105 | 0110 1001 | -105 | 1001 0111 |
106 | 0110 1010 | -106 | 1001 0110 |
107 | 0110 1011 | -107 | 1001 0101 |
108 | 0110 1100 | -108 | 1001 0100 |
109 | 0110 1101 | -109 | 1001 0011 |
110 | 0110 1110 | -110 | 1001 0010 |
111 | 0110 1111 | -111 | 1001 0001 |
112 | 0111 0000 | -112 | 1001 0000 |
113 | 0111 0001 | -113 | 1000 1111 |
114 | 0111 0010 | -114 | 1000 1110 |
115 | 0111 0011 | -115 | 1000 1101 |
116 | 0111 0100 | -116 | 1000 1100 |
117 | 0111 0101 | -117 | 1000 1011 |
118 | 0111 0110 | -118 | 1000 1010 |
119 | 0111 0111 | -119 | 1000 1001 |
120 | 0111 1000 | -120 | 1000 1000 |
121 | 0111 1001 | -121 | 1000 0111 |
122 | 0111 1010 | -122 | 1000 0110 |
123 | 0111 1011 | -123 | 1000 0101 |
124 | 0111 1100 | -124 | 1000 0100 |
125 | 0111 1101 | -125 | 1000 0011 |
126 | 0111 1110 | -126 | 1000 0010 |
127 | 0111 1111 | -127 | 1000 0001 |
-128 | 1000 0000 | ||
FAQ
What is the two's complement?
The two's complement is a way to represent negative numbers in binary when the minus sign is not available. The minus sign is substituted in the two's complement representation by a digit, usually the leading one.
- If the leading digit is
0
, the number is positive. - If the leading digit is
1
, the number is negative.
How do I calculate the two's complement of a number?
To calculate the two's complement of a number:
- If the number is negative, subtract it from the power of 2 with exponent corresponding to the number of bits of your chosen representation.
- Convert the number to binary.
- If the number was negative, add
1
to the proper position and pad with0
. - If the number was positive, left-pad the result with
0
to the desired length.
What are the disadvantages of the two's complement notation?
The two's complement notation takes one number away from the binary representation of a number. This means that, using an 8-bit representation allows us to represent numbers from −27 = −128 to 27−1 = 127. If we had renounced the use of negative numbers, 8 bits would have allowed us to represent numbers from 0 to 28−1 = 255.
What is the 8-bit two's complement notation of -37?
The 8-bit two's complement representation of −37 is 110110112. To find this result:
- Subtract 37 from 27: 128 − 37 =91.
- Find the binary representation of 91:
91 = 64 + 16 + 8 + 2 + 1
= 1·26 + 0·25 + 1·24 + 1·23 + 0·22 + 1·21 + 1·20
=1011011 - Place 1 in the correct position to mark that we started from a negative number:
−3710 = 110110112