home *** CD-ROM | disk | FTP | other *** search
- Newsgroups: comp.sys.mac.programmer
- Path: sparky!uunet!munnari.oz.au!uniwa!cujo!ncrpda.curtin.edu.au!rocky.curtin.edu.au!user
- From: peter@cujo.curtin.edu.au (Peter N Lewis)
- Subject: Re: faster division routine wanted.
- Message-ID: <peter-220193094640@rocky.curtin.edu.au>
- Followup-To: comp.sys.mac.programmer
- Lines: 26
- Sender: news@ncrpda.curtin.edu.au
- Nntp-Posting-Host: ncrpda.curtin.edu.au
- Organization: NCRPDA, Curtin University
- References: <5662@daily-planet.concordia.ca> <sage.cc.purdue.edu-200193155236@seib.cc.purdue.edu> <1993Jan21.011218.12052@hobbes.kzoo.edu>
- Date: Fri, 22 Jan 1993 01:51:44 GMT
-
- In article <1993Jan21.011218.12052@hobbes.kzoo.edu>,
- k044477@hobbes.kzoo.edu (Jamie R. McCarthy) wrote:
-
- > If you really need speed, and you're on a 68000, build a 65,536-byte
- > lookup table, so that x/1000==table[x]. Fourteen cycles. Can't beat it!
-
- Hmmm, if you divide a 2 byte number by 1000, you can only get one of 65
- possible answers, there should be a way of using that information to make
- it more efficient.
-
- For one thing, you could make a 8192-byte lookup table so that
- x/125==table[x], and then calculate table[x>>3]. An 8k table is a lot more
- acceptable than a 64k table.
-
- Another possiblity is that you could use the fact that 1000 is almost 1024.
- Then build a 65-word lookup table with x*1000==table[x], and do this:
- y = x >> 10; ie, x/1024
- if table[y+1]<=x then y++;
- (watch out for overflow if x could be >64536, also watch out for signed
- number problems).
-
- Just some random ideas, I'd use the DIV instruction :-)
- Peter.
-
- _______________________________________________________________________
- Peter N Lewis <peter@cujo.curtin.edu.au> Ph: +61 9 368 2055
-