Binary Calculator

About this calculator

The Binary Calculator adds, subtracts, multiplies and divides base 2 numbers and shows the answer in both binary and decimal, together with the working. It also converts a binary value to decimal and a decimal value to binary.

Calculations use exact big-integer arithmetic, so long strings of ones and zeros are handled without rounding.

Digits 0 and 1 only. A leading minus sign is allowed.
Whole numbers; any fractional part is dropped.
Embed this calculator

Paste this code into a Custom HTML block on your site. The calculator fits the width of the block. Adjust the height in the code if you want more room for results.

Find this widget in the publisher directory

What is binary?

Binary is the base 2 number system. Instead of ten digits it uses just two, 0 and 1, and each place is worth twice the place to its right: 1, 2, 4, 8, 16, 32 and so on. Computers store everything as binary because an electrical switch has two natural states, off and on. A single binary digit is a bit, and eight bits make a byte.

Binary to decimal

Multiply each digit by its place value and add the results. For 10111 the places from the left are 16, 8, 4, 2 and 1:

10111₂ = 1×16 + 0×8 + 1×4 + 1×2 + 1×1 = 23

Decimal to binary

Divide the number by 2 repeatedly and record each remainder. The remainders read from last to first form the binary number. For 18: 18 ÷ 2 = 9 r 0, 9 ÷ 2 = 4 r 1, 4 ÷ 2 = 2 r 0, 2 ÷ 2 = 1 r 0, 1 ÷ 2 = 0 r 1. Reading upward gives 10010. Another way to see it is 18 = 16 + 2, so the bits for 16 and 2 are on.

DecimalBinaryDecimalBinary
0081000
1191001
210101010
311121100
4100151111
51011610000
71112010100

Binary addition

Add column by column from the right using 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: 101 + 11. The rightmost column is 1 + 1 = 10, so write 0 and carry 1. The next is 0 + 1 + 1 = 10, write 0 and carry 1. The last is 1 + 1 = 10, giving 1000. In decimal that is 5 + 3 = 8.

Binary subtraction

Subtract column by column, borrowing from the next column to the left when you need to take 1 from 0. Borrowing turns the 0 into 10 (two) and reduces the neighbor by one. For 1010 − 11, borrow to get 111 in the end, which is 10 − 3 = 7. If the second number is larger the answer is negative, and the calculator shows it with a minus sign.

Binary multiplication

Multiplying works like long multiplication in decimal, but each partial product is either zero or a shifted copy of the top number. For 10111 × 11, write 10111 once for the ones bit, and 10111 shifted one place left for the twos bit, then add: 10111 + 101110 = 1000101. In decimal, 23 × 3 = 69, which is 1000101 in binary.

Binary division

Long division uses the same steps as decimal, only each quotient digit is 0 or 1. For 10101 ÷ 11, the quotient is 111 with remainder 0, because 21 ÷ 3 = 7. When a division is not exact, this calculator reports the whole-number quotient and the remainder, so that divisor × quotient + remainder equals the dividend.

Where binary is used

  • Computer memory, processors and file sizes.
  • IP addresses and subnet masks, which are 32 bits long in IPv4.
  • Bitwise flags and permissions in software.
  • Digital logic and electronics.

Tips for working in binary

Learn the powers of two up to 1,024, because they appear constantly: 1, 2, 4, 8, 16, 32, 64, 128, 256, 512, 1,024. Group long binary strings in fours from the right to read them more easily, since each group of four bits is one hex digit. A number ending in 0 is even and one ending in 1 is odd. Shifting left by one place doubles a value, and shifting right halves it, ignoring the remainder. These shortcuts make mental checks fast: 1000101 has bits for 64, 4 and 1, which is 69.

Frequently asked questions

What is 101 + 11 in binary?
101 + 11 = 1000. In decimal that is 5 + 3 = 8.
How do I convert binary to decimal?
Multiply each digit by 2 raised to its position, counting from 0 on the right, and add the results. For 10111 that is 16 + 4 + 2 + 1 = 23.
How do I convert decimal to binary?
Divide by 2 repeatedly, keep the remainders, and read them from last to first. For 18 you get 10010.
Does this handle negative numbers?
Yes. Type a minus sign in front of a binary value and results are shown with a minus sign rather than in two’s complement.

Formulas and sample results on this page were checked against independent references. Page last reviewed or updated . How we verify calculators. Project led by Shaun Connell.