# Order of operations and negating the 16 bit values.

4 messages
Open this post in threaded view
|

## Order of operations and negating the 16 bit values.

 the order I do things are zero the x and or negate the value same with Y value then add or and it then negate the output. The code doesn't work at all. Here is what I have. ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////     Mux16(a=x,b=false,sel=zx,out=xZeroed);/ /can out put zeroed and not zeroed    Not16(in=xZeroed,out=InvertX);   Inc16(in=InvertX,out=IncX);//outputs only negtive numbers    Mux16(a=xZeroed,b=IncX,sel=nx,out=NegX);//can out put Negtive or not Negtive X //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////     Mux16(a=y,b=false,sel=zy,out=yZeroed);/ /can out put zeroed and not zeroed y    Not16(in=yZeroed,out=Inverty);   Inc16(in=Inverty,out=Incy);//outputs only negtive numbers    Mux16(a=yZeroed,b=Incy,sel=nx,out=NegY);//can out put Negtive or not Negtive y  //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// Add16(a=NegX,b=NegY ,out=added); And16(a=NegX,b=NegY,out=anded); Mux16(a=anded,b=added,sel=f,out=addand);//first main output /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////    Not16(in=addand,out=InvertOut);   Inc16(in=InvertOut,out=IncOut);//outputs only negtive numbers Mux16(a=addand,b=IncOut,sel=no,out=out); /////////////////////////////////////////////////////////////////////////////////////////////////////// but all I get is zeros or ones.
Open this post in threaded view
|

## Re: Order of operations and negating the 16 bit values.

For each input (x, y) there are two bits which can affect them prior to their use together. This means we have a four value selector that chooses between:
zeronotresultbits
00original input101 => 101
01bitwise not the input101 => 010
10zero the input101 => 000
11bitwise not the zero101 => 111
I hope this helps clarify things a little.