'Divide by 10'
The following is from Pete Brink (microchip.com), who is pete.brink
having trouble posting directly to the list:
------ Forwarded Message Follows -------
Here was my answer to the divide by 10 problem. It's kind of based
upon how floating point format works, successive divisions by
multiples of two to approximate a multiply.
One solution would be to perform a conversion to a multiple of 16.
That is, (1.6 * X) / 16. The operation can be done entirely with
shifts and adds. As a quick approximation I came up with:
(X + (X >> 1) + (X >> 4) + (X >> 5)) >> 4 = X / 10.
This calculation yields (1.59375 * X) / 16 (0.3% error). You can get
even closer with more shifting, but it rapidly becomes more costly
than a look-up table in run-time processing.
------ End of Forwarded Message ------
Andrew Warren - ix.netcom.comfastfwd
Fast Forward Engineering, Vista, California
More... (looser matching)
- Last day of these posts
- In 1996
, 1997 only
- New search...