Binary Calculator

Enter two binary numbers and choose an operation.

Operation

AND, OR and XOR compare the numbers digit by digit.

Only the digits 0 and 1; a leading minus sign is allowed.

Only the digits 0 and 1; a leading minus sign is allowed.

Try

Result

You entered1102 − 10112\mathrm{110}_{2}\ -\ \mathrm{1011}_{2}

1102 − 10112=−1012\displaystyle \mathrm{110}_{2}\ -\ \mathrm{1011}_{2} = -\mathrm{101}_{2}

Decimal

6−11=−5\displaystyle 6 - 11 = -5

Hex

−516\displaystyle -\mathrm{5}_{16}
Show the work
  1. Binary to decimal

    Each binary digit is worth a power of 22, counting from 00 at the right. Converting both numbers to decimal lets the operation be done with ordinary arithmetic.

    Using N=dk 2k+⋯+d1 2+d0N = d_{k}\,2^{k} + \cdots + d_{1}\,2 + d_{0}

    1102=1×22+1×21+0×20=4+2+0=610112=1×23+0×22+1×21+1×20=8+0+2+1=11\begin{gathered} \mathrm{110}_{2} = 1 \times 2^{2} + 1 \times 2^{1} + 0 \times 2^{0} = 4 + 2 + 0 = 6 \\ \mathrm{1011}_{2} = 1 \times 2^{3} + 0 \times 2^{2} + 1 \times 2^{1} + 1 \times 2^{0} = 8 + 0 + 2 + 1 = 11 \end{gathered}
  2. Subtraction in decimal

    The second number is larger, so the difference is negative: it is the difference of the sizes with a minus sign.

    6−11=−56 - 11 = -5
  3. Decimal to binary

    Divide by 22 again and again, keeping each remainder, until the quotient is 00. The remainders read from the last to the first are the binary digits, with the minus sign put back in front.

    Using N=2×q+r,r=0 or 1N = 2 \times q + r, \quad r = 0 \text{ or } 1

    5=2×2+12=2×1+01=2×0+1\begin{array}{l} 5 = 2 \times 2 + 1 \\ 2 = 2 \times 1 + 0 \\ 1 = 2 \times 0 + 1 \end{array}
  4. Result

    So 1102 − 10112=−1012\mathrm{110}_{2}\ -\ \mathrm{1011}_{2} = -\mathrm{101}_{2}.

Worked examples

10112 + 1102\mathrm{1011}_{2}\ +\ \mathrm{110}_{2}
10112 + 1102=100012\mathrm{1011}_{2}\ +\ \mathrm{110}_{2} = \mathrm{10001}_{2}

Binary addition with carries, Check in decimal

10112 − 1102\mathrm{1011}_{2}\ -\ \mathrm{110}_{2}
10112 − 1102=1012\mathrm{1011}_{2}\ -\ \mathrm{110}_{2} = \mathrm{101}_{2}

Binary to decimal, Subtraction in decimal

1102 − 10112\mathrm{110}_{2}\ -\ \mathrm{1011}_{2}
1102 − 10112=−1012\mathrm{110}_{2}\ -\ \mathrm{1011}_{2} = -\mathrm{101}_{2}

Binary to decimal, Subtraction in decimal

10112 × 1102\mathrm{1011}_{2}\ \times\ \mathrm{110}_{2}
10112 × 1102=10000102\mathrm{1011}_{2}\ \times\ \mathrm{110}_{2} = \mathrm{1000010}_{2}

Binary to decimal, Multiplication in decimal

10112 ÷ 1102\mathrm{1011}_{2}\ \div\ \mathrm{110}_{2}
10112 ÷ 1102=12 remainder 1012\mathrm{1011}_{2}\ \div\ \mathrm{110}_{2} = \mathrm{1}_{2}\ \text{remainder}\ \mathrm{101}_{2}

Binary to decimal, Division with a remainder

10112 AND 1102\mathrm{1011}_{2}\ \mathrm{AND}\ \mathrm{110}_{2}
10112 AND 1102=102\mathrm{1011}_{2}\ \mathrm{AND}\ \mathrm{110}_{2} = \mathrm{10}_{2}

Binary to decimal, Bitwise AND

10112 OR 1102\mathrm{1011}_{2}\ \mathrm{OR}\ \mathrm{110}_{2}
10112 OR 1102=11112\mathrm{1011}_{2}\ \mathrm{OR}\ \mathrm{110}_{2} = \mathrm{1111}_{2}

Binary to decimal, Bitwise OR

10112 XOR 1102\mathrm{1011}_{2}\ \mathrm{XOR}\ \mathrm{110}_{2}
10112 XOR 1102=11012\mathrm{1011}_{2}\ \mathrm{XOR}\ \mathrm{110}_{2} = \mathrm{1101}_{2}

Binary to decimal, Bitwise XOR