Skip to content
CalcSpectrum

Binary Calculator

Add, subtract, multiply, or divide binary numbers, or apply AND/OR/XOR, with results in binary, decimal, and hexadecimal.

Free to use · Instant results
Loading calculator…

How It's Calculated

Formula

\text{result} = \text{binary}_A \;\text{op}\; \text{binary}_B

Binary is base-2: every digit is a power of 2, using only 0 and 1. This calculator converts both binary inputs to decimal, applies the chosen operation, and converts the result back to binary (and hexadecimal, for convenience). Arithmetic operations (add, subtract, multiply, integer divide) work exactly like their decimal equivalents once the values are converted. Bitwise operations (AND, OR, XOR) instead compare the two numbers digit by digit: AND keeps a 1 only where both inputs have a 1, OR keeps a 1 where either input has a 1, and XOR keeps a 1 only where the inputs differ. Each binary input must contain only 0s and 1s. Arithmetic inputs are limited to 52 digits to stay within JavaScript's exact-integer range; bitwise inputs are limited to 31 digits because bitwise operators work on 32-bit integers. Subtraction that produces a negative result is shown with a leading minus sign.

Worked Examples

Adding two binary numbers: 1010 + 0110

  1. 1010 in decimal = 10
  2. 0110 in decimal = 6
  3. 10 + 6 = 16
  4. 16 in binary = 10000

Bitwise AND: 1100 AND 1010

  1. Compare each digit position: 1&1=1, 1&0=0, 0&1=0, 0&0=0
  2. Result: 1000

Frequently Asked Questions

What happens if I divide by binary 0?

Division by zero is undefined, so this calculator rejects a divisor of 0 rather than returning an invalid result. Divide uses integer (truncating) division, matching how whole binary values are typically compared.

How is a negative result shown in binary?

Subtraction can produce a negative decimal value. Rather than using two's-complement bit patterns (which depend on a fixed bit width), this calculator shows negative results as a minus sign followed by the binary representation of the absolute value, e.g. -1000 for -8.

Why is there a digit-length limit?

Arithmetic results are kept within JavaScript's exact safe-integer range (up to 2^53), so arithmetic inputs are capped at 52 binary digits. Bitwise operators (AND, OR, XOR) work on 32-bit integers in JavaScript, so bitwise inputs are capped at 31 digits to avoid silent truncation.

What's the difference between AND, OR, and XOR?

AND returns 1 only when both bits are 1. OR returns 1 when at least one bit is 1. XOR (exclusive or) returns 1 only when the bits are different from each other. All three compare the two binary numbers one digit position at a time.