It is currently Tue Oct 15, 2019 3:01 pm

 All times are UTC

 Page 1 of 1 [ 6 posts ]
 Print view Previous topic | Next topic
Author Message
 Post subject: division without using divuPosted: Wed Feb 22, 2012 6:17 pm

Joined: Wed Feb 22, 2012 2:17 am
Posts: 8
Location: toronto
I can figure out how to multiply by an integer without using mult.

Top

 Post subject: Posted: Wed Feb 22, 2012 6:28 pm

Joined: Thu Dec 16, 2004 6:42 pm
Posts: 1102
Subtract the divisor from the dividend in a loop. Count the number of subtractions necessary to reach zero. The count is the answer.

_________________
Prof. Kelly

Top

 Post subject: Posted: Wed Feb 22, 2012 7:25 pm

Joined: Wed Feb 22, 2012 2:17 am
Posts: 8
Location: toronto
profkelly wrote:
Subtract the divisor from the dividend in a loop. Count the number of subtractions necessary to reach zero. The count is the answer.

so to obtain a fraction:
you'd check if the n flag.
increase the counter by 1 to obtain the whole part.
then... somehow store the ratio of the remainder?

is there a standard way to store fractions?

Top

 Post subject: Posted: Wed Feb 22, 2012 9:16 pm

Joined: Thu Dec 16, 2004 6:42 pm
Posts: 1102
I don't recall a standard way to store fractions unless you want to use a floating point scheme.

http://www.swarthmore.edu/NatSci/echeeve1/Ref/BinaryMath/NumSys.html#posfrac

_________________
Prof. Kelly

Top

 Post subject: Posted: Thu Feb 23, 2012 4:53 pm

Joined: Mon Jul 26, 2010 11:43 pm
Posts: 198
Location: Aurora, IL
etw3 wrote:
is there a standard way to store fractions?

Fixed point representations, and floating point.

Fixed point tends to be implementation specific, based on the range of the numbers being used. With 32 bit you could use a 16.16 or 2.30 representation.

Top

 Post subject: Posted: Thu Feb 23, 2012 5:00 pm

Joined: Mon Jul 26, 2010 11:43 pm
Posts: 198
Location: Aurora, IL
profkelly wrote:
Subtract the divisor from the dividend in a loop. Count the number of subtractions necessary to reach zero. The count is the answer.

Kind of brute force, most 80's era 8-bit processors did long division in software using a shift and subtract algorithm.

http://courses.cs.vt.edu/~cs1104/Buildi ... e.030.html

Kind of how decimal long division is achieved when you don't have a calculator.

Top

 Display posts from previous: All posts1 day7 days2 weeks1 month3 months6 months1 year Sort by AuthorPost timeSubject AscendingDescending
 Page 1 of 1 [ 6 posts ]

 All times are UTC

#### Who is online

Users browsing this forum: No registered users and 4 guests

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

Search for:
 Jump to:  Select a forum ------------------ EASy68K Forum    FAQ    Latest Features    EASy68K Questions    68000 Programming Questions    Wish List    Wishes Granted    Undocumented Features    Documented Features    General Discussion    EASy68K Projects