Omni Calculator logo

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, 00 or 11. Each digit corresponds to a successive power of 2, starting on the right.

For example, 1212 in binary is 11001100, as 12=8+4=123+122+021+02012 = 8 + 4 = 1\cdot2^3 + 1\cdot2^2 + 0\cdot2^1 + 0\cdot2^0 (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 11 to show that something is present or 00 to mean that there is a lack of that thing, there are two main approaches:

  1. 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 11 is negative, while a leading 00 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.

  2. 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:

  1. Choose the number of bits in your notation. The higher value, the broader range of numbers you can input.

  2. Write any whole decimal within the range that appears under the Decimal to binary section.

  3. … 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:

  1. Choose the number of bits in the binaries representation. Let's assume we want values in the 8-bit system.

  2. Write down your number, let's say 16. 16 in binary is 1 00001\ 0000.

  3. Add some leading 00's so that the number has eight digits, 0001 00000001\ 0000. That's 16 in the two's complement notation.

And what about its counterpart, 16-16?

  1. Switch all the digits to their opposite (010\rightarrow1 and 101\rightarrow0). In our case, 0001 00001110 11110001\ 0000 \rightarrow 1110\ 1111.

  2. Add 1 to this value, 1110 1111+1=1111 00001110\ 1111 + 1 = 1111\ 0000.

  3. 1111 00001111\ 0000 in the two's complement representation is 16-16 in decimal notation and is the 2's complement of 0001 00000001\ 0000.

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 1011 10111011\ 1011, 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 1-1 instead of 11. Starting from the right:

decimal=120+121+022+123+124+125+026127=1+2+8+16+32128=69\scriptsize \begin{split} \rm{decimal} &= 1\cdot2^0+1\cdot2^1+0\cdot2^2+1\cdot2^3\\ &+1\cdot2^4+1\cdot2^5+0\cdot2^6-1\cdot2^7\\ &=1+2+8+16+32-128 \\ &= -69 \end{split}

Method 2

We can see that the first digit is 11, 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:

  1. Reverse digits, 1011 10110100 01001011\ 1011 \rightarrow 0100\ 0100.
  2. Add a unity, 0100 0100+1=0100 01010100\ 0100 + 1 = 0100\ 0101.
  3. Convert to a decimal (starting from the right),
decimal=120+021+122+023+024+025+126+027\scriptsize \begin{split} \qquad \rm{decimal} =& \,1\!\cdot\!2^0 \!+\! 0\!\cdot\!2^1 \!+\! 1\!\cdot\!2^2 \!+\! 0\!\cdot\!2^3\\ +& \,0\!\cdot\!2^4 \!+\! 0\!\cdot\!2^5 \!+\! 1\!\cdot\!2^6 \!+\! 0\!\cdot\!2^7 \end{split}
  1. decimal=1+4+64=69\rm{decimal} = 1 + 4 + 64 = 69.
  2. As 6969 is the absolute value of our initial (negative) binary, add a minus sign in front of it.
  3. 1011 10111011\ 1011 is 69-69 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:

  1. If the number is negative, subtract it from the power of 2 with exponent corresponding to the number of bits of your chosen representation.
  2. Convert the number to binary.
  3. If the number was negative, add 1 to the proper position and pad with 0.
  4. 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:

  1. Subtract 37 from 27: 128 − 37 =91.
  2. 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
  3. Place 1 in the correct position to mark that we started from a negative number:
    −3710 = 110110112
Wojciech Sas, PhD
Binary number representation
8-bit
Decimal to binary
You can enter a decimal number between -128 and 127.
Decimal
Binary to decimal
You can write a binary number with no more than 8 digits. You don't have to input leading zeros.
Binary
Check out 13 similar binary calculators 1️0️
ANDBinary additionBinary division… 10 more
People also viewed…

Inverse variation

Use this inverse variation calculator to understand and compute the inverse proportionality between two variables.

Plastic footprint

Find out how much plastic you use throughout the year with this plastic footprint calculator. Rethink your habits, reduce your plastic waste, and make your life a little greener.

Round to the nearest hundred

With this handy tool, you will learn how to calculate the rounding to the nearest hundred for every number you can think of!

Sleep

The sleep calculator can help you determine when you should go to bed to wake up happy and refreshed.