Skip to content
thecalculatorstudio

Binary Calculator: Add, Subtract, Multiply, Divide

Enter two binary numbers and pick an operation. You get the answer in binary, decimal, hexadecimal and octal, with the remainder for division, exact for numbers of up to 64 bits.

Last reviewed

Up to 64 binary digits each. A 0b prefix, spaces and underscores are fine.

1010 + 110

1 0000

in binary · 5 bits

Binary
1 0000
Decimal
16
Hexadecimal
10
Octal
20

Whole numbers only, and exact: the answer is worked in arbitrary-size integers, not floating point. Division gives a whole-number quotient and a remainder. AND, OR and XOR need numbers of 0 or more.

What binary is

Binary is the number system with two digits, 0 and 1, where decimal has ten. It is how computers store and process numbers, because a switch, a voltage or a magnetic spot can be in one of two states. Each digit is a bit, and eight bits make a byte.

Binary works like decimal, with a different base. In decimal each place is worth ten times the one to its right (1, 10, 100, 1,000). In binary each place is worth two times the one to its right.

Place from the right 1st 2nd 3rd 4th 5th 6th 7th 8th
Worth 1 2 4 8 16 32 64 128

The next places are 256, 512 and 1,024. So 1101 means 8 + 4 + 0 + 1 = 13.

Counting from 0 to 15

Decimal Binary Hex
0 0000 0
1 0001 1
2 0010 2
3 0011 3
4 0100 4
5 0101 5
6 0110 6
7 0111 7
8 1000 8
9 1001 9
10 1010 A
11 1011 B
12 1100 C
13 1101 D
14 1110 E
15 1111 F

Four bits count from 0 to 15, which is exactly one hexadecimal digit. That is why programmers write long binary numbers in hex. See the hex calculator.

Binary to decimal, and back

To decimal: add the place value of every 1. For 1101 that is 8 + 4 + 1 = 13.

From decimal: divide by 2 again and again, keeping each remainder, and read the remainders from the last to the first. For 13: 13 ÷ 2 = 6 remainder 1; 6 ÷ 2 = 3 remainder 0; 3 ÷ 2 = 1 remainder 1; 1 ÷ 2 = 0 remainder 1. Reading upwards gives 1101.

For any number, the hex to decimal converter also works from binary and octal and shows the place values.

The four operations

Addition follows four rules: 0 + 0 = 0, 0 + 1 = 1, 1 + 1 = 10 (write 0, carry 1), and 1 + 1 + 1 = 11 (write 1, carry 1). Example: 1010 + 110 = 10000, which is 10 + 6 = 16.

Subtraction borrows when the top digit is smaller than the bottom: a borrowed 1 is worth 2 in the column to its right. 1101 − 1011 = 10, which is 13 − 11 = 2.

Multiplication is shifting and adding. Multiplying by 1 copies the number, multiplying by 0 gives 0, and each place shifts it one place left. 1011 × 11 is 1011 + 10110 = 100001, which is 11 × 3 = 33.

Division is long division with only 0 and 1 as quotient digits. 10110 ÷ 101 = 100 remainder 10, which is 22 ÷ 5 = 4 remainder 2. The long division calculator shows the same method in decimal.

AND, OR and XOR

These compare two numbers one bit at a time.

Bits AND OR XOR
0 and 0 0 0 0
0 and 1 0 1 1
1 and 0 0 1 1
1 and 1 1 1 0

For 1100 and 1010 (12 and 10): AND is 1000 (8), OR is 1110 (14) and XOR is 0110 (6). AND picks out bits (a “mask”), OR switches them on, and XOR flips them where the other number has a 1.

How big can a number be?

Bits Largest whole number
8 255
16 65,535
32 4,294,967,295
64 18,446,744,073,709,551,615

An n-bit number can hold 2ⁿ − 1 at most. This calculator takes up to 64 bits per number, and gives exact answers beyond that, such as the 65-bit result of adding 1 to the largest 64-bit number. Big values of this kind are also in the big number calculator, and powers of two are in the exponent calculator.

Common mistakes

  • Reading 10 as ten. In binary, 10 is two. Check what base a number is in.
  • Forgetting the carry when adding 1 + 1. It is 10, so 0 is written and 1 carried.
  • Leading zeros. 0011 and 11 are the same number (3). The answer drops them.
  • Using 2 or any other digit. Only 0 and 1 are binary digits. The calculator points out the wrong digit.
  • Expecting two’s complement. Computers usually store negative numbers in two’s complement. This page shows a negative answer with a minus sign instead.
  • Hex calculator and hex to decimal converter.
  • Big number calculator and exponent calculator.
  • Long division calculator and scientific notation calculator.

How it is calculated

Each number is read digit by digit as a whole number in exact integer arithmetic (up to 64 binary digits), the operation is done on the integers, and the answer is written back in binary, decimal, hexadecimal and octal. Division gives the quotient rounded toward zero and the remainder, so that divisor × quotient + remainder equals the first number. AND, OR and XOR act on the bits of the two numbers. Nothing goes through floating point.

Frequently asked questions

How do you add binary numbers?

Add column by column from the right, carrying as you would in decimal. 0+0 = 0, 0+1 = 1, 1+1 = 10 (write 0, carry 1) and 1+1+1 = 11 (write 1, carry 1). For example 1010 + 110 = 10000, which is 10 + 6 = 16.

How do you subtract binary numbers?

Subtract column by column and borrow from the next column when you need to: borrowing turns a 0 into 10 (two) in the column on its right. 1101 − 1011 = 10, which is 13 − 11 = 2. If the second number is bigger, this calculator gives a negative answer with a minus sign.

How do you convert binary to decimal?

Add the place value of every 1, where the places from the right are 1, 2, 4, 8, 16 and so on. 1101 is 8 + 4 + 0 + 1 = 13. The answer is also shown in the results above, with hexadecimal and octal.

What do AND, OR and XOR do?

They compare two numbers one bit at a time. AND gives 1 only where both bits are 1, OR gives 1 where either is 1, and XOR gives 1 where the bits differ. 1100 and 1010 give 1000 for AND, 1110 for OR and 0110 for XOR.

How big a binary number can this calculator handle?

Up to 64 binary digits for each number, which is the size of an unsigned 64-bit integer (up to 18,446,744,073,709,551,615). The answer can be longer. It is worked in exact whole-number arithmetic, so there is no rounding.

Can it do negative binary numbers or fractions?

Negative numbers are shown with a minus sign, not in two's complement, and are allowed for adding, subtracting, multiplying and dividing. It does not handle binary fractions, such as 101.01, and AND, OR and XOR need numbers of 0 or more.

Related calculators

Sources