Computers do all their arithmetic in base 2, with only the digits 0 and 1. This binary calculator performs the four operations on two binary numbers of any length up to 256 digits — addition, subtraction, multiplication and division (quotient and remainder) — using exact big-integer arithmetic, so there is no rounding even for very long numbers.
The answer is given in binary, decimal and hexadecimal at once, and the work is laid out the way you would do it on paper: a column-by-column table with every carry for addition, every borrow for subtraction, and the shifted partial products for multiplication. It is a convenient way to check homework in a digital-electronics or computer-architecture course, or to verify what a piece of low-level code should produce.
Negative numbers can be typed with a minus sign. If you pick a register width (8, 16, 32 or 64 bits), the calculator also shows the result as a two’s complement bit pattern and warns you when it overflows that width, exactly as a processor would.
How to use this calculator
- Type the first binary number A, for example 1011. Spaces and underscores are ignored, so 1101 0110 is fine.
- Choose the operation: +, −, × or ÷.
- Type the second binary number B.
- Optionally pick a width for the two’s complement view.
- Read the result in binary, decimal and hexadecimal. Open the table and steps to follow the carries, borrows or partial products.
The formula
A binary numeral stands for . The four operations work like decimal arithmetic with only two digits.
Addition, column by column from the right (Knuth’s Algorithm A): and the carry . The four basic facts are , , and .
Subtraction uses borrows: when you borrow from the next column.
Multiplication is shift-and-add: , i.e. a copy of shifted left places for each 1 bit of .
Division gives with .
Two’s complement on bits stores an integer with as ; for a negative number, invert all the bits of and add 1.
Worked example
Binary addition 1011 + 110 (11 + 6 in decimal). From the right: ; , write 0 carry 1; , write 0 carry 1; , write 0 carry 1; the last carry gives a new digit. The carries out of each column, read from left to right, are 1110, and the sum is 10001 = 17.
Subtraction (26 − 15 = 11). Multiplication : two partial products, and , add up to 1000001 (13 × 5 = 65). Division gives quotient 101 and remainder 10 (27 = 5 × 5 + 2).
Two’s complement: −5 on 8 bits is : write 5 as 00000101, invert to 11111010, add 1.
Binary addition step by step
Binary addition follows the same column method as decimal addition, but a column overflows as soon as it reaches 2 instead of 10. Each column therefore has only four cases:
| Bits + carry in | Sum bit | Carry out |
|---|---|---|
| 0 + 0 + 0 | 0 | 0 |
| 1 + 0 + 0 | 1 | 0 |
| 1 + 1 + 0 | 0 | 1 |
| 1 + 1 + 1 | 1 | 1 |
This table is exactly what a full adder circuit implements with logic gates: the sum bit is (XOR) and the carry is set when at least two of the three inputs are 1. Chaining one full adder per bit gives a ripple-carry adder, the simplest way a processor adds two registers.
Binary arithmetic operations and negative numbers
The four binary arithmetic operations rely on a handful of facts. Subtraction borrows a 2 from the next column (). Multiplication only ever multiplies by 0 or 1, so it reduces to copying the first number, shifting it left and adding — which is why multiplying by 2 is a simple left shift. Long division works like decimal long division, except that each quotient digit is either 0 or 1.
Computers rarely store a minus sign. With two’s complement, the same adder handles positive and negative numbers: subtracting B is the same as adding the two’s complement of B and dropping the final carry. On 8 bits, 00010100 (20) + 11111001 (−7) = 00001101 (13). Results outside the range of the register overflow and wrap around. To work with remainders and powers of two, see the modulo calculator; for the number of bits a value needs, use log₂ in the logarithm calculator.
Frequently asked questions
How do you add binary numbers?
Line the numbers up on the right and add column by column: 0 + 0 = 0, 0 + 1 = 1, 1 + 1 = 0 carry 1, and 1 + 1 + 1 = 1 carry 1. For example 1011 + 110 = 10001, which is 11 + 6 = 17.
What is 1 + 1 in binary?
1 + 1 = 10 in binary: the column becomes 0 and a 1 is carried to the next place, because 2 is written 10 in base 2. Likewise 1 + 1 + 1 = 11 (three).
How do you subtract binary numbers?
Work right to left, borrowing when the top bit is smaller: 0 − 1 becomes 10 − 1 = 1 with a borrow from the next column. Alternatively, add the two’s complement of the second number and drop the final carry.
How does binary division handle the remainder?
The calculator returns a whole-number quotient and a remainder such that A = B × Q + R. 11011 ÷ 101 gives Q = 101 and R = 10 (27 ÷ 5 = 5 remainder 2). With negative numbers the quotient is truncated toward zero.
What is two’s complement?
It is the standard way to store signed integers in a fixed number of bits: negative x is stored as 2ʷ − |x|. To get it by hand, invert every bit of the positive value and add 1. On 8 bits, −5 is 11111011.
Sources
- Knuth, D. E., The Art of Computer Programming, vol. 2: Seminumerical Algorithms, 3rd ed. — §4.1 Positional number systems, §4.3.1 classical algorithms A (addition), S (subtraction), M (multiplication), D (division)
- Weisstein, Two’s Complement — Wolfram MathWorld
- Weisstein, Binary — Wolfram MathWorld
Last updated: