Faster divides

sdenman@wolf.cs.washington.edu (Stuart Denman)
Sat, 14 Oct 1995 10:18:15 GMT

          From comp.compilers

Related articles
Faster divides sdenman@wolf.cs.washington.edu (1995-10-14)
Re: Faster divides idr@cs.pdx.edu (1995-10-23)
Re: Faster divides cdg@nullstone.com (1995-10-25)
| List of all articles for this month |

Newsgroups: comp.graphics.algorithms,comp.compilers
From: sdenman@wolf.cs.washington.edu (Stuart Denman)
Keywords: arithmetic, performance, question
Organization: Computer Science & Engineering, U of Washington, Seattle
Date: Sat, 14 Oct 1995 10:18:15 GMT

I remember someone saying there was a trick to speed up something like this
where you have all long variables and you divide multiple times by the same
value:


long dsh,dtx,dty,dy;
...do some calculations to find values for them...
dsh = (dsh << 16) / dy;
dtx = (dtx << 16) / dy;
dty = (dty << 16) / dy;


I tried using 3 floating-point multiplies, but that is way slower, even on
a Pentium due to the large speed hit of converting back-and-forth from
integer to floating-point.


Does anyone know of an algorithm to speed this up without having to do these
3 very similar divides? It seems like there would be one since you are
dividing by the exact same value!


Thanks for any help you can offer,


Stuart Denman
sdenman@cs.washington.edu
























--


Post a followup to this message

Return to the comp.compilers page.
Search the comp.compilers archives again.