# What is the binary answer?

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

- Page: https://www.acalculator.org/logic/binary-calculator
- JSON spec: https://www.acalculator.org/logic/binary-calculator.json
- Version: db1ec70730e6

## Default answer

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

## Inputs

| Key | Label | Description |
| --- | --- | --- |
| a | First binary number | The first number in binary: the digits 0 and 1, with an optional minus sign. |
| op | Operation | Add, subtract, multiply, divide (whole-number quotient and remainder), or the bitwise AND, OR, or XOR. |
| b | Second binary number | The second number in binary. |

## Outputs

| Key | Label | Description |
| --- | --- | --- |
| binary | Result in binary | The result in binary; for division, the whole-number quotient. |
| remainder | Remainder (binary) | For division: what is left over, A − quotient × B, in binary. |
| decimal | Result in decimal | The result as a decimal whole number. |
| hex | Result in hex | The result in hexadecimal (base 16), capital letters. |
| aDecimal | First number in decimal | The first number in decimal. |
| bDecimal | Second number in decimal | The second number 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.

## Assumptions

- 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.

## Worked examples

1. a = 1011, op = add, b = 110 gives binary = 10001, decimal = 17, hex = 11, aDecimal = 11, bDecimal = 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. a = 1001, op = add, b = 11011 gives binary = 100100, 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. a = 110, op = sub, b = 1011 gives binary = -101, 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. a = 1011, op = mul, b = 110 gives binary = 1000010, decimal = 66, 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. a = 1011, op = div, b = 110 gives binary = 1, remainder = 101, 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. a = 1100, op = xor, b = 1010 gives binary = 110, 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. a = 1100, op = and, b = 1010 gives binary = 1000, decimal = 8.
8. a = 1100, op = or, b = 1010 gives binary = 1110, decimal = 14.

## FAQ

### 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.

## Sources

- OpenStax, Contemporary Mathematics, §4.4 Addition and Subtraction in Base Systems, retrieved 2026-10-01. https://openstax.org/books/contemporary-mathematics/pages/4-4-addition-and-subtraction-in-base-systems
- OpenStax, Contemporary Mathematics, §4.5 Multiplication and Division in Base Systems, retrieved 2026-10-01. https://openstax.org/books/contemporary-mathematics/pages/4-5-multiplication-and-division-in-base-systems
