Skip to content

Binary Calculator: Add, Subtract, Multiply, Divide

Add, subtract, multiply and divide binary numbers, with carries shown and results in binary, decimal and hex.

Your details

Digits 0 and 1 only, up to 256 digits. A leading minus sign is allowed.

Operation

Optional: also show the result as a fixed-width signed pattern, as stored in a computer register.

Results update as you type

Result (binary)

10001

Result in decimal
17
Result in hexadecimal
0x11
A and B in decimal
A = 11, B = 6
Significant bits
5

Step-by-step solution
  1. 1011 + 110 = 10001
  2. The final carry adds one more digit on the left.
  3. In decimal: 11 + 6 = 17

Column addition with carries (bit 0 = rightmost)

Computers do all their arithmetic in base 2, with only the digits 0 and 1. This binary calculator performs the four operations on two binary numbers of any length up to 256 digits — addition, subtraction, multiplication and division (quotient and remainder) — using exact big-integer arithmetic, so there is no rounding even for very long numbers.

The answer is given in binary, decimal and hexadecimal at once, and the work is laid out the way you would do it on paper: a column-by-column table with every carry for addition, every borrow for subtraction, and the shifted partial products for multiplication. It is a convenient way to check homework in a digital-electronics or computer-architecture course, or to verify what a piece of low-level code should produce.

Negative numbers can be typed with a minus sign. If you pick a register width (8, 16, 32 or 64 bits), the calculator also shows the result as a two’s complement bit pattern and warns you when it overflows that width, exactly as a processor would.

How to use this calculator

  1. Type the first binary number A, for example 1011. Spaces and underscores are ignored, so 1101 0110 is fine.
  2. Choose the operation: +, −, × or ÷.
  3. Type the second binary number B.
  4. Optionally pick a width for the two’s complement view.
  5. Read the result in binary, decimal and hexadecimal. Open the table and steps to follow the carries, borrows or partial products.

The formula

A binary numeral bn−1…b1b0b_{n-1}\ldots b_1 b_0 stands for ∑ibi 2i\sum_{i} b_i \, 2^i. The four operations work like decimal arithmetic with only two digits.

Addition, column by column from the right (Knuth’s Algorithm A): si=(ai+bi+ci) mod 2s_i = (a_i + b_i + c_i) \bmod 2 and the carry ci+1=⌊(ai+bi+ci)/2⌋c_{i+1} = \lfloor (a_i + b_i + c_i)/2 \rfloor. The four basic facts are 0+0=00+0=0, 0+1=10+1=1, 1+1=101+1=10 and 1+1+1=111+1+1=11.

Subtraction uses borrows: when ai−bi−ki<0a_i - b_i - k_i < 0 you borrow 22 from the next column.

Multiplication is shift-and-add: A×B=∑bi=1A⋅2iA \times B = \sum_{b_i = 1} A \cdot 2^i, i.e. a copy of AA shifted left ii places for each 1 bit of BB.

Division gives A=B×Q+RA = B \times Q + R with ∣R∣<∣B∣|R| < |B|.

Two’s complement on ww bits stores an integer xx with −2w−1≤x≤2w−1−1-2^{w-1} \le x \le 2^{w-1}-1 as x mod 2wx \bmod 2^w; for a negative number, invert all the bits of ∣x∣|x| and add 1.

Worked example

Binary addition 1011 + 110 (11 + 6 in decimal). From the right: 1+0=11+0 = 1; 1+1=101+1 = 10, write 0 carry 1; 0+1+1=100+1+1 = 10, write 0 carry 1; 1+0+1=101+0+1 = 10, write 0 carry 1; the last carry gives a new digit. The carries out of each column, read from left to right, are 1110, and the sum is 10001 = 17.

Subtraction 11010−1111=101111010 - 1111 = 1011 (26 − 15 = 11). Multiplication 1101×1011101 \times 101: two partial products, 11011101 and 110100110100, add up to 1000001 (13 × 5 = 65). Division 11011÷10111011 \div 101 gives quotient 101 and remainder 10 (27 = 5 × 5 + 2).

Two’s complement: −5 on 8 bits is 1111101111111011: write 5 as 00000101, invert to 11111010, add 1.

Binary addition step by step

Binary addition follows the same column method as decimal addition, but a column overflows as soon as it reaches 2 instead of 10. Each column therefore has only four cases:

Bits + carry in Sum bit Carry out
0 + 0 + 0 0 0
1 + 0 + 0 1 0
1 + 1 + 0 0 1
1 + 1 + 1 1 1

This table is exactly what a full adder circuit implements with logic gates: the sum bit is a⊕b⊕ca \oplus b \oplus c (XOR) and the carry is set when at least two of the three inputs are 1. Chaining one full adder per bit gives a ripple-carry adder, the simplest way a processor adds two registers.

Binary arithmetic operations and negative numbers

The four binary arithmetic operations rely on a handful of facts. Subtraction borrows a 2 from the next column (10−1=110 - 1 = 1). Multiplication only ever multiplies by 0 or 1, so it reduces to copying the first number, shifting it left and adding — which is why multiplying by 2 is a simple left shift. Long division works like decimal long division, except that each quotient digit is either 0 or 1.

Computers rarely store a minus sign. With two’s complement, the same adder handles positive and negative numbers: subtracting B is the same as adding the two’s complement of B and dropping the final carry. On 8 bits, 00010100 (20) + 11111001 (−7) = 00001101 (13). Results outside the range of the register overflow and wrap around. To work with remainders and powers of two, see the modulo calculator; for the number of bits a value needs, use log₂ in the logarithm calculator.

Frequently asked questions

How do you add binary numbers?

Line the numbers up on the right and add column by column: 0 + 0 = 0, 0 + 1 = 1, 1 + 1 = 0 carry 1, and 1 + 1 + 1 = 1 carry 1. For example 1011 + 110 = 10001, which is 11 + 6 = 17.

What is 1 + 1 in binary?

1 + 1 = 10 in binary: the column becomes 0 and a 1 is carried to the next place, because 2 is written 10 in base 2. Likewise 1 + 1 + 1 = 11 (three).

How do you subtract binary numbers?

Work right to left, borrowing when the top bit is smaller: 0 − 1 becomes 10 − 1 = 1 with a borrow from the next column. Alternatively, add the two’s complement of the second number and drop the final carry.

How does binary division handle the remainder?

The calculator returns a whole-number quotient and a remainder such that A = B × Q + R. 11011 ÷ 101 gives Q = 101 and R = 10 (27 ÷ 5 = 5 remainder 2). With negative numbers the quotient is truncated toward zero.

What is two’s complement?

It is the standard way to store signed integers in a fixed number of bits: negative x is stored as 2ʷ − |x|. To get it by hand, invert every bit of the positive value and add 1. On 8 bits, −5 is 11111011.

Sources

Last updated:

More Math calculators

People also use