Binary Calculator

Enter two binary numbers and an operation. Arithmetic is exact for numbers up to 256 bits, and every answer is also shown in decimal and hex.

Also called: Base-2 calculator

  • Last updated
  • Formula tested against reference values

Your numbers

Result

Result (binary)
—

Calculating…

Result in decimal
—
Result in hexadecimal
—
Remainder (division only)
—
First number in decimal
—
Second number in decimal
—

How to use this calculator

  1. Enter or choose first binary number.
  2. Enter or choose operation.
  3. Enter or choose second binary number.
  4. The result (binary) updates as you type. Use Copy result or Share to keep it.

Method

Value = Σ dᵢ × 2ⁱ (digits dᵢ = 0 or 1, i counted from 0 at the right); the operation is done on the exact integers and converted back to base 2

dᵢ
the binary digit (bit) in position i

Worked example

  1. 1011 = 8 + 2 + 1 = 11 and 110 = 4 + 2 = 6.
  2. 11 + 6 = 17 = 16 + 1, which is 10001 in binary.
  3. In hexadecimal 17 = 1 × 16 + 1 = 0x11.

1011 + 110 = 10001 in binary, which is 11 + 6 = 17 in decimal.

What the result means

Bitwise AND keeps a 1 only where both numbers have one, OR where either has one, and XOR where exactly one has one: the basis of masks and flags in programming.

Assumptions and limits

  • Inputs are unsigned (non-negative) binary integers; a 0b prefix is accepted.
  • Negative results are shown with a minus sign, not in two’s complement.
  • Division gives a whole-number quotient and a remainder; binary fractions are not supported.

Questions

How do I convert binary to decimal by hand?

Write the powers of 2 under the digits from the right (1, 2, 4, 8, …) and add the ones under a 1. For 1011: 8 + 0 + 2 + 1 = 11.

Why does a computer use binary?

Electronic circuits reliably distinguish two states, on and off, so every number is stored as a pattern of bits.