Re: LZ: Fractions
[Prev][Next][Index][Thread]
At 11:52 PM 8/21/96 -0500, you wrote:
>The easiest way to divide by five is to first multiply the number by 2 and
then divide by 10. An example is below.
>
>Assuming A is the number to divide by 5
>
>Start:
> ld l,a
> ld h,0
> sla l
> rl h ;multiply A by two and place in HL
>
> ROM_CALL(UNPACK_HL) ;divides HL by 10 and stores decimal to A
>
> ;HL contains number divided by 5 and A contains the decimal part of number
in HL
>End:
>
>That's all there is to it. I just found out how to do that today when I
had to write a routine to convert Celcius degrees to Farenheit.
>
>Ed Plese, Jr.
>(eplese@lnd.com)
>
>
The problem with this routine is that it won't work if you want to divide it
by 3, (or 7, or 9, or whatever). I'd need a generic routine. If there is no
generic routine, this would be a good idea, but I was hoping for a simple
routine that would work for most numbers. (Actually, I need to divide
numbers by 2, 3, 5, and 10, and maybe some others later).
David Kristensen at the University of Missouri - Kansas City
dkristensen@cctr.umkc.edu
The Mind conquers All...
References: