Binary Addition Calculator
Add two binary numbers online. Type two binary numbers — only 0s and 1s — and the sum appears live in every base, with the carry rules below.
Add Binary Numbers
Full calculator (all bases, all operations) → · How to convert binary to decimal →
How to add binary numbers
- Line up the numbers. Write the two binary numbers right-aligned, one above the other.
- Add right to left. Add each column from right to left.
- Carry when the sum is 2 or more. 1 + 1 = 0 carry 1. 1 + 1 + 1 = 1 carry 1. Carry the 1 into the next column.
- Write any final carry. If a carry remains after the leftmost column, it becomes a new leftmost 1.
Binary addition rules
| Column | Result bit | Carry |
|---|---|---|
| 0 + 0 | 0 | 0 |
| 0 + 1 | 1 | 0 |
| 1 + 0 | 1 | 0 |
| 1 + 1 | 0 | 1 |
| 1 + 1 + 1 (with carry) | 1 | 1 |
Worked example: 1010₂ + 1011₂ = 10101₂
| Column (right to left) | A | B | Carry in | Sum | Carry out |
|---|---|---|---|---|---|
| 1st | 0 | 1 | 0 | 1 | 0 |
| 2nd | 1 | 1 | 0 | 0 | 1 |
| 3rd | 0 | 0 | 1 | 1 | 0 |
| 4th | 1 | 1 | 0 | 0 | 1 |
| 5th | — | — | 1 | 1 | 0 |
Read the Sum column bottom to top: 1 0 1 0 1. Check in decimal: 10 + 11 = 21, and 10101₂ in binary is 21₁₀.
How to add binary numbers in code
Python
def add_binary(a, b):
return bin(int(a, 2) + int(b, 2))[2:]
print(add_binary("1010", "1011")) # 10101 Java
// Shortcut
String sum = Integer.toBinaryString(
Integer.parseInt("1010", 2) + Integer.parseInt("1011", 2)
); // "10101" C
#include <stdio.h>
#include <string.h>
int binaryToInt(const char *bits) {
int result = 0;
for (size_t i = 0; i < strlen(bits); i++)
result = result * 2 + (bits[i] - '0');
return result;
}
void printBinary(int n) {
if (n == 0) { printf("0"); return; }
char bits[64]; int i = 0;
while (n > 0) { bits[i++] = (n % 2) + '0'; n /= 2; }
for (int j = i - 1; j >= 0; j--) putchar(bits[j]);
}
int main(void) {
int sum = binaryToInt("1010") + binaryToInt("1011");
printBinary(sum); // prints 10101
return 0;
} These snippets assume valid binary input (only 0s and 1s). RadixFlip rejects other digits for you — a 2 typed in a binary box simply isn't entered.
Frequently asked questions
How do I add binary numbers?
Line up the numbers on the right, then add column by column from right to left. Use the rules 0 + 0 = 0, 0 + 1 = 1, 1 + 0 = 1, 1 + 1 = 0 carry 1, and 1 + 1 + 1 (with a carry) = 1 carry 1. The final carry becomes the leftmost digit. Example: 1010 + 1011 = 10101.
What is 1010 + 1011 in binary?
1010 + 1011 = 10101 in binary, which is 21 in decimal. Check: 1010 is 10, 1011 is 11, and 10 + 11 = 21.
What are the binary addition rules?
0 + 0 = 0 (no carry), 0 + 1 = 1, 1 + 0 = 1, 1 + 1 = 0 carry 1, and 1 + 1 + 1 with an incoming carry = 1 carry 1. Every column produces one result bit plus a carry of 0 or 1 into the next column.
How do I add binary numbers with carry?
When a column sums to 2 or more, write down the remainder and carry 1. 1 + 1 = 0 carry 1. 1 + 1 + 1 = 1 carry 1. Carry the 1 into the next column to the left, and keep going. If a carry remains after the leftmost column, it becomes a new leftmost 1 — that is why 1010 + 1011 gives a 5-bit answer.
How do I add binary numbers in Python?
Use int(a, 2) + int(b, 2), then bin(result)[2:]. Example: bin(int("1010", 2) + int("1011", 2))[2:] gives "10101".
How do I add binary numbers in Java and C?
Java: Integer.toBinaryString(Integer.parseInt("1010", 2) + Integer.parseInt("1011", 2)) gives "10101". C: convert each binary string to an int with a loop (result = result * 2 + (c - '0')), add the ints, then convert the sum back by repeated division by 2.
How to convert decimal to binary → · How to convert binary to decimal →