Addition, subtraction, multiplication and division all work in the binary numeral system. Their logic is the same as in decimal arithmetic: align equal place values, work from right to left when necessary, and manage carries, borrows and partial results. The difference is that base 2 has only the digits 0 and 1.

NIST defines a bit as a binary digit with the value 0 or 1. A bit string is an ordered sequence in which the most significant bit is on the left and the least significant bit is on the right. This order matters because every column has twice the weight of the column immediately to its right.

First rule: align equal place values

In column arithmetic, digits with the same weight must appear one under the other. The 2⁰ column belongs under 2⁰, 2¹ under 2¹, and so on. This is the binary equivalent of aligning ones, tens and hundreds in decimal arithmetic.

Leading zeros may be added without changing an unsigned integer's value. For example, 1101 and 01101 both represent 13. They are useful for showing alignment or working with fixed-width words.

Infographic showing addition, subtraction, multiplication and division in binary The four arithmetic operations follow decimal logic, but every column uses only 0 and 1 and is based on powers of two.

Binary addition: the fundamental cases

  • 0 + 0 = 0;
  • 0 + 1 = 1;
  • 1 + 0 = 1;
  • 1 + 1 = 10₂: write 0 and carry 1;
  • 1 + 1 + 1 = 11₂: write 1 and carry 1.

The apparently strange rule is 1 + 1 = 10₂. The value is decimal 2, but binary has no single digit 2. It is written as one unit in the next column and zero in the current column.

Complete example: 1011 + 1101

1011 + 1101 ------- 11000
  • first column: 1 + 1 = 10, write 0 and carry 1;
  • second: 1 + 0 + carry 1 = 10;
  • third: 0 + 1 + carry 1 = 10;
  • fourth: 1 + 1 + carry 1 = 11; write 1 and place the final carry on the left.

The result is 11000₂. Decimal verification gives 11 + 13 = 24.

Step-by-step binary addition of 1011 and 1101 with carries Whenever a column totals decimal 2 or 3, its binary form produces a current digit and a carry to the left.

Where does the carry go?

The carry always belongs to the next column on the left because that column has twice the weight. A value of 2 in the 2⁰ column is rewritten as 0 × 2⁰ + 1 × 2¹. The new 1 must therefore be added to the 2¹ column.

A final carry is not discarded in variable-width arithmetic. If it remains after the leftmost column, it becomes a new leading digit.

Diagram showing where the carry moves during binary addition Every carry is placed above the next column to the left; the last carry becomes a new leading digit.

Binary subtraction: a borrow is worth 10₂

  • 0 - 0 = 0;
  • 1 - 0 = 1;
  • 1 - 1 = 0;
  • 0 - 1 requires a borrow from the left.

In decimal arithmetic, a borrowed unit becomes ten units in the current column. In base 2, one unit from the next column is worth two current units. Therefore the borrowed value is 10₂, and 10₂ - 1₂ = 1₂.

Example: 1101 - 0110

1101 - 0110 ------- 0111

The result is 111₂, decimal 7. The check is 13 - 6 = 7.

If the immediate bit to the left is zero, the borrow propagates farther left until it reaches a 1. That 1 becomes 0, and the zeros crossed by the borrow become available to pass a borrow onward. It is the same idea as decimal subtraction across several zeros, adapted to base 2.

Subtraction as addition of the two's complement

Digital hardware can reuse an adder. At a fixed width:

A - B = A + two's_complement(B)

To form the two's complement, invert every bit at the chosen width and add 1. On four bits, the two's complement of 0110 is 1010:

1101 + 1010 ------- 1 0111

Discarding the carry beyond the four-bit word leaves 0111, or 7. This method connects binary arithmetic, signed integers and the hardware arithmetic-logic unit.

Binary multiplication: partial products and shifts

  • 0 × 0 = 0;
  • 0 × 1 = 0;
  • 1 × 0 = 0;
  • 1 × 1 = 1.

Each multiplier digit creates a partial product. A 0 produces all zeros; a 1 produces a copy of the multiplicand. Moving left through multiplier positions shifts each partial product by the same number of places.

Example: 101 × 11

101 × 11 ----- 101 + 1010 ----- 1111

101₂ is 5 and 11₂ is 3. The result 1111₂ is 15, confirming 5 × 3 = 15.

A one-position left shift multiplies an unsigned integer by 2 if enough width is available. In a fixed-width word, however, bits shifted out on the left are lost, so overflow must be considered.

Binary division: compare, subtract and keep the remainder

Long division follows the decimal idea. Compare the divisor with the current part of the dividend. If it fits, write 1 in the quotient and subtract it; otherwise write 0. Then bring down the next digit.

Simple example: 1100 ÷ 10

1100₂ is 12 and 10₂ is 2. The quotient is 110₂, or 6, with remainder 0.

For a positive unsigned integer, division by 10₂ is equivalent to shifting right by one position. The bit removed from the right is the remainder after division by 2.

Example with a remainder: 10111 ÷ 11

10111₂ is 23 and 11₂ is 3:

10111₂ ÷ 11₂ = 111₂ with remainder 10₂.

In decimal, 23 = 3 × 7 + 2. The remainder must be smaller than the divisor; binary 10 is 2 and binary 11 is 3.

Shifts and powers of two

For non-negative integers without overflow:

  • one left shift multiplies by 2;
  • two left shifts multiply by 4;
  • one right shift performs integer division by 2;
  • k shifts correspond to multiplication or division by 2ᵏ.

Signed values require more care. A logical right shift inserts zeros on the left, whereas an arithmetic right shift usually repeats the most significant bit to preserve the sign. Exact behaviour depends on architecture and programming language.

Fixed width, carry and overflow

On paper, a result can grow by another digit. A hardware register has a fixed width. With four unsigned bits:

1111 + 0001 ------- 1 0000

The mathematical value is 16, but four bits represent only 0 through 15. If only the lower four bits are stored, the result becomes 0000 and the external carry reports that the value did not fit.

Unsigned carry and signed overflow are not the same condition. On four-bit two's complement:

0111 (+7) + 0001 (+1) ------- 1000

1000 represents -8, but the mathematical result is +8, outside the range -8 to +7. Signed overflow has occurred even without a final external carry.

What does the CPU do?

A CPU does not write columns on paper. It uses combinational and sequential circuits built from logic gates. Full adders process operand bits, carry inputs and carry outputs; registers hold operands and results; control circuits select the required operation.

Intel's official instruction reference describes operations such as ADD, ADC for addition with carry, SUB, SBB for subtraction with borrow, and multiplication and division instructions. These instructions update status flags, including carry and overflow, so software can continue calculations wider than one register and detect out-of-range results.

Checking the examples with Python

Python accepts binary integer literals with the 0b prefix. Ordinary arithmetic produces integers, and bin() shows a result in base 2.

a = 0b1011 b = 0b1101 print(bin(a + b)) # 0b11000 print(bin(a - 0b0110)) # 0b101 print(bin(0b101 * 0b11)) # 0b1111 q, r = divmod(0b10111, 0b11) print(bin(q), bin(r)) # 0b111 0b10

Python integers have arbitrary precision, so they do not automatically reproduce four-bit or eight-bit register overflow. To study fixed width, apply a mask such as & 0b1111 to retain four bits.

Common mistakes

  • Failing to right-align digits: different positional weights are combined.
  • Leaving the carry in the same column: it belongs to the next column on the left.
  • Not reducing the column that supplied a borrow: a borrow changes that column.
  • Forgetting to shift partial products: multiplier positions have different weights.
  • Confusing quotient and remainder: the remainder must be smaller than the divisor.
  • Ignoring width: a mathematically correct value may not fit in the available register.
  • Confusing carry and overflow: carry mainly describes unsigned range; overflow describes signed range.

Frequently asked questions

Why does 1 + 1 not produce the digit 2?

The value is decimal two, but base 2 writes that value as 10 because it has no single digit 2.

When does the final carry become a new digit?

In variable-width arithmetic. In a fixed-width register, it may remain outside the stored result and be recorded in a carry flag.

Does multiplying by 10₂ mean multiplying by ten?

No. 10₂ is decimal 2, so multiplication by 10₂ means multiplication by 2.

Can binary division have a remainder?

Yes. As in decimal arithmetic, a non-exact division produces both a quotient and a remainder.

Why use two's complement for subtraction?

It converts subtraction into addition, allowing much of the same arithmetic circuitry to be reused.

Official sources and further reading