LZ: Fractions
[Prev][Next][Index][Thread]
LZ: Fractions
-
Subject: LZ: Fractions
-
From: Edward Plese <eplese@lnd.com>
-
Date: Wed, 21 Aug 1996 23:52:13 -0500
-
In-Reply-To: <>
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)