# Convert 4-bit input to its negative number in 2's complement format

#### Huzaifa Asif

Joined Mar 22, 2015
11
Design a circuit that takes in 4-bit 2's complement number and outputs its negative number in 2's complement format. For +4, output is -4.

I'm thinking of finding the logic using K-map but i'm not too sure whether it's the right way. Can anybody help me out?

Regards

#### MrChips

Joined Oct 2, 2009
22,062
Draw a truth table with a column for all states DCBA, 0-7 (D is MSB, A is LSB).
Draw to the right of these columns, the 2's complement of 0-7.

#### Papabravo

Joined Feb 24, 2006
14,648
The way we do it inside a processor is to invert each bit and add 1 to the result. Don't know if that will help you.
BTW the range of the results will be [-8,-7,-6,-5,-4,-3,-2,-1,0,1,2,3,4,5,6,7] and the complement of -8 is -8.

#### Huzaifa Asif

Joined Mar 22, 2015
11
Draw a truth table with a column for all states DCBA, 0-7 (D is MSB, A is LSB).
Draw to the right of these columns, the 2's complement of 0-7.
This is what I did according to my understanding. What do you think?

#### Attachments

• 758.3 KB Views: 38

#### MrChips

Joined Oct 2, 2009
22,062
This is what I did according to my understanding. What do you think?
Start by drawing the truth table. The Karnaugh map will come later.

#### Papabravo

Joined Feb 24, 2006
14,648
That's not correct. You have identical values in row 2, columns 2 and 3.

#### Huzaifa Asif

Joined Mar 22, 2015
11
That's not correct. You have identical values in row 2, columns 2 and 3.
Sorry. The 2nd row 3 column is supposed to be 1001.
Now how does it look?

#### WBahn

Joined Mar 31, 2012
26,271
Sorry. The 2nd row 3 column is supposed to be 1001.
Now how does it look?
With that modification, it looks correct.

You need to get in the habit of checking your own work because there usually will not be someone around to check it for you -- that's you they are paying you to do it.

Where possible, use the structure of what you are trying to doing to provide a means of checking your work. In this case you (should) know that the 2's complement bit patterns start at -8 (1000) for an input value of 8 (the most negative representable value) and then count up from there. So visually walk along the table and find 8 and see it it's 1000, then find 7 and it should be 1001 and so on. Then do the same for the negative input values.

#### Huzaifa Asif

Joined Mar 22, 2015
11
With that modification, it looks correct.

You need to get in the habit of checking your own work because there usually will not be someone around to check it for you -- that's you they are paying you to do it.

Where possible, use the structure of what you are trying to doing to provide a means of checking your work. In this case you (should) know that the 2's complement bit patterns start at -8 (1000) for an input value of 8 (the most negative representable value) and then count up from there. So visually walk along the table and find 8 and see it it's 1000, then find 7 and it should be 1001 and so on. Then do the same for the negative input values.
Alright thanks
by the way, the next step is to be create carnage maps for 4 outputs and then create a logic, right?

#### WBahn

Joined Mar 31, 2012
26,271
Alright thanks
by the way, the next step is to be create carnage maps for 4 outputs and then create a logic, right?
That's certainly one way to proceed -- and probably the way that you are expected to proceed.