Binary calculator

Add, subtract, multiply or divide two binary numbers, or combine them with AND, OR, XOR and bit shifts. The answer is shown in binary with its decimal, hex and octal values underneath, so 1011 + 110 gives 10001, which is 17. To convert a single number without doing any math on it, use binary to decimal, decimal to binary or binary to hex.

Show the working
Whole numbers only. A minus sign is allowed.
Checked bySharmina Rahman
Last updated · How we test

Runs in your browser. Nothing you type is uploaded.

How to use the calculator

  1. Choose an operation from the menu above the boxes.
  2. Type the first and second binary numbers. The result updates as you type.
  3. Open "Show the working" to see the same sum in decimal, and for AND, OR and XOR the bits lined up column by column.

Step-by-step working. For add, subtract, multiply and divide, "Show the working" lays out the full sum: the carry row for addition, borrows for subtraction, one shifted row per 1 bit for multiplication, and a long division table. Modulo gives the remainder only, Power raises the first number to the second, and NOT flips every bit of the first number within the digits you typed.

The swap button between the boxes exchanges the two numbers, which is handy for subtraction and division. Inputs must be whole numbers; a leading minus sign is allowed, and results can be negative. Values of any length are calculated exactly, with no 32-bit or 64-bit cut-off.

What the calculator does at the limits

The easy sums give the answers you expect. These are the inputs where people usually wonder what will happen, each one typed into the calculator on this page with Number type on Unsigned unless the row says otherwise.

InputWhat you get
101 − 1011 (a smaller number minus a bigger one)-110, which is -6
1101 ÷ 100 (a division that does not come out even)11 remainder 1, which is 3 remainder 1
1101 mod 100 (Modulo)1, the remainder only
1101 ÷ 0 (dividing by zero)No result. The message says you cannot divide by zero.
10 ^ 1010 (Power, 2 to the 10th)10000000000, which is 1024
NOT 1011 (NOT works on the first number only)100. The four digits you typed flip to 0100, and the leading zero is dropped.
-101 × 11 (a minus sign)-1111, which is -15
0b101 + 11 (0b prefix)1000, which is 8
1111_0000 + 1 (underscore between groups)11110001, which is 241
01111111 + 1 with Number type set to Signed 8-bit1000 0000, read as -128. A message says the exact answer, 128, does not fit in signed 8-bit, so it wraps.
11111111 + 0 with Number type set to Signed 8-bit-1 signed, with 255 shown next to it as the unsigned value
102 + 1 (a digit that is not 0 or 1)No result. The message says the first number can only use 0 and 1 and names the 2.
1.1 + 1 (a binary point)No result. The message says to use whole numbers only.
The binary calculator with Number type set to Signed 8-bit adding 01111111 and 1. A message says the exact answer is 128 in decimal, which does not fit in signed 8-bit, so it wraps to -128. The result is 1000 0000, decimal signed -128, decimal unsigned 128, hex 80.
01111111 + 1 in signed 8-bit. The bits are right, 1000 0000, but read as a signed byte they mean -128, and the calculator says so above the result.

Binary addition calculator: how to add binary numbers

Binary addition works like decimal addition, column by column from the right, but a column overflows at 2 instead of 10. In a chip, each column is handled by a full adder. There are only four cases to learn: 0 + 0 = 0, 0 + 1 = 1, 1 + 1 = 10 (write 0, carry 1) and 1 + 1 + 1 = 11 (write 1, carry 1).

Binary addition of 1011 and 0110 written in columns, with carries of 1 shown above three of the columns and the answer 10001 (11 + 6 = 17).

From the right: 1 + 0 = 1. 1 + 1 = 0 carry 1. 0 + 1 + 1 = 0 carry 1. 1 + 0 + 1 = 0 carry 1. The last carry drops down as the leading 1, giving 10001.

With three numbers, add two first and then add the third. 101 + 110 = 1011, and 1011 + 011 = 1110, which is 5 + 6 + 3 = 14. A longer example: 01011111 + 01110101 = 11010100 (95 + 117 = 212).

Binary subtraction calculator: how to subtract binary numbers

Subtract column by column from the right. When the top bit is 0 and the bottom bit is 1, borrow from the next column to the left. The borrowed 1 is worth 2 in the current column, so the column becomes 10 - 1 = 1, and the column you borrowed from drops by 1. The binary subtraction guide also covers the two's complement method that processors use.

Binary subtraction of 0110 from 1011 in columns. One borrow turns the third column into 10 minus 1, and the answer is 0101 (11 - 6 = 5).

If the next column to the left is also 0, keep moving left until you find a 1. Every 0 you pass on the way becomes 1. That chain of borrows is where most mistakes happen, so check the answer by adding it back: 0101 + 0110 should give 1011 again.

1000000 − 101101: a borrow that runs the whole width

This textbook problem is hard by hand because six of the seven columns in the top number are 0. The rightmost column needs a borrow, and there is no 1 to take it from until the far left. The leftmost 1 is borrowed from, every 0 on the way becomes 1, and the rightmost column becomes 10 − 1 = 1.

The answer is 10011, and the check in decimal is 64 − 45 = 19. Adding it back works too: 101101 + 10011 = 1000000.

The binary calculator result for 1000000 minus 101101: 10011, decimal 19, hex 13, octal 23. Show the working is open, with a b marked above six columns to show where 1 was borrowed, the subtraction laid out column by column and the result 10011 in red.
The working for 1000000 − 101101. Each b marks a column that lent 1 to the column on its right.

Subtraction with two's complement

Computers do not borrow. They add the negative of the second number instead, written in two's complement. To work out 1011 - 0110 in 4 bits, flip the bits of 0110 to get 1001, add 1 to get 1010, then add: 1011 + 1010 = 10101. Drop the carry out of the fourth bit and the answer is 0101, the same 5 as before.

Binary multiplication

Multiplying by a single bit is easy: by 1 the number stays the same, by 0 it becomes 0. So long multiplication in binary is just shifting and adding. Write one row for each bit of the bottom number, shifted one place further left each time, and add the rows.

Binary long multiplication of 10010 by 110: partial products 00000, 10010 shifted one place and 10010 shifted two places add up to 1101100 (18 x 6 = 108).

A smaller one: 101 × 11 is 101 plus 1010, which is 1111 (5 × 3 = 15). Multiplying by 10 just adds a 0 on the right, the same way multiplying by 10 does in decimal.

10010 × 110, step by step

The bottom number 110 has 1s in its second and third places, so there are two rows to add: 10010 shifted one place left, 100100, and 10010 shifted two places left, 1001000. The zero bit gives a row of zeros, which can be skipped. 100100 + 1001000 = 1101100, and the check in decimal is 18 × 6 = 108.

The binary calculator result for 10010 times 110: 1101100, decimal 108, hex 6C, octal 154. Show the working is open, with 10010 over 110, the two shifted rows 100100 and 1001000, and the sum 1101100 in red.
The working for 10010 × 110. Only the rows for the two 1 bits are written out.

Binary division

Long division in binary is simpler than in decimal, because each step only asks one question: does the divisor fit, yes (1) or no (0)? For 101101 ÷ 101:

  1. 101 fits into the first three bits 101 once. Write 1, remainder 0.
  2. Bring down the next bit to get 1. Too small: write 0.
  3. Bring down the next bit to get 10. Still too small: write 0.
  4. Bring down the last bit to get 101. It fits once: write 1, remainder 0.

The quotient is 1001, which checks out as 45 ÷ 5 = 9. When the division does not come out even, the calculator shows the remainder too: 1101 ÷ 100 is 11 remainder 1 (13 ÷ 4 = 3 remainder 1). Dividing by zero shows a message instead of a result.

AND, OR, XOR and shifts

These bitwise operations compare the two numbers one bit position at a time, with no carrying. For XOR of three or more values, or of text, use the XOR calculator; for the same sums in base 16, the hex calculator.

Bitwise AND, OR and XOR of 1100 and 1010: AND gives 1000, OR gives 1110 and XOR gives 0110.

AND is used to clear bits (masking), OR to set them and XOR to flip them. XOR has a handy property: applying it twice with the same value gets you back where you started, which is why it shows up in checksums and simple ciphers. To try it on a word, turn the letters into bits with text to binary first.

For shifts, the second box is how many places to move, also written in binary. 1011 shifted left by 10 (two places) is 101100, which multiplies 11 by 4 to get 44. Shifting right by 1 drops the last bit, so 1011 becomes 101, which is 11 ÷ 2 rounded down. Python's notes on bitwise operations on integers state both rules the same way.

Frequently asked questions

What is 1 + 1 in binary?

10, which is 2 in decimal. You write 0 and carry 1 to the next column.

What is 1111 + 1 in binary?

10000, which is 16. The carry ripples through all four 1s, just as 9999 + 1 does in decimal.

How do you calculate binary numbers?

The same way as decimal numbers, column by column, except that each column can only hold 0 or 1. A column that reaches 2 carries 1 to the left. The calculator above does it for you and shows the decimal check.

Does the calculator handle negative numbers?

Yes, with a minus sign in front, such as -101. With Number type on Unsigned it does not treat a leading 1 as a sign bit, so 11111111 is 255. Set Number type to Signed 8-bit and the same bits read as -1.

Is there a limit on the size of the numbers?

No fixed limit. The calculator uses whole-number arithmetic without rounding, so 64-bit and larger values give exact answers.

Scroll to Top