Binary Calculator
Add, subtract, multiply, divide, and AND/OR/XOR binary numbers, with results in binary, decimal, and hex
By Waqar Mushtaq · Last updated:
This binary calculator does arithmetic directly on binary numbers -- addition, subtraction, multiplication, and division with remainder -- plus the bitwise AND, OR, and XOR operations programmers use for masks and flags. Each input shows its decimal value as you type, so the calculator doubles as a quick binary-to-decimal converter, and the result comes back in binary, decimal, and hexadecimal. A column view lines the operands and result up bit by bit, and a table shows what every operation would give for the same two numbers, which is the fastest way to see how AND, OR, and XOR differ from each other and from ordinary arithmetic.
How Binary Arithmetic Works
O(n) for +, −, bitwise; O(n²) for × and ÷ in the number of bitsBinary addition: 1 + 1 writes 0 and carries 1 to the next column
Binary arithmetic follows the same column-by-column rules as decimal arithmetic, just with two digits instead of ten.
Addition -- 101101 + 1011 (45 + 11):
Line the numbers up on the right and add each column, carrying 1 whenever a column sums to 2 (10₂) or 3 (11₂):
101101 + 001011 = 111000 → 56
Subtraction borrows 2 from the next column instead of 10: 101101 − 1011 = 100010 (34).
Multiplication is shift-and-add: for every 1 bit in the second number, add a copy of the first number shifted left by that bit's position. 101101 × 1011 = 101101 + 1011010 + 101101000 = 111101111 (495).
Division is long division where each step's quotient digit is either 0 or 1. 101101 ÷ 1011 = 100 remainder 1 (45 ÷ 11 = 4 r 1). This calculator truncates toward zero, so −7 ÷ 2 = −3 remainder −1, matching most programming languages.
Bitwise operations compare the two numbers one bit position at a time, with no carrying:
- 101101 AND 001011 = 001001 (9) -- keeps bits set in both
- 101101 OR 001011 = 101111 (47) -- keeps bits set in either
- 101101 XOR 001011 = 100110 (38) -- keeps bits set in exactly one
All arithmetic uses arbitrary-precision integers, so 64-bit and larger values stay exact. Bitwise operations are limited to non-negative inputs, because for negative numbers the answer depends on the bit width they're stored in (see the Binary to Decimal Converter for two's complement).
Use Cases
Bit Masks and Flags
AND a value with a mask to test or clear bits, OR to set them, and XOR to toggle them. Seeing the operands and result lined up bit by bit makes it obvious which flags changed.
Digital Logic and Computer Architecture Courses
Check binary addition, subtraction, multiplication, and division homework -- the decimal equivalents shown under each input make it easy to confirm an answer independently.
Networking and Subnet Calculations
An IP address AND its subnet mask gives the network address. Enter both octets in binary to see the result one bit at a time.
Checksums and Simple Ciphers
XOR is the basis of parity bits, simple checksums, and one-time-pad style ciphers. XORing a value with the same key twice returns the original -- easy to verify here.
Frequently Asked Questions
How do you add binary numbers?
Add column by column from the right, just like decimal addition. 0 + 0 = 0, 0 + 1 = 1, 1 + 1 = 0 with a carry of 1, and 1 + 1 + a carried 1 = 1 with a carry of 1. For example, 1011 + 0110 = 10001 (11 + 6 = 17).
What is the difference between OR and XOR?
OR gives 1 when either bit is 1, including when both are. XOR (exclusive OR) gives 1 only when the bits are different, so 1 XOR 1 = 0. For 1100 and 1010: OR = 1110, XOR = 0110.
How does binary division handle remainders?
It works like integer long division: the quotient is the whole number of times the divisor fits, and the remainder is what's left over. 101101 ÷ 1011 is 100 with a remainder of 1. Fractional results aren't shown -- the remainder captures the leftover exactly.
Can I use negative binary numbers?
Yes, for addition, subtraction, multiplication, and division -- put a minus sign in front (for example −101). Results can also come out negative. Bitwise AND, OR, and XOR require non-negative inputs, since their result on negative numbers depends on a fixed bit width and representation such as two's complement.
Is there a size limit?
No practical one. The calculator uses arbitrary-precision integers (BigInt), so values wider than 64 bits are calculated exactly rather than being rounded the way standard floating-point numbers would be.
Methodology
The formula above is implemented as a standalone module covered by unit tests, so its worked examples are re-checked on every change to the site. It is verified against the authoritative sources listed below.
Maintained by Waqar Mushtaq. Spotted a result that looks wrong? Report it and it becomes a failing test.