Add Binary Bits
Add two binary numbers bit by bit with carry visualization. See step-by-step full-adder logic, carry propagation, and verify results instantly.
About
Binary addition is the foundation of every arithmetic logic unit (ALU) in digital processors. Two operands of arbitrary bit-length are summed column by column from the least-significant bit (LSB) to the most-significant bit (MSB), propagating a carry c at each stage. A single mishandled carry bit in hardware design or firmware can cascade into catastrophic miscalculation - buffer overflows, checksum failures, and data corruption all trace back to this primitive operation. This tool implements a full-adder chain: for each bit position i, the sum bit si and carry-out ci+1 are computed from inputs ai, bi, and carry-in ci. Results are cross-verified with arbitrary-precision integer arithmetic. The tool assumes unsigned integers with no fixed word size - the output grows to accommodate any carry-out from the MSB.
Formulas
The full-adder computes, for each bit position i, a sum bit and a carry-out from three single-bit inputs: operand bit ai, operand bit bi, and carry-in ci.
Where ⊕ is the XOR (exclusive-or) gate, ∧ is AND, and ∨ is OR. The initial carry c0 = 0. The process iterates from i = 0 (LSB) to i = n − 1 (MSB), where n is the length of the longer operand. If the final carry cn = 1, the result has n + 1 bits. The decimal equivalent of any binary number is computed as the positional sum: D = n−1∑i=0 bi ⋅ 2i.
Reference Data
| a | b | cin | s (Sum) | cout (Carry) |
|---|---|---|---|---|
| 0 | 0 | 0 | 0 | 0 |
| 0 | 0 | 1 | 1 | 0 |
| 0 | 1 | 0 | 1 | 0 |
| 0 | 1 | 1 | 0 | 1 |
| 1 | 0 | 0 | 1 | 0 |
| 1 | 0 | 1 | 0 | 1 |
| 1 | 1 | 0 | 0 | 1 |
| 1 | 1 | 1 | 1 | 1 |
| Common Binary Addition Examples | ||||
| 1010 + 0110 | 10000 (decimal 10 + 6 = 16) | |||
| 1111 + 0001 | 10000 (decimal 15 + 1 = 16) | |||
| 1100 + 1100 | 11000 (decimal 12 + 12 = 24) | |||
| 101010 + 010101 | 111111 (decimal 42 + 21 = 63) | |||
| 11111111 + 1 | 100000000 (decimal 255 + 1 = 256) | |||
| Standard Word Sizes | ||||
| Nibble | 4 bits - max value 1111 (15) | |||
| Byte | 8 bits - max value 11111111 (255) | |||
| Word (16-bit) | 16 bits - max value 65535 | |||
| Double Word | 32 bits - max value 4294967295 | |||
| Quad Word | 64 bits - max value 18446744073709551615 | |||
| Powers of 2 | ||||
| 20 | 1 | |||
| 21 | 2 | |||
| 22 | 4 | |||
| 23 | 8 | |||
| 24 | 16 | |||
| 25 | 32 | |||
| 26 | 64 | |||
| 27 | 128 | |||
| 28 | 256 | |||
| 210 | 1024 | |||
| 216 | 65536 | |||
| 232 | 4294967296 | |||