Binary Calculator
Perform binary arithmetic and bitwise operations — add, subtract, multiply, divide, AND, OR, XOR — with results shown in binary, decimal, and hex.
Result (a + b)
0b1111
- Decimal
- 15
- Hexadecimal
- 0xF
- A in decimal
- 10
- B in decimal
- 5
How to use this calculator
Type two binary numbers (using only the digits 0 and 1) into the A and B fields. Pick an operation — arithmetic (+, −, ×, ÷) or bitwise (AND, OR, XOR). The calculator shows the result in binary, decimal, and hexadecimal, along with the decimal value of each input so you can verify the answer.
How the calculation works
Binary arithmetic follows the same rules as decimal arithmetic, except each column "rolls over" at 2 instead of 10. Addition: 1 + 1 = 10 (carry the 1). Subtraction borrows the same way: 10 − 1 = 1. Multiplication is repeated addition. Bitwise operations work column-by-column: AND outputs 1 only where both bits are 1; OR outputs 1 where either bit is 1; XOR outputs 1 where the bits differ. Division here is integer division — the fractional remainder is discarded.
Worked example
Take 1010 + 0101. In decimal that is 10 + 5 = 15. In binary, line them up and add column by column: 0+1=1, 1+0=1, 0+1=1, 1+0=1, giving 1111 — which is indeed decimal 15. For bitwise AND on the same inputs (1010 AND 0101), no column has 1s in both numbers, so the result is 0000 (decimal 0).
Frequently asked questions
What is binary?
Binary (base 2) is the number system computers use internally. Every value is stored as a sequence of bits — binary digits, each either 0 or 1. A single bit holds one piece of true/false information. Eight bits form a byte, which can represent values 0–255. Binary works for circuits because transistors naturally hold one of two states (on/off, high/low voltage).
How do you add binary numbers?
Add column by column from right to left, the same way you add decimal numbers — but rolling over at 2 instead of 10. The rules are: 0+0=0, 0+1=1, 1+0=1, and 1+1=10 (write 0, carry 1 to the next column). For example, 11 + 01 = 100: rightmost column 1+1=10 (write 0, carry 1); next column 1+0+1=10 (write 0, carry 1); leftmost column 0+0+1=1. Result: 100, which is decimal 4.
How do you subtract binary numbers?
Subtract column by column, borrowing from the next-higher column when needed (just like decimal subtraction). The rules are: 0−0=0, 1−0=1, 1−1=0, and 0−1=1 with a borrow from the next column. For example, 110 − 011 = 011: rightmost 0−1 borrows to give 10−1=1 (next column owes 1); middle 1−1−1 borrows to give 11−1−1=1; leftmost 1−1−0=0. Result: 011, which is decimal 3.
What is the difference between AND, OR, and XOR?
These are bitwise operations that compare two bits in the same column and return a single bit. AND returns 1 only when both bits are 1 (else 0). OR returns 1 when either bit is 1 (else 0). XOR (exclusive OR) returns 1 only when the bits differ — exactly one is 1 (else 0). So 1100 AND 1010 = 1000, 1100 OR 1010 = 1110, and 1100 XOR 1010 = 0110. These operations are fundamental in low-level programming: masking, flag-setting, and cryptography all rely on them.
Why does this calculator do integer division?
Binary division can produce a fractional result, but fractions in binary become repeating expansions (similar to 1/3 = 0.333… in decimal), which are messy to display. This calculator returns the integer quotient (the whole-number part of the division, truncated toward zero), which is what most low-level binary contexts — CPU instructions, integer arithmetic in code — actually compute. For 1100 ÷ 11 (decimal 12 ÷ 3), the answer is 100 (decimal 4); for 1101 ÷ 11 (decimal 13 ÷ 3), the integer answer is also 100 (decimal 4), with the remainder discarded.
Can this calculator handle negative binary numbers?
Inputs are unsigned (positive only) — you cannot type a minus sign or a two's-complement form. However, the result of a subtraction can be negative: 0101 − 1010 (decimal 5 − 10) gives −5, which the calculator displays as -101. Bitwise operations return non-negative results when both inputs are non-negative.