acalculator

What is the binary answer?

Type two binary numbers and pick an operation. The answer shows in binary, decimal, and hex as you type, at any size and with no rounding.

Your numbers

Operation
Result in binary
10001

1011 + 110 = 10001 in binary (17 in decimal).

Result in decimal
17
Result in hex
11
First number in decimal
11
Second number in decimal
6

Result in binary: 10001. 1011 + 110 = 10001 in binary (17 in decimal).

How to calculate

Adds, subtracts, multiplies, divides, ANDs, ORs, or XORs two binary numbers exactly at any size, with the result in binary, decimal, and hex.

Example with the default inputs (First binary number 1011, Operation +, Second binary number 110): 1011 + 110 = 10001 in binary (17 in decimal).

Method: Each binary number is read in base 2 (digit × 2ⁿ), the whole numbers are combined exactly, and the result is written back in base 2 and base 16.

  • Numbers are whole (no binary point) and may be negative; a minus sign is written in front, not as two’s complement.
  • Division gives the whole-number quotient rounded toward zero and the remainder, A − quotient × B, which has the sign of A.
  • AND, OR, and XOR compare the numbers bit by bit and take numbers of 0 or more only.
  • Numbers may have up to 200 characters; a 0b prefix, spaces, and underscores are ignored.

Machine-readable copies: Markdown, JSON.

Worked examples

Each example is checked against the calculator on every build.

  1. First binary number 1011, Operation +, Second binary number 110 gives Result in binary 10001, Result in decimal 17, Result in hex 11, First number in decimal 11, Second number in decimal 6.Source: OpenStax, Contemporary Mathematics, §4.4 Addition and Subtraction in Base Systems (base 2 addition table: 1 + 1 = 10). https://openstax.org/books/contemporary-mathematics/pages/4-4-addition-and-subtraction-in-base-systems
  2. First binary number 1001, Operation +, Second binary number 11011 gives Result in binary 100100, Result in decimal 36.Source: OpenStax, Contemporary Mathematics, §4.4 Addition and Subtraction in Base Systems, Example 4.33: 1001 + 11011 = 100100 (base 2). https://openstax.org/books/contemporary-mathematics/pages/4-4-addition-and-subtraction-in-base-systems
  3. First binary number 110, Operation −, Second binary number 1011 gives Result in binary -101, Result in decimal -5.Source: OpenStax, Contemporary Mathematics, §4.4 Addition and Subtraction in Base Systems. https://openstax.org/books/contemporary-mathematics/pages/4-4-addition-and-subtraction-in-base-systems
  4. First binary number 1011, Operation ×, Second binary number 110 gives Result in binary 1000010, Result in decimal 66, Result in hex 42.Source: OpenStax, Contemporary Mathematics, §4.5 Multiplication and Division in Base Systems. https://openstax.org/books/contemporary-mathematics/pages/4-5-multiplication-and-division-in-base-systems
  5. First binary number 1011, Operation ÷, Second binary number 110 gives Result in binary 1, Remainder (binary) 101, Result in decimal 1.Source: OpenStax, Contemporary Mathematics, §4.5 Multiplication and Division in Base Systems. https://openstax.org/books/contemporary-mathematics/pages/4-5-multiplication-and-division-in-base-systems
  6. First binary number 1100, Operation XOR, Second binary number 1010 gives Result in binary 110, Result in decimal 6.Source: OpenStax, Contemporary Mathematics, §4.4 Addition and Subtraction in Base Systems (binary place values). https://openstax.org/books/contemporary-mathematics/pages/4-4-addition-and-subtraction-in-base-systems
  7. First binary number 1100, Operation AND, Second binary number 1010 gives Result in binary 1000, Result in decimal 8.
  8. First binary number 1100, Operation OR, Second binary number 1010 gives Result in binary 1110, Result in decimal 14.

How it works

A binary number is written in base 2: each digit is 0 or 1, and each place is worth twice the place to its right (1, 2, 4, 8, 16, …). The calculator reads each number as a whole number, does the operation exactly, and writes the result back in binary and in hex (base 16, digits 0 to 9 and A to F).

  • Add, subtract, multiply: the exact sum, difference, or product.
  • Divide: the whole-number quotient, rounded toward zero, and the remainder r = A − quotient × B. The remainder has the sign of A: −1011 ÷ 110 is −1 with remainder −101.
  • AND, OR, XOR: the numbers are lined up from the right, with 0s added on the left of the shorter one, and each pair of bits is combined. AND is 1 when both bits are 1; OR is 1 when at least one is 1; XOR is 1 when exactly one is 1. Leading 0s of the result are dropped.

Rules

  • Each number may have up to 200 characters. Only the digits 0 and 1 count; a minus sign in front, a 0b prefix, spaces, and underscores are allowed. Any other character gives a message instead of an answer.
  • A negative number is written with a minus sign, not in two’s complement.
  • Dividing by 0 has no answer, and the page says so.
  • AND, OR, and XOR take numbers of 0 or more only; with a minus sign they have no answer, and the page says so.

Worked examples by hand

1011 + 110. From the right: 1 + 0 = 1; 1 + 1 = 10, write 0 and carry 1; 0 + 1 + 1 = 10, write 0 and carry 1; 1 + 1 = 10. The result is 10001. In decimal: 11 + 6 = 17, and 10001 = 16 + 1 = 17. In hex: 17 = 11.

1001 + 11011. 9 + 27 = 36 = 32 + 4 = 100100 (OpenStax Example 4.33).

110 − 1011. 6 − 11 = −5, and 5 = 4 + 1 = 101, so the result is −101.

1011 × 110. 1011 × 110 = 1011 × 100 + 1011 × 10 = 101100 + 10110 = 1000010. In decimal: 11 × 6 = 66 = 64 + 2. In hex: 66 = 4 × 16 + 2 = 42.

1011 ÷ 110. 11 = 1 × 6 + 5: quotient 1, remainder 101.

1100 XOR 1010. Bit by bit: 1 and 1 give 0, 1 and 0 give 1, 0 and 1 give 1, 0 and 0 give 0: 0110, written 110 (6).

1100 AND 1010 = 1000 (8), and 1100 OR 1010 = 1110 (14), bit by bit.

Other questions people ask

How do you add binary numbers?

Add column by column from the right, as in decimal, using 0 + 0 = 0, 0 + 1 = 1, and 1 + 1 = 10 (write 0, carry 1). For example, 1011 + 110 = 10001, which is 11 + 6 = 17.

How do you subtract binary numbers?

Subtract column by column from the right and borrow 2 from the next column when the top digit is smaller. If the second number is bigger, subtract the other way and put a minus sign in front, so 110 − 1011 = −101 (6 − 11 = −5).

How does binary division work here?

It gives the whole-number quotient and the remainder, as in long division. 1011 ÷ 110 is 1 with remainder 101, because 11 = 1 × 6 + 5. You cannot divide by 0.

What do AND, OR, and XOR do?

They compare the two numbers bit by bit, lined up from the right. AND gives 1 where both bits are 1, OR where either is 1, and XOR where exactly one is 1. So 1100 AND 1010 = 1000, OR = 1110, and XOR = 110.

How do I convert a binary number to decimal?

Multiply each digit by its place value, 1, 2, 4, 8, 16 and so on from the right, and add. 1011 is 8 + 0 + 2 + 1 = 11. The result panel shows both numbers you typed in decimal.

Why is a negative result shown with a minus sign?

The calculator works with whole numbers of any size, so a negative result is written as a minus sign and the binary digits, like −101 for −5. Computers store negative numbers in two’s complement, which needs a fixed number of bits; this page does not assume one.

How big can the numbers be?

Up to 200 characters each. The arithmetic is exact, so even numbers far longer than 64 bits give the exact answer.