Binary Arithmetic and Two's Complement: Add, Subtract, Multiply

Learn binary addition with carries, subtraction with borrows, multiplication and division, and how two's complement stores negatives and overflows.

Updated September 29, 2026 7 min read

Use the free Binary CalculatorBinary arithmetic, bitwise AND/OR/XOR/NOT, shifts and two's complement

Binary arithmetic follows exactly the same rules you learned for decimal sums at school. The only difference is that you carry when a column reaches 2 instead of 10. Once that clicks, adding, subtracting and multiplying in binary becomes mechanical, and it explains a lot about how computers behave, including why adding two positive numbers can sometimes produce a negative one.

This guide covers the four operations by hand, then explains two's complement, the system almost every modern processor uses for negative integers, and the overflow that happens when a result does not fit in the available bits. If you first need to convert between binary, decimal and hex, read How to Convert Between Binary, Decimal and Hex by Hand.

Binary addition

There are only four single-bit facts to learn:

Sum Result Carry
0 + 0 0 0
0 + 1 1 0
1 + 1 0 1
1 + 1 + 1 (with carry in) 1 1

Work from the right-hand column to the left, just as in decimal. Here is 101101 (45) plus 1011 (11):

 carries     1 1 1 1
           1 0 1 1 0 1
         + 0 0 1 0 1 1
         -------------
           1 1 1 0 0 0

The result is 111000, which is 56 in decimal, and 45 + 11 = 56. Checking in decimal is the best habit you can build.

Binary subtraction

Subtraction uses borrowing. When you need to take 1 from 0, borrow from the next column to the left. In binary, a borrowed 1 is worth 2 in the current column, so 0 − 1 becomes 2 − 1 = 1, and the column you borrowed from loses 1.

101101 (45) minus 1011 (11):

   1 0 1 1 0 1
 − 0 0 1 0 1 1
 -------------
   1 0 0 0 1 0

The answer, 100010, is 34. Long chains of borrowing (for example 1000000 − 1) are where most mistakes happen. Computers avoid borrowing entirely by adding the two's complement of the second number instead, which is explained below.

Binary multiplication

Multiplication is easier in binary than in decimal because each digit of the multiplier is either 0 or 1. You either copy the top number, shifted left, or write zeros, then add the partial products:

        1 0 1 1 0 1    (45)
      ×     1 0 1 1    (11)
      -------------
        1 0 1 1 0 1    × 1
      1 0 1 1 0 1      × 1, shifted 1
    0 0 0 0 0 0        × 0, shifted 2
  1 0 1 1 0 1          × 1, shifted 3
  -----------------
  1 1 1 1 0 1 1 1 1    (495)

A useful consequence: shifting a binary number one place left multiplies it by 2, just as appending a zero in decimal multiplies by 10. 1101 (13) shifted left is 11010 (26).

Binary division

Long division works as in decimal, but at each step the divisor either "goes in" once or not at all. 101101 (45) divided by 1011 (11) gives a quotient of 100 (4) and a remainder of 1, because 11 × 4 = 44. Shifting right by one place divides by 2 and discards the remainder bit.

Negative numbers: two's complement

A computer stores integers in a fixed number of bits, such as 8, 16, 32 or 64. Two's complement is the convention for representing negatives in that fixed width.

To encode a negative number

  1. Write the absolute value in binary, padded to the width.
  2. Invert every bit (0 becomes 1 and 1 becomes 0). This is the one's complement.
  3. Add 1.

For −42 in 8 bits:

 42          0010 1010
 invert      1101 0101
 add 1       1101 0110   → −42

In hex that pattern is D6.

To decode a pattern

If the top (leftmost) bit is 0, the number is positive and you read it normally. If it is 1, the number is negative: invert and add 1 to get the magnitude, then apply the minus sign. Another way to think about it is that the top bit has a negative place value. In 8 bits it is worth −128, so 1101 0110 is −128 + 64 + 16 + 4 + 2 = −42.

Why this system won

  • There is only one zero (0000 0000). Older sign-and-magnitude schemes had both +0 and −0.
  • Addition and subtraction use the same circuit for signed and unsigned numbers. Subtracting B is just adding the two's complement of B.
  • The range is asymmetric: 8 bits hold −128 to +127. There is one more negative number than positive, which is why −128 has no positive counterpart in 8 bits.
Width Signed range
8-bit −128 to 127
16-bit −32,768 to 32,767
32-bit −2,147,483,648 to 2,147,483,647

Overflow: when the answer does not fit

Add 100 and 50 in 8-bit signed arithmetic. The true answer, 150, is above 127. The bit pattern produced is 1001 0110, and because its top bit is 1, it reads as −106. The processor has not made an error; the result simply wrapped around the range.

This is integer overflow, and it is a real source of software bugs, from counters that suddenly go negative to calculations that silently produce nonsense. The rule of thumb: if two numbers with the same sign produce a result with the opposite sign, overflow has occurred.

How to do it with the calculator

The Binary Calculator has three tabs.

  1. Arithmetic (+ − × ÷): type the First number (binary), choose the Operation and type the Second number. A leading minus sign is allowed and spaces or underscores are ignored, so you can group bits for readability. Addition shows the column working with carries, multiplication shows the partial products, and division gives the quotient and remainder. Every result is also shown in decimal, hexadecimal and octal.
  2. Bitwise (AND, OR, XOR, NOT, shifts): pick a Bit width and an operation, including logical and arithmetic right shifts. The result is shown bit by bit, with unsigned and signed decimal readings.
  3. Two's complement: choose Decimal → two's complement or Two's complement → decimal, set the Bit width (4 to 64 bits) and enter a value. The steps show the invert-and-add-one process, and the tool warns you if a number is outside the signed range for that width.

The arithmetic tab works with numbers of any length, so it does not overflow; use the two's complement tab to see what a fixed-width machine would store.

Other ways to check your work

  • Operating system calculators: the Windows Calculator's Programmer mode and the macOS Calculator's programmer view both do binary arithmetic and bitwise operations in fixed widths.
  • Programming languages: in Python, bin(0b101101 + 0b1011) prints 0b111000. In JavaScript, (45).toString(2) converts and -42 & 0xFF gives 214, the unsigned reading of the 8-bit pattern.
  • Convert and check: turn each number into decimal with the Number Base Converter, do the arithmetic, and convert back.

For hexadecimal sums and bit masks written in hex, the Hex Calculator is the companion tool.

Common mistakes

  • Forgetting the final carry. 1 + 1 in the leftmost column produces an extra digit; 111 + 1 is 1000, not 000 (unless you are working in a fixed 3-bit width, where it overflows).
  • Mixing widths. −42 is 1101 0110 in 8 bits but 1111 1111 1101 0110 in 16 bits. Always state the width.
  • Treating two's complement as "flip the sign bit". Changing only the top bit of 0010 1010 gives 1010 1010, which is −86, not −42.
  • Confusing logical and arithmetic right shift. For negative numbers, an arithmetic shift copies the sign bit (−20 >> 1 = −10), while a logical shift fills with 0 and produces a large positive number.

Frequently asked questions

What is 1 + 1 in binary?

It is 10: a 0 in the current column with a 1 carried to the next. That 10 means two in decimal.

How do you subtract in binary without borrowing?

Add the two's complement of the number you are subtracting and ignore any carry out of the top bit. Within a fixed width, A − B equals A + (NOT B + 1).

Why is the range of an 8-bit signed number −128 to 127?

Eight bits give 256 patterns. Half have a top bit of 1 and represent −128 to −1; the other half represent 0 to 127, so zero takes one of the "positive" slots.

What is the difference between one's complement and two's complement?

One's complement just inverts every bit. Two's complement inverts and then adds 1, which removes the duplicate negative zero and makes ordinary addition work for signed numbers.

How do I know if a binary number is negative?

Only if you know it is a signed value and its width. In two's complement, a 1 in the top bit of that width means negative; the same bits read as unsigned are a positive number.

Try it now: Binary Calculator

Loading tool…