Continue to Site

Welcome to EDAboard.com

Welcome to our site! EDAboard.com is an international Electronics Discussion Forum focused on EDA software, circuits, schematics, books, theory, papers, asic, pld, 8051, DSP, Network, RF, Analog Design, PCB, Service Manuals... and a whole lot more! To participate you need to register. Registration is free. Click here to register now.

[SOLVED] Two's complement: Are there any algebraic 'hidden' properties ?

Status
Not open for further replies.

andre_luis

Super Moderator
Staff member
Joined
Nov 7, 2006
Messages
9,587
Helped
1,190
Reputation
2,399
Reaction score
1,206
Trophy points
1,403
Location
Brazil
Activity points
55,628
I am studying to make a test for the engineering position in a large company where I live, and I am using a test applied few years ago, and I got stucked with one of the questions, which is:

Let be two numbers X and Y of N bits and consider that the "+" operator refers to a sum of N bits and not to a logical OR operation. Given the bitwise complements of X and Y represented by X_ and Y_, respectively, evaluate the following expression when truncated to N bits:
A2.png

The first thing that came to mind was to recursively apply the "Two's Complement" rule:

CodeCogsEqn1.jpg

Which rearranged, give:

CodeCogsEqn2.jpg

So, replacing each of the last 2 variables at original equation,

CodeCogsEqn3.jpg

Adding the numerals,

CodeCogsEqn4.jpg

Doing the same for the first 2 variables,

CodeCogsEqn22.gif

And the same for the upper bar,

CodeCogsEqn33.jpg

Gathering numerals,

CodeCogsEqn44.jpg

But from here I'm stuck.

I wonder if I'm overlooking some elementary boolean rule.
I'm not sure if I can apply a distributive property to the (') complement operator:

CodeCogsEqn111.jpg

Rearranging,

CodeCogsEqn222.jpg

In a different format,

CodeCogsEqn666.jpg

And knowing that the complement means an algebraic signal inversion,

CodeCogsEqn888.jpg

Rearranging,

CodeCogsEqn999.jpg

However, correct answer (which I could confirm with random numerals at X and Y) is :


Does anyone have any insight on how to solve that?
 
Last edited:

I've some difficult in finding the error in your derivation, I should read it more carefully. However, I would proceed as follow:

-A=A_+1 from which A_=-A-1. Applying it to your expression we obtain:

-[-(x+y)-1 -x-1 -y-1]-1 = x+y+1+x+1+y+1-1 that is:

2x+2y+2
 
Your approach seems more consistent, once you are dealing with the variables only using the algebraic property of signal inversion, whereas I also made the distributive operation - which now I realize that is not applicable here. Thank you, the question surely have been solved.
 

Status
Not open for further replies.

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top