# Addition and subtraction of binary digits

I have to solve the following exercise :

Extend the circuit of the first part (the first part was an adder of integer numbers of 2 binary digits) in order to execute addition and subtraction of integers numbers of 2 binary digits (AB+-CD). Considering that numbers AB, CD are in 2's complement arithmetic. What does 2's complement mean and how I create the truth table?

## 2 Answers

Two's complement

See google: Two's Complement

Fragment:

Two's complement is a mathematical operation on binary numbers, best known for its role in computing as a method of signed number representation. For this reason, it is the most important example of a radix complement.

The two's complement of an N-bit number is defined as its complement with respect to 2N. For instance, for the three-bit number 010, the two's complement is 110, because 010 + 110 = 1000.

Truth Table

Also called Karnaugh Diagram

See google: Truth Table

A truth table is a mathematical table used in logic—specifically in connection with Boolean algebra, boolean functions, and propositional calculus—which sets out the functional values of logical expressions on each of their functional arguments, that is, for each combination of values taken by their logical variables (Enderton, 2001). In particular, truth tables can be used to show whether a propositional expression is true for all legitimate input values, that is, logically valid.

You also might have a look at Karnaugh Maps.

• I know what 2'complement and truth table are but the thing that i don't understand is how the truth table will be?Will I make the CD in 2's complement and add it to AB(substraction)? – Deppie3910 Nov 12 '18 at 12:19
• Check Karnaugh maps, put A, B, C and D in the table, and fill in what you expect (first calculate the 2 complement values of AB + CD). You literally asked: What does 2's complement mean .. this is explained in detail above/via wikipedia. – Michel Keijzers Nov 12 '18 at 12:22
1. The "2's complement" is the way one interprets the unsigned binary values as being signed, like described here: Two's complement. The fact that you're using two's complement numbers in addition does not impose any constrains to the simple binary adder that adds unsigned values. Only your interpretation of the numbers that took place in the addition differs.

2. The simplest way to add unsigned binary numbers is to do it with ripple carry adder. Once you are able to add numbers, subtraction is easily made by passing minuend and subtrahend to the same binary adder and:

• inverting all bits of the subtrahend
• passing carry-in to the ripple adder as 1, instead of default 0 for addition.