How the binary calculator works
Use Calculate for binary arithmetic or bitwise operations, and Convert to write a number in binary, decimal, hexadecimal and octal. The binary answer appears with its other base representations and worked steps. Word size determines whether arithmetic keeps the full result or wraps to a fixed number of bits.
- 1Choose the task. Calculate offers addition, subtraction, multiplication, division, AND, OR and XOR. In Convert, choose the input base and enter one number.
- 2Enter the numbers. Use the boxes or binary keypad. Binary entries accept spaces, underscores and a 0b prefix. For addition, use Add a number or paste a sum such as 101 + 110 + 011, with up to eight numbers.
- 3Set the word size. Any leaves arithmetic unwrapped and allows negative numbers and binary fractions. Choose 4, 8, 16, 32 or 64 bits for fixed-width integer work.
- 4Inspect the result. Copy an answer by tapping its base representation. The steps explain the calculation, and Bit by bit shows place values. In Convert, tap a bit to change it.
The binary place-value formula
Binary uses only 0 and 1. Starting at the right of an integer, the places are worth 1, 2, 4, 8, 16 and so on. Multiply each bit by its place value, then add the products.
This formula reads an unsigned binary integer. Fractional positions use exponents −1, −2 and so on after the binary point.
For example, 101010 is 32 + 8 + 2 = 42. After the point, the places are worth 1/2, 1/4 and 1/8, so 101.11 is 4 + 1 + 0.5 + 0.25 = 5.75.
Worked example: 1011 + 110
Choose addition, enter 1011 and 110, and select Any. Align the numbers on the right, treating the second as 0110. From right to left, the column totals are 1, 2, 2 and 2 after including carries. Each total of 2 writes 0 and carries 1; the final carry becomes a new leftmost bit.
The result is 17 in decimal, 11 in hexadecimal and 21 in octal. These are different ways to write the same value: 11 + 6 = 17.
Binary arithmetic by hand
For addition, 1 + 1 = 10 and 1 + 1 + 1 = 11. With several addends, total each column including the incoming carry. Write the remainder after dividing that total by 2, and carry the whole-number quotient. A column total of 4 writes 0 and carries 2.
| Operation | Binary result | Decimal check |
|---|---|---|
| 101 + 110 + 011 | 1110 | 5 + 6 + 3 = 14 |
| 1000000 − 101101 | 10011 | 64 − 45 = 19 |
| 10010 × 110 | 1101100 | 18 × 6 = 108 |
| 10011 ÷ 101 | 11 remainder 100 | 19 ÷ 5 = 3 remainder 4 |
Subtraction borrows from the next column when needed; one borrowed unit supplies 10 in the current binary column. Multiplication adds shifted copies of the first number wherever the second number has a 1. Long division writes 1 when the divisor fits the current partial dividend, and 0 otherwise.
For nonnegative integer division, the divisor is positive and the remainder is at least zero but smaller than the divisor.
Thus 19 = 5 × 3 + 4. Continuing past the binary point gives 10011 ÷ 101 = 11.11001100…, with 1100 repeating. The exact decimal quotient is 3.8. Division by zero is undefined.
Converting decimal, hex and octal
To convert a positive decimal integer to binary, repeatedly divide by 2 and record the remainders. Read them upward from the last division. For 42, the remainders are 0, 1, 0, 1, 0, 1, which reverse to 101010. Zero is written as 0.
For hexadecimal, group binary digits in fours outward from the point; for octal, use threes. Pad incomplete outer groups with zeros. Thus 101010 becomes 0010 1010, or 2A in hex, and 101 010, or 52 in octal.
AND, OR and XOR
Bitwise operations compare matching integer bit positions without carrying. AND returns 1 when both bits are 1. OR returns 1 when either or both are 1. XOR returns 1 when the bits differ.
| First bit | Second bit | AND | OR | XOR |
|---|---|---|---|---|
| 0 | 0 | 0 | 0 | 0 |
| 0 | 1 | 0 | 1 | 1 |
| 1 | 0 | 0 | 1 | 1 |
| 1 | 1 | 1 | 1 | 0 |
For 1100 and 1010, AND gives 1000, OR gives 1110 and XOR gives 0110. In decimal, the inputs are 12 and 10, and the results are 8, 14 and 6.
Word size, signed values and overflow
Fixed-width arithmetic keeps the lowest selected number of bits. The same stored pattern has an unsigned value and a signed two's complement value. The following formulas describe wrapping and signed interpretation.
Applies to integer results. Modulo here returns the nonnegative remainder.
| Bits | Unsigned range | Signed range |
|---|---|---|
| 4 | 0 to 15 | −8 to 7 |
| 8 | 0 to 255 | −128 to 127 |
| 16 | 0 to 65,535 | −32,768 to 32,767 |
To encode a negative value, write its positive magnitude at the chosen width, flip every bit and add 1. In 8 bits, 28 is 00011100; flipping gives 11100011, and adding 1 gives 11100100, which represents −28.
Carry and signed overflow differ. In 8 bits, 11111111 + 00000001 wraps to 00000000 with carry 1; signed, −1 + 1 still fits. But 01111111 + 00000001 gives 10000000 with no carry. Signed, 127 + 1 exceeds the maximum and wraps to −128, so signed overflow occurs.
Checks before using the answer
- 1Check the input base. In Convert, select decimal before entering 42. In a binary input, only 0 and 1 are digits.
- 2Keep the intended width. Use Any for ordinary arithmetic. Keep the specified width when checking a register, bit mask or two's complement exercise.
- 3Distinguish repeating results. An expansion ending in an ellipsis continues. Do not treat its displayed digits as an exact terminating value.
Frequently asked questions
What is 1 + 1 in binary?
It is 10, which equals decimal 2. Write 0 in the current column and carry 1 to the next column.
How do I add three or more binary numbers?
Select addition and add more input boxes, or paste a sum such as 101 + 110 + 011. That example gives 1110, or decimal 14; the calculator accepts up to eight addends.
Can a binary subtraction result be negative?
Yes: with Any, 101 − 1000 = −11. A fixed-width result wraps instead; in 4 bits, the same subtraction produces 1101, whose signed value is −3.
Why does decimal 0.1 repeat in binary?
A reduced fraction terminates in binary only when its denominator is a power of 2. Since 0.1 is 1/10, it repeats as 0.0001100110011…, while fractions such as 1/2 and 1/4 terminate.
What does the 0b prefix mean?
It identifies the following digits as binary, so 0b101 means decimal 5. The prefix identifies the base and does not contribute a bit to the number.
Sources
- 1Numbers: CS 3410 Spring 2026 · Cornell University · Accessed November 2026
- 2CSC104: Binary arithmetic and number representations · University of Toronto · Accessed November 2026
- 3Binary, Hexadecimal and Other Number Systems · University of Cambridge · Accessed November 2026
- 4Two's Complement · Cornell University · Accessed November 2026
- 5Built-in Types: Bitwise Operations on Integer Types · Python Software Foundation · Accessed November 2026
- 6Floating-Point Arithmetic: Issues and Limitations · Python Software Foundation · Accessed November 2026