1011 + 1101 — binary arithmetic
introcarries through every column
Answer
11000
Why this example is worth doing
Binary addition with a carry out of almost every column, which is the case worth starting on because the carry chain is the whole difficulty. The rules are four lines long — 0+0, 0+1, 1+0, and 1+1 which gives 0 carry 1 — and the tool draws the carry row above the operands exactly as it is done by hand. Eleven plus thirteen is twenty-four, and the decimal check is printed alongside.
Try your own input in the Binary arithmetic. Add, subtract, multiply and divide in binary with every carry and borrow shown.
How the answer is reached
01011 + 01101 (5-bit, unsigned)
| operand | bits | hex | unsigned | signed |
|---|---|---|---|---|
| A | 01011 | 0x0B | 11 | 11 |
| B | 01101 | 0x0D | 13 | 13 |
| row | 4 | 3 | 2 | 1 | 0 |
|---|---|---|---|---|---|
| carry in | 1 | 1 | 1 | 1 | 0 |
| A | 0 | 1 | 0 | 1 | 1 |
| + B | 0 | 1 | 1 | 0 | 1 |
| result | 1 | 1 | 0 | 0 | 0 |
C = 0 · V = 1 · N = 1 · Z = 0
unsigned11 + 13 = 24, kept as 24— fits in the width
signed11 + 13 = 24, kept as -8— V = 1: the signed answer is wrong
C is carry-out (unsigned overflow); V is carry-into-MSB XOR carry-out-of-MSB (signed overflow). They are independent: either, both or neither can be set.