EASy68K  
It is currently Wed Jun 03, 2020 3:27 am

All times are UTC




Post new topic Reply to topic  [ 6 posts ] 
Author Message
PostPosted: Mon Feb 17, 2014 6:27 pm 
Offline

Joined: Mon Feb 17, 2014 6:20 pm
Posts: 2
So I have

DIVU #4, D2
DIVU #10, D3
DIVU #100, D4

to 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.


Top
 Profile  
 
PostPosted: Wed Feb 19, 2014 11:04 am 
Offline

Joined: Tue Nov 15, 2005 7:58 am
Posts: 129
Location: Oregon, USA
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.


Top
 Profile  
 
PostPosted: Wed Feb 19, 2014 6:02 pm 
Offline

Joined: Mon Feb 17, 2014 6:20 pm
Posts: 2
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.


Top
 Profile  
 
PostPosted: Thu Feb 20, 2014 1:04 pm 
Offline

Joined: Tue Nov 15, 2005 7:58 am
Posts: 129
Location: Oregon, USA
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?


Last edited by gtippery on Fri Apr 04, 2014 5:19 am, edited 1 time in total.

Top
 Profile  
 
PostPosted: Thu Apr 03, 2014 7:36 pm 
Offline

Joined: Mon Jul 26, 2010 11:43 pm
Posts: 198
Location: Aurora, IL
He's attempting to compute 36% of the original number, in order to then compute 64%

a = $5000

p25 = (a / 4)
p10 = (a / 10)
p1 = (a / 100)
p36 = p25 + p10 + p1
p64 = a - p36

Which of course could also be done as

p64 = (a * 100) / 64


Top
 Profile  
 
PostPosted: Fri Apr 04, 2014 5:23 am 
Offline

Joined: Tue Nov 15, 2005 7:58 am
Posts: 129
Location: Oregon, USA
clive wrote:
He's attempting to compute 36% of the original number, in order to then compute 64%

a = $5000

p25 = (a / 4)
p10 = (a / 10)
p1 = (a / 100)
p36 = p25 + p10 + p1
p64 = a - p36

Which of course could also be done as

p64 = (a * 100) / 64

Beats 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...


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 6 posts ] 

All times are UTC


Who is online

Users browsing this forum: No registered users and 13 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
cron
Powered by phpBB® Forum Software © phpBB Group