Mathematics
The mathematics are as simple as addition of 10-based digits
- Add two binary number of the same bit and the carry (from the last bit)
- If sum exeeds 1, sum turns 0, add 1 to the next carry
Overflow
Overflow occurs when the result of addition exceeds the maximum length of binary digits (
Digital Adder
- Half Adder - adds two bits
- Full Adder - adds three bits
- Adder - Adds two numbers
Half Adder
If the carry is 0, then
a | b | Sum | Carry |
---|---|---|---|
0 | 0 | 0 | 0 |
1 | 0 | 1 | 0 |
0 | 1 | 1 | 0 |
1 | 1 | 0 | 1 |
**Diagram**
Full Adder
Why a half adder is called HALF? There're two of them in a FULL Adder.
Take the carry into consideration
a | b | c (last carry) | Sum | Carry |
---|---|---|---|---|
0 | 0 | 0 | 0 | 0 |
0 | 0 | 1 | 1 | 0 |
1 | 0 | 0 | 1 | 0 |
1 | 0 | 1 | 0 | 1 |
0 | 1 | 0 | 1 | 0 |
0 | 1 | 1 | 0 | 1 |
1 | 1 | 0 | 0 | 1 |
1 | 1 | 1 | 1 | 1 |
- There're two ways to get
And And
- Otherwise Sum = 0
- There're two ways to get
And - (
doesn't matter because , so only affect )
- (
**Diagram**
Multi-bit Adder
- The first c is always 0
- The last carry is thrown (ignore the overflow)
For N-bit adder
- 1 Half adder
- N-1 Full adder