Binary Calculator
Enter two binary numbers and pick an operation to see the result in binary and decimal. Enter only 0s and 1s.
What the calculator does
Enter two binary strings and choose add or subtract. The tool converts each input to decimal, performs the operation, then returns the answer in both bases along with the decimal value of each input. With the defaults 1010 and 11, it reports 10 and 3, and the sum 1101, which is 13 in decimal. Subtraction with the same inputs gives 7, written 111.
Place values in base 2
Binary is positional like decimal, but each place is worth twice the one to its right instead of ten times. Reading from the right, the weights are 1, 2, 4, 8, 16, 32, 64 and 128. A digit can only be 0 or 1, so each place is either counted or skipped — there is no such thing as a 2 in a single column.
That is why 1010 equals 10: the leftmost 1 sits on the 8 place, the next 1 sits on the 2 place, and the two zeros contribute nothing, so 8 + 2 = 10. The same reading applies to 11: one 2 plus one 1 makes 3. Neither value needs any multiplication beyond picking the right weight.
| Position from right | Weight | Set in 1010? | Set in 11? |
|---|---|---|---|
| 1 | 1 | No | Yes |
| 2 | 2 | Yes | Yes |
| 3 | 4 | No | No |
| 4 | 8 | Yes | No |
| 5 | 16 | No | No |
| 6 | 32 | No | No |
| 7 | 64 | No | No |
| 8 | 128 | No | No |
Worked example: 1010 + 11
Line the numbers up on the right and pad the shorter one with a leading zero, so 11 becomes 0011. Add column by column from the right. Column one: 0 + 1 = 1. Column two: 1 + 1 = 10, write 0 and carry 1. Column three: 0 + 0 + the carried 1 = 1. Column four: 1 + 0 = 1. Reading left to right gives 1101.
Check it in decimal: 10 + 3 = 13, and 1101 is 8 + 4 + 1 = 13. The carry is the only thing that differs from decimal addition, and it happens whenever a column reaches 2 rather than 10.
| Column sum | Write | Carry |
|---|---|---|
| 0 + 0 | 0 | 0 |
| 0 + 1 | 1 | 0 |
| 1 + 0 | 1 | 0 |
| 1 + 1 | 0 | 1 |
| 1 + 1 + carry | 1 | 1 |
The last row is the one that catches people. Three set bits in a single column produce a 1 with a carry, not a 0, which is why adding several binary numbers in sequence needs care at every column that already has a carry coming in.
Worked example: 1010 − 11
Switch the operation to subtract and the same inputs give 10 − 3 = 7. In binary that is 111, since 4 + 2 + 1 = 7. Lined up as 1010 − 0011, the rightmost column needs 0 − 1, so you borrow 2 from the next column: 10 − 1 = 1 and the borrowed column drops by one.
The borrow is worth 2, not 10, because the base is 2. Each borrow halves the column to its left, and a chain of borrows across zeros, as in 1000 − 1 = 111, is the most error-prone case to do by hand.
Negative results
If the second number is larger, the result is negative and the binary output is prefixed with a minus sign: 11 − 1010 returns -111, meaning -7. This is sign-and-magnitude notation for display only. Computers normally store negatives in two’s complement, where -7 in 8 bits is 11111001, a very different string.
What moves the answer
- A single extra bit on the left doubles the value, so 111 (7) becomes 1111 (15) with one keystroke
- Leading zeros never change the value: 0011 and 11 both equal 3
- Adding a carry past the leftmost column grows the result by one digit, as 111 + 1 = 1000
- Subtracting equal values returns 0, and the tool prints a plain 0 rather than an empty string
- Swapping A and B changes subtraction but never addition, since addition is commutative
Common mistakes
- Entering a decimal number such as 10 and expecting binary 1010, when the field reads 10 as the binary string one-zero
- Typing a digit of 2 or higher: parseInt stops at the first invalid character, so 1012 silently becomes 101
- Forgetting to pad before subtracting, which shifts every column and produces a wrong borrow chain
- Reading 1101 as decimal one thousand one hundred one instead of thirteen
- Assuming an 8-digit input covers large numbers: eight bits cap the value at 255
The field limit
The input accepts up to eight characters, which is eight bits and a maximum value of 11111111 = 255. Two such inputs can sum to 510, or 111111110 in binary, which is nine digits — one more than either input can hold. That extra digit is the carry out of the top column, and it is the reason fixed-width registers need an overflow flag.
Binary versus decimal arithmetic
The algorithm is identical in any base: align on the right, work column by column, carry or borrow when a column crosses the base. Only the threshold changes, 2 instead of 10.
A carry chain shows the difference clearly. Adding 1010 to itself gives 10100: column two produces 10, column three takes the carry and produces another 10, and the carry walks all the way to a new leading digit. In decimal the same addition, 10 + 10, produces a single carry and 20. Binary needs three carries for a result of 20, which is why fixed-width overflow appears one bit sooner than people expect.
Frequently asked questions
How do I add binary numbers?
Align the numbers on the right and add each column, carrying 1 whenever a column reaches 2. 1010 + 0011 gives 1101, which is 13 in decimal.
What is 1 plus 1 in binary?
It equals 10, meaning write 0 and carry 1 to the next column. Add a third set bit from an incoming carry and the column writes 1 with a carry of 1.
How does binary subtraction work?
Borrow from the next column when the top digit is smaller, but the borrow is worth 2 rather than 10. 1010 − 0011 = 0111, or 7.
What is 1010 in decimal?
10. The bits sit on the 8 and 2 places, so 8 + 2 = 10. The two zeros on the 4 and 1 places contribute nothing.
What is the largest number this calculator accepts?
11111111, which is 255 in decimal. The field allows eight characters, so two inputs can sum to 510 and produce a nine-digit result.
Why does entering 10 give the wrong answer?
The field reads 10 as the binary string one-zero, which is decimal 2. To add decimal ten, enter 1010. Any digit of 2 or higher is invalid in binary.
What happens if I type a 2?
The parser stops at the first invalid character, so 1012 is read as 101, which is 5. If the first character is invalid the result becomes NaN and nothing is displayed.
How do I write a negative binary result?
This tool prefixes a minus sign, so 11 − 1010 shows -111. Two’s complement would store -7 in 8 bits as 11111001 instead.
Is binary addition the same as decimal addition?
Yes, apart from the carry threshold. Both align on the right and propagate carries left; binary carries at 2 and decimal at 10.
Method and sources
- Binary is base 2; each digit is a power of two.