# ALU, negationx, y, add16 off by one?

10 messages
Open this post in threaded view
|

## ALU, negationx, y, add16 off by one?

 So when im adding positive x, to positive y. And I negate either one and set f to 1. Is it right that the result is a number that is one less compared to the result i would have gotten if I used a negative sign instead of the negation bit? I originally fixed this by incrementing the noty, and notx outputs then ran them through a multiplexor with the negation bits and the original noty and notx for the adder16 gate. However the script said this was wrong. When i took out my fix, it works? Here is a mathematical example. 1500 + -(500) = 1000.
Open this post in threaded view
|

## Re: ALU, negationx, y, add16 off by one?

 Can you clarify your question? I assume you're working on the ALU. What feature are you trying to accomplish? Are you familiar with the 2's complement system?
Open this post in threaded view
|

## Re: ALU, negationx, y, add16 off by one?

 In reply to this post by rogerdodger91 It seems as though you have a misapprehension about the twos complement notation.  not x (where x is positive) is not equal to -x. I think this might best be explored with 0.  Obviously, mathematically, -0 = 0, however, in twos complement, not 0 = -1. On Tue, Dec 6, 2011 at 10:48 AM, rogerdodger91 [via TECS Questions and Answers Forum] <[hidden email]> wrote: > So when im adding positive x, to positive y. And I negate either one and set > f to 1. Is it right that the result is a number that is one less compared to > the result i would have gotten if I used a negative sign instead of the > negation bit?
Open this post in threaded view
|

## Re: ALU, negationx, y, add16 off by one?

 Administrator In reply to this post by rogerdodger91 There are two types of negation, arithmetic and logical. Read the description of the ALU carefully and make sure you understand what type of negation is required. Note that just changing the sign bit of a number results in a wildly different number, not the arithmetic negation of the number. Example: 0x0000 (0), 0x8000 (-32768). --Mark
Open this post in threaded view
|

## Re: ALU, negationx, y, add16 off by one?

 What im asking is, If were for instance put in the y out = 1. And then the bit control for ny = 1. And im supposed to get -1. Because in this case im getting -2. Can i send one of you my implementation so you guys can see what im saying?
Open this post in threaded view
|

## Re: ALU, negationx, y, add16 off by one?

 I went ahead and sent mark my ALU. I commented out the "fix" that would make the addition of the ny and nx = logical. While keeping the binary implementation sound. I realize the binary and the "fix" i made are in fact two different number nows. If you could clarify on how "fixes" in my ALU sucks id be happy to hear your critique.
Open this post in threaded view
|

## Re: ALU, negationx, y, add16 off by one?

 Administrator I got your email and will look at your ALU and comment.  You might also want to check out this worksheet that will help you learn how the ALU operates. --Mark
Open this post in threaded view
|

## Re: ALU, negationx, y, add16 off by one?

 I have a working ALU. I just now have two ALUs. One that does an off by one subtraction and on that give you a true valid subtraction answer.. They both give the same AND bitwise results results. I understand twos complement. I know that since you cant have a +0, and -0 is the reason why my method might be wrong. I just want to know why we dont necessarily us my proposed fixed with in place of the other one. Whats wrong with my ALU basically theoretically speaking.