[Prev][Next][Index][Thread]

Re: A85: More questions




1)  Fractions:  I might go about this by storing the numerator in one
area of memory and the denominator in another.  Then when a display was
called display num '/' den.  If you want a decimal approximation get a
divide routine.  I've never worked on a fraction program so this stuff is
theoretical but remember you can multiply any fraction by 1 and have a
different fraction of the same value ( 1/2 * 2/2 = 2/4 ).  Also, of
course it's possible because with assembly, you can do just about
anything.

2)  If I had a dollar for every time I put this algorithm up I'd be rich:
(You want to take the square root of X)

GUESS = X / 2
DO
GUESS = (GUESS + X / GUESS) / 2
WHILE ABS(GUESS * GUESS - X) > 1.0E-9

A few things to remember here are to remember order of operations,
anything divided by two can have a bitwise shift to the right for the
same value (not decimals), and the 1.0E-9 is how many places
approximation behind the decimal the solution will be (sp?).

If anyone ever decides to make the assembly routine for a square root
function, I'd like to have it (source code).

Mordant
egillespie@juno.com
erik_gillespie_1096@gwgate.kvcc.edu

"Just because you're paranoid don't mean they're not after you." -Kurt
Cobain

_____________________________________________________________________
You don't need to buy Internet access to use free Internet e-mail.
Get completely free e-mail from Juno at http://www.juno.com
Or call Juno at (800) 654-JUNO [654-5866]


Follow-Ups: References: