Binary Calculator – Arithmetic and Bitwise Operations
What can this binary calculator do?
How to add two binary numbers manually?
Binary addition works column by column from right to left, exactly like decimal addition, but with only two digits. There are four possible cases per column:
| Bit A | Bit B | Carry in | Sum bit | Carry out |
|---|---|---|---|---|
| 0 | 0 | 0 | 0 | 0 |
| 1 | 0 | 0 | 1 | 0 |
| 0 | 1 | 0 | 1 | 0 |
| 1 | 1 | 0 | 0 | 1 |
| 0 | 0 | 1 | 1 | 0 |
| 1 | 0 | 1 | 0 | 1 |
| 0 | 1 | 1 | 0 | 1 |
| 1 | 1 | 1 | 1 | 1 |
Worked example: 1011 + 0110 (11 + 6 = 17)
| Column | A bit | B bit | Carry in | Sum bit | Carry out |
|---|---|---|---|---|---|
| 0 (rightmost) | 1 | 0 | 0 | 1 | 0 |
| 1 | 1 | 1 | 0 | 0 | 1 |
| 2 | 0 | 1 | 1 | 0 | 1 |
| 3 (leftmost) | 1 | 0 | 1 | 0 | 1 |
| 4 (overflow) | — | — | 1 | 1 | 0 |
Reading the sum bits bottom-up (column 4 → 0): 10001 = 16 + 1 = 17 ✓. The carry that overflows the original bit-width becomes the most significant bit of the result.
How do AND, OR, and XOR work bit by bit?
Bitwise operations compare the two inputs one bit at a time at each position. The truth table below shows the output for every combination of input bits:
| 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 |
Example: 1100 AND/OR/XOR 1010
| Bit position | A | B | AND | OR | XOR |
|---|---|---|---|---|---|
| 3 | 1 | 1 | 1 | 1 | 0 |
| 2 | 1 | 0 | 0 | 1 | 1 |
| 1 | 0 | 1 | 0 | 1 | 1 |
| 0 | 0 | 0 | 0 | 0 | 0 |
Results: AND = 1000, OR = 1110, XOR = 0110. Common uses: AND to mask (isolate) specific bits, OR to set bits, XOR to toggle bits or compare two values for differences.
How does NOT work?
NOT is a unary operation that takes a single input and flips every bit: 0 becomes 1, 1 becomes 0. The result always has the same number of bits as the input.
| Input bit | NOT output |
|---|---|
| 0 | 1 |
| 1 | 0 |
Example: NOT 10110100 = 01001011. Each bit is individually flipped, position by position.
Note: this tool computes NOT within the natural bit-width of your input. NOT of 1010 (4 bits) is 0101, not 11110101 (8 bits). If you need a fixed-width NOT (e.g. 8-bit or 32-bit), pad the input with leading zeros before applying NOT.
How do left shift and right shift work?
Shift operations move every bit in the number left or right by a given number of positions. They are the fastest way to multiply or divide by powers of 2.
Left shift (<<): multiply by 2ⁿ
| Operation | Binary | Decimal |
|---|---|---|
| Original | 0000 0011 | 3 |
| << 1 | 0000 0110 | 6 (×2) |
| << 2 | 0000 1100 | 12 (×4) |
| << 3 | 0001 1000 | 24 (×8) |
Right shift (>>): integer divide by 2ⁿ
| Operation | Binary | Decimal |
|---|---|---|
| Original | 0010 0100 | 36 |
| >> 1 | 0001 0010 | 18 (÷2) |
| >> 2 | 0000 1001 | 9 (÷4) |
| >> 3 | 0000 0100 | 4 (÷8, truncated) |
Bits shifted off the end are discarded; right shift truncates toward zero rather than rounding. Shifting left by n positions is identical to multiplying by 2ⁿ as long as no significant bits are lost off the left edge.
What input format is accepted?
0 and 1. The tool does not require a 0b prefix. Enter the raw bit pattern, for example 1101 for decimal 13.