Skip to content

Binary Calculator: Binary Arithmetic and Bitwise Operations

Add, subtract, multiply and divide binary numbers, and run AND, OR, XOR, NOT and bit shifts, with results in binary, decimal, hex and octal. Methods explained.

4 min read

Binary is the language of computers: every number, letter and image is stored as a pattern of 0s and 1s. Doing arithmetic and logic on binary numbers is a core skill in computer science, electronics and low-level programming. Our binary calculator handles the four arithmetic operations and the standard bitwise operations, and shows every answer in binary, decimal, hex and octal. This guide explains how each operation works.

How to use the calculator

  1. First number: a binary number, such as 1011.
  2. Operation: +, −, ×, ÷, AND, OR, XOR, NOT (first number only), << (shift left) or >> (shift right).
  3. Second number: another binary number.

The default, 1011 + 110, gives 10001, which is 17 in decimal, 11 in hex and 21 in octal.

Binary place value

Each binary digit (bit) is worth a power of 2, doubling from right to left: 1, 2, 4, 8, 16 and so on.

1011 = 8 + 0 + 2 + 1 = 11, and 110 = 4 + 2 + 0 = 6. So 1011 + 110 is 11 + 6 = 17.

The binary and hex converter converts between bases without doing arithmetic.

Binary addition

The rules are simple:

SumResultCarry
0 + 000
0 + 110
1 + 101
1 + 1 + 111

1011 + 110, from right to left:

  1. 1 + 0 = 1.
  2. 1 + 1 = 0, carry 1.
  3. 0 + 1 + carry 1 = 0, carry 1.
  4. 1 + carry 1 = 0, carry 1.
  5. Bring down the carry: 1.

Result: 10001.

Subtraction, multiplication and division

Subtraction works like decimal, borrowing 2 instead of 10. Computers usually subtract by adding the two's complement of the second number.

Multiplication is easier than in decimal, because each digit is 0 or 1: write the first number shifted once for each 1 in the second, then add. 1011 × 110 = 10110 + 101100 = 1000010 (11 × 6 = 66).

Division uses long division with only two possible digits per step. The calculator gives the quotient and remainder.

Bitwise operations

Bitwise operations compare numbers bit by bit. Using 1100 (12) and 1010 (10):

OperationRuleResult
AND1 only if both bits are 11000 (8)
OR1 if either bit is 11110 (14)
XOR1 if the bits differ0110 (6)
NOT 1100Flip every bit (8-bit)11110011 (243)

Where they are used:

  • AND masks bits, keeping only the ones you want. Subnet masks in networking work this way; see the IP subnet calculator.
  • OR sets bits, such as turning on permission flags.
  • XOR toggles bits and is the basis of simple encryption and checksums. XORing twice with the same key restores the original.
  • NOT inverts every bit. The calculator pads to a whole number of bytes so the result is clear.

Bit shifts

  • Shift left (<<) moves every bit left and fills with zeros. Each shift doubles the number. 1011 << 10 (shift by 2) = 101100, which is 11 × 4 = 44.
  • Shift right (>>) moves bits right, dropping the rightmost. Each shift halves the number, rounding down.

Shifts are a fast way for processors to multiply and divide by powers of 2.

Reading the results

The calculator shows the result in four bases:

  • Binary: the raw bit pattern.
  • Decimal: the everyday value.
  • Hex: four bits per digit, the usual shorthand in programming. The hex calculator does arithmetic directly in base 16.
  • Octal: three bits per digit, used in Unix file permissions.

Tips

  • Group long binary numbers in fours (1010 1100) to read them easily.
  • Leading zeros do not change the value: 0011 is the same as 11.
  • Remember that 8 bits make a byte, holding values from 0 to 255. Powers of 2, covered by the exponent calculator, set the range of any bit width.

Frequently asked questions

Why does 1 + 1 equal 10 in binary?

Binary only has the digits 0 and 1. Two is written as 10, just as ten is written as 10 in decimal: one group of the base and nothing left over.

What is the difference between OR and XOR?

OR gives 1 if either or both bits are 1. XOR gives 1 only when the bits are different, so 1 XOR 1 is 0.

How are negative numbers stored in binary?

Most computers use two's complement: flip all the bits and add 1. The calculator shows negative results with a minus sign for clarity.

What does shifting left by one do?

It doubles the number, just as adding a zero in decimal multiplies by ten.

Share

Try it yourself

Run your own numbers with our free tool: Binary calculator. No sign-up, and it works on any device.

Open the calculator