Binary Calculator
This binary calculator adds, subtracts, multiplies and divides binary numbers and runs AND, OR, XOR, NOT and bit shifts. Results appear in binary, decimal and hex, with the working shown.
Negative numbers work too: type a minus sign, as in -101. The bit width is used by NOT and by the two's complement row.
| Binary | | |
|---|---|---|
| Decimal | | |
| Hex | | |
| Two's complement | |
| Binary | | |
|---|---|---|
| Decimal | | |
| Hex | |
Show steps
The top row shows the carries. In binary 1 + 1 = 10, so you write 0 and carry 1 to the next column on the left.
Every 1 bit in B adds a copy of A, shifted left by that bit's position. The shifted copies are then added up.
Check: A = B × quotient + remainder. Integer division rounds toward zero, and the remainder has the same sign as A.
Bitwise operations compare the numbers one column at a time. Negative numbers are written in two's complement at the selected bit width.
Each shift to the left multiplies by 2. Each shift to the right divides by 2 and rounds down.
Calculate with Binary Numbers Online
Binary arithmetic follows the same rules as decimal, but with only two digits it is easy to lose track of carries and borrows. This calculator does the sums for numbers of any length and shows the working.
It also handles the bitwise operations programmers use every day: AND, OR, XOR, NOT and shifts, with input in binary, decimal or hex.
How to use the binary calculator
- Choose the input format: binary, decimal or hex.
- Enter A, pick an operation and enter B. For shifts, B is the number of places. NOT only uses A.
- Read the result in binary, decimal and hex. Division also shows the remainder.
Binary addition
There are only four rules, plus one for a carried 1:
| Sum | Result | Carry |
|---|---|---|
| 0 + 0 | 0 | 0 |
| 0 + 1 | 1 | 0 |
| 1 + 1 | 10 (0, carry 1) | 1 |
| 1 + 1 + 1 | 11 (1, carry 1) | 1 |
Example: 1011 + 110 = 10001, which is 11 + 6 = 17. Work from the right: 1 + 0 = 1; 1 + 1 = 10, write 0 carry 1; 0 + 1 + 1 = 10, write 0 carry 1; 1 + 1 = 10.
Subtraction, multiplication and division
- Subtraction: 1 − 1 = 0, 1 − 0 = 1, and 0 − 1 needs a borrow from the next column.
1101 − 110 = 111(13 − 6 = 7). If B is larger, the result is negative. - Multiplication: for every 1 in B, add a copy of A shifted left.
101 × 11= 101 + 1010 =1111(5 × 3 = 15). - Division: the calculator gives a whole-number quotient and a remainder.
1101 ÷ 11 = 100remainder1(13 ÷ 3 = 4 r 1).
Bitwise operations: AND, OR, XOR, NOT
Bitwise operations work on each column separately, with no carries:
| A | B | A AND B | A OR B | A XOR B |
|---|---|---|---|---|
| 0 | 0 | 0 | 0 | 0 |
| 0 | 1 | 0 | 1 | 1 |
| 1 | 0 | 0 | 1 | 1 |
| 1 | 1 | 1 | 1 | 0 |
With A = 1100 and B = 1010: AND gives 1000, OR gives 1110 and XOR gives 0110. NOT flips every bit within the chosen width, so in 8 bits NOT 00001010 is 11110101, which is 245 unsigned or -11 signed.
Bit shifts
A left shift moves every bit one place to the left and adds a 0 on the right, which multiplies by 2. 1011 << 2 is 101100, so 11 × 4 = 44. A right shift drops the rightmost bits, dividing by 2 and rounding down: 1011 >> 1 is 101 (5).
Where binary arithmetic is used
- Subnetting: an IP address AND its mask gives the network. 130 AND 192 is
10000010AND11000000=10000000, so 192.168.1.130 with mask 255.255.255.192 is in network 192.168.1.128. - Flags: OR sets a bit, AND with a mask tests it, and XOR toggles it.
- Overflow: in 8 bits,
11111111 + 1needs a ninth bit, so fixed-width hardware keeps00000000. To convert single numbers, use binary to decimal.
Frequently Asked Questions
Common questions about binary arithmetic and bitwise operations.
Add column by column from the right. 1 + 1 is 10, so write 0 and carry 1. 1011 + 110 = 10001.
Work from the right and borrow from the next column when you need 0 − 1. Computers instead add the two's complement of B.
1 + 1 = 10 in binary, which is 2 in decimal.
Yes. Type a minus sign before a number. Negative results get a minus sign, and the two's complement row shows their bit pattern.
Division by zero has no answer, so the calculator shows a message and asks for another value of B.
OR gives 1 when either bit is 1. XOR gives 1 only when the bits are different, so 1 XOR 1 is 0.
NOT flips every bit, including leading zeros, so the width decides the answer: NOT 1010 is 11110101 in 8 bits.