Addition in Binary With Logical Operators
Addition in Binary With Logical Operators
Truth Table
p
CarryIn
0
0
0
1
1
1
1
0
1
1
0
0
1
1
1
0
1
0
1
0
1
Sum CarryOut
1
1
0
1
0
0
1
0
0
1
0
1
1
1
1.
Move within the p and q strings bit-by-bit from right to left, setting Integer Variables for each bit as you go.
2.
3.
4.
5.
6.
7.
CarryIn = CarryOut
8.
CarryOut = 0
9.
Continue through the p and q strings bit-by-bit until done (Go back to 4.)
<--Minuend
<--Subtrahend
Make sure the Minuend String is LARGER than the Subtrahend String.
2.
Move within the Minuend and Subtrahend strings from right to left, setting Integer Variables for each bit as you go.
3.
4.
Add the Minuend to the (Subtrahend XOR'd with 1), bit-by-bit, as shown below (See (c) above)
5.
6.
7.
8.
CarryIn = CarryOut
9.
CarryOut = 0
10. Continue through the Minuend and Subtrahend Strings bit-by-bit until done (Go back to 5.)
11. There will ALWAYS be a final CarryOut: Ignore it or set it to zero (See (h) above: + 100110111 - 100000000)
Note: The number of NINES used is always the number of DIGITS in the Subtrahend.