EASy68K  
It is currently Mon Sep 23, 2019 12:07 pm

All times are UTC




Post new topic Reply to topic  [ 6 posts ] 
Author Message
PostPosted: Wed Feb 22, 2012 6:17 pm 
Offline

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.
but what about division?


Top
 Profile  
 
 Post subject:
PostPosted: Wed Feb 22, 2012 6:28 pm 
Offline
User avatar

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
 Profile  
 
 Post subject:
PostPosted: Wed Feb 22, 2012 7:25 pm 
Offline

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
 Profile  
 
 Post subject:
PostPosted: Wed Feb 22, 2012 9:16 pm 
Offline
User avatar

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
 Profile  
 
 Post subject:
PostPosted: Thu Feb 23, 2012 4:53 pm 
Offline

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
 Profile  
 
 Post subject:
PostPosted: Thu Feb 23, 2012 5:00 pm 
Offline

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
 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 3 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:  
Powered by phpBB® Forum Software © phpBB Group