EASy68Khttp://www.easy68k.com/EASy68Kforum/ Adding and subtracting fractions?http://www.easy68k.com/EASy68Kforum/viewtopic.php?f=6&t=1292 Page 1 of 1

 Author: Invoke [ Mon Feb 17, 2014 6:27 pm ] Post subject: Adding and subtracting fractions? So I have DIVU #4, D2DIVU #10, D3DIVU #100, D4to get 25%, 10%, and 1% of those registers but i have to sum them together and if I have a random initial value of \$00005000 in all of the registers I end up with a fraction in D3 and D4 and I'm unsure of how to add them together. Then subtract the sum of the 3 fractions from the initial value.

 Author: gtippery [ Wed Feb 19, 2014 11:04 am ] Post subject: Re: Adding and subtracting fractions? I find your question to be unclear. Perhaps you could just quote the original homework assignment?If you really need to add fractions on a 68000 (without floating point), you'll probably want to use scaled values. Googling "scaled integer arithmetic" might be a good place to start. Another possibility is rational arithmetic, but that's not what it sounds like you're describing.

 Author: Invoke [ Wed Feb 19, 2014 6:02 pm ] Post subject: Re: Adding and subtracting fractions? Ok so, Suppose there is already an initial value value in D1, I had to take 25% of D1 to put into D2, 10% into D3, and 1% into D4, Then in D5, it is the initial value - the sum of the %s. I just rounded by dropping off the remainders. Just wondering if there was a better way to do it.

 Author: gtippery [ Thu Feb 20, 2014 1:04 pm ] Post subject: Re: Adding and subtracting fractions? Invoke wrote:Ok so, Suppose there is already an initial value value in D1, I had to take 25% of D1 to put into D2, 10% into D3, and 1% into D4, Then in D5, it is the initial value - the sum of the %s. I just rounded by dropping off the remainders. Just wondering if there was a better way to do it.I think what you're saying is that D2, D3, and D4 each hold a number that is a integer fraction of D1, not that they are fractions (have a part that's less than one). Is that right?You're still paraphrasing the assignment instead of quoting it. I'm still confused as to what you want to do with the contents of D2..D4. Is D5 their sum? If so, it will not be the initial value (D1); 25%+10%+1% is not 100%. You also mentioned subtracting. Where does the result of that go? I think you need to post the code you've written so far.As far as a "better way", it depends on what you're trying to accomplish, which is still unclear. Did you check the subjects I mentioned before?

 Author: clive [ Thu Apr 03, 2014 7:36 pm ] Post subject: Re: Adding and subtracting fractions? He's attempting to compute 36% of the original number, in order to then compute 64%a = \$5000p25 = (a / 4)p10 = (a / 10)p1 = (a / 100) p36 = p25 + p10 + p1p64 = a - p36Which of course could also be done asp64 = (a * 100) / 64

 Author: gtippery [ Fri Apr 04, 2014 5:23 am ] Post subject: Re: Adding and subtracting fractions? clive wrote:He's attempting to compute 36% of the original number, in order to then compute 64%a = \$5000p25 = (a / 4)p10 = (a / 10)p1 = (a / 100) p36 = p25 + p10 + p1p64 = a - p36Which of course could also be done asp64 = (a * 100) / 64Beats me how you figured this out, unless you've seen the assignment. If you have, is the 100%-(25%+10%+1%) method part of the assignment?It'd still be good for him to post his code...