Works on this device
Binary Adder Calculator
Add two binary numbers the way a ripple-carry adder does it: one column at a time, with the carry passed to the next column. You can also subtract by two's complement and see the truth tables of the half adder and the full adder.
Enter your values
Check these values
Your values are worked out in this browser. They are not sent to a server.
Your result will show here
Fill in the values, then choose Calculate.
Your result
How it was worked out
How to use this calculator
- Choose Add two binary numbers or Subtract by two's complement.
- Type the two numbers. They can be binary, decimal or hexadecimal;
0band0xin front of a number are read too. - Keep the width at as many bits as the longer number, or choose a fixed width such as 8 bits to see overflow and the signed reading.
- Choose Calculate. The column table shows each bit with its carry in, sum bit and carry out.
How the adder works
- A half adder adds two bits: sum S = A ⊕ B (XOR) and carry C = A·B (AND).
- A full adder adds two bits and a carry in: S = A ⊕ B ⊕ Cin and Cout = A·B + Cin·(A ⊕ B). It is made of two half adders and an OR gate.
- A ripple-carry adder chains one full adder for each bit. The carry out of each column is the carry into the next one.
- Subtraction: A − B = A + NOT B + 1. NOT B + 1 is the two's complement of B. The 1 enters as the carry into bit 0. A carry out of 1 means the answer is 0 or more; a carry out of 0 means the answer is negative (a borrow).
- Overflow in a fixed width: unsigned overflow when the carry out of the last bit is 1 (for addition). Signed overflow when the carry into the last bit differs from the carry out of it.
Worked examples
- 1011 + 0111 (11 + 7): bit 0: 1 + 1 = 0, carry 1. Bit 1: 1 + 1 + 1 = 1, carry 1. Bit 2: 0 + 1 + 1 = 0, carry 1. Bit 3: 1 + 0 + 1 = 0, carry 1. The last carry becomes a new bit: 1 0010, which is 18.
- In 8 bits, 0110 1101 + 0011 0111 (109 + 55) = 1010 0100, which is 164 unsigned. The carry into the last bit is 1 and the carry out is 0, so there is a signed overflow: as a signed number the register reads −92.
- 0110 − 1011 (6 − 11): NOT B = 0100, and 0110 + 0100 + 1 = 1011 with no carry out. So the answer is negative, and its size is the two's complement of 1011, which is 0101. The answer is −5.
Limits you should know
- Whole numbers only, up to 128 bits. Negative numbers need a fixed width, because they are stored in two's complement.
- The page shows the logic of the adder, not its timing: a real ripple-carry adder waits for the carry to pass through every bit.
- For AND, OR, XOR, shifts, multiplication and division in a fixed width, use the Bitwise & Binary Calculator. It gives the same sums and overflow flags.