Skip to content
Calculator.hair

Binary Calculator

Binary Calculation—Add, Subtract, Multiply, or Divide

Press Calculate to see the results.

Convert Binary Value to Decimal Value

Press Calculate to see the results.

Convert Decimal Value to Binary Value

Press Calculate to see the results.

This binary calculator performs arithmetic on base-2 numbers and converts values between binary and decimal. Numbers of any length are handled exactly.

The binary number system, or base 2, writes every number using only two digits, 0 and 1. Each digit is called a bit. Binary is the native language of digital electronics because a circuit can represent two states, off and on, far more reliably than ten. Every file, image and instruction inside a computer is ultimately a long string of bits.

Binary works exactly like the familiar decimal system except for the base. In decimal, each place is worth ten times the place to its right: ones, tens, hundreds. In binary, each place is worth twice the place to its right: ones, twos, fours, eights, sixteens and so on. The binary number 10110 therefore means (1 × 16) + (0 × 8) + (1 × 4) + (1 × 2) + (0 × 1) = 22.

DecimalBinaryDecimalBinary
0081000
1191001
210101010
311111011
4100121100
5101131101
61101610000
711132100000

To convert binary to decimal, multiply each bit by its place value, a power of 2, and add the results. Working right to left, the place values are 2⁰ = 1, 2¹ = 2, 2² = 4, 2³ = 8 and so on. For 10101010: (1 × 128) + (0 × 64) + (1 × 32) + (0 × 16) + (1 × 8) + (0 × 4) + (1 × 2) + (0 × 1) = 170. Only the 1 bits contribute, so you can simply add the place values where a 1 appears.

To convert decimal to binary, one method is to subtract the largest power of 2 that fits, write a 1 in that place, and repeat with the remainder, writing 0 in any place that is skipped. For 18, the largest power of 2 that fits is 16, leaving 2; 8 and 4 do not fit, 2 does, leaving 0; and 1 is not needed. The bits are 1 0 0 1 0, so 18 = 10010.

A second method, used in the converter above, divides by 2 repeatedly and records the remainders. 170 ÷ 2 = 85 remainder 0, 85 ÷ 2 = 42 remainder 1, 42 ÷ 2 = 21 remainder 0, and so on until the quotient reaches 0. Reading the remainders from last to first gives the binary digits, 10101010.

Groups of bits have names. Four bits form a nibble, which maps neatly to one hexadecimal digit, and eight bits form a byte, which can hold 2⁸ = 256 different values, 0 to 255. Computers represent negative numbers using two's complement, in which the leftmost bit carries a negative place value; this calculator instead shows negative results with a minus sign, as you would write them by hand.

Binary Addition

Binary addition follows the same column-by-column method as decimal addition, but carrying happens as soon as a column reaches 2. There are only four basic facts: 0 + 0 = 0, 0 + 1 = 1, 1 + 0 = 1, and 1 + 1 = 10, which means write 0 and carry 1. With a carry coming in, 1 + 1 + 1 = 11, which means write 1 and carry 1.

For example, 1011 + 110: the rightmost column is 1 + 0 = 1. The next is 1 + 1 = 10, so write 0 and carry 1. The next is 0 + 1 + 1 (carry) = 10, write 0, carry 1. The last is 1 + 1 (carry) = 10. Reading the result gives 10001. Checking in decimal, 11 + 6 = 17, and 10001 is 16 + 1 = 17. The default values, 10101010 + 11001100, add to 101110110, which is 170 + 204 = 374.

Binary Subtraction

Subtraction also works column by column. The facts are 0 − 0 = 0, 1 − 0 = 1, 1 − 1 = 0, and 0 − 1, which requires borrowing. Borrowing takes 1 from the next column to the left, and because each place is worth twice the one to its right, the borrowed 1 is worth 2 in the current column. So 0 − 1 becomes 10 − 1 = 1, with the column to the left reduced by 1.

For example, 1100 − 101: the rightmost column is 0 − 1, so borrow. The next column to the left is also 0, so the borrow has to come from the third column, turning the 1 there into 0 and passing 2s down the line. Working it through gives 111, and in decimal 12 − 5 = 7, which checks out.

When the second number is larger, subtract the smaller from the larger and attach a minus sign. Computers avoid borrowing altogether by adding the two's complement of the second number: invert every bit, add 1, add the result to the first number and discard any overflow bit.

Binary Multiplication

Binary multiplication is simpler than decimal because each digit of the multiplier is either 0 or 1. Multiplying by 1 copies the number, and multiplying by 0 gives zero. So the long-multiplication method reduces to writing shifted copies of the first number for each 1 in the second, then adding them up.

Take 101 × 11. The rightmost bit of 11 is 1, so write 101. The next bit is also 1, so write 101 shifted one place left, 1010. Adding 101 + 1010 gives 1111, which is 15, matching 5 × 3 in decimal. Shifting a binary number one place left always doubles it, just as appending a zero in decimal multiplies by ten. This shift-and-add procedure is essentially how simple processors multiply.

Long numbers work the same way; there are just more partial products to add. Many students find it easiest to add the partial products two at a time to keep the carries manageable.

Binary Division

Binary long division mirrors decimal long division, but each step only asks whether the divisor fits into the current portion of the dividend once or not at all, so every quotient digit is 0 or 1. Bring down bits one at a time, write 1 and subtract the divisor whenever it fits, otherwise write 0. Dividing 11011 (27) by 11 (3) gives 1001 (9) with no remainder. This calculator returns the whole-number quotient and any remainder.

10011111011−110011−110

Frequently asked questions

How do I convert binary to decimal?

Multiply each bit by its power of 2 and add. 1101 = 8 + 4 + 0 + 1 = 13.

How do I convert decimal to binary?

Divide by 2 repeatedly and read the remainders from last to first. 13 → 6 r1 → 3 r0 → 1 r1 → 0 r1, giving 1101.

What is 1 + 1 in binary?

10, which is two in decimal: write 0 and carry 1 to the next place.

Why do computers use binary?

Electronic circuits can distinguish two states, on and off, very reliably and cheaply, so storing and processing data as 0s and 1s is the most robust design.

Updated by Calculator.hair. How we build and check our calculators