Re: division problem
- From: dcorbit@xxxxxxxxx
- Date: 26 Dec 2006 16:54:19 -0800
David T. Ashley wrote:
<dcorbit@xxxxxxxxx> wrote in message
news:1167146673.002013.64670@xxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
To do division efficently, the classical solution is to use Newton's
methd.
http://en.wikipedia.org/wiki/Division_(digital)
It might be a bit crunchy to use it on integers, so why not just
perform a double division and then assign it? I guess that it is a
lot faster than emulating hardware.
The IBM Jikes Compiler has a 64 bit number class for 32 bit machines.
It is C++ but it would not be too hard to convert it to be C function
calls.
It appears that the method won't pay off over classic division until the
operands are fairly large:
http://www.swox.com/list-archives/gmp-discuss/2006-November/002549.html
For the kind of work I do, 64 bits is a HUGE integer (eight bytes, wow!). I
need to read up on this.
They are not comparing Newton's method to classic method.
See:
http://swox.com/gmp/devel/
in the section: "New division code"
If you use the floating point hardware to approximate the answer, and
then use the approximation given (it will be good to about 15 digits on
most machines) then one iteration of Newton's method would give you 30
digits of precision, two iterations of Newton's method would give you
60 digits, three iterations 120 digits, etc.
.
- Follow-Ups:
- Re: division problem
- From: dcorbit
- Re: division problem
- References:
- division problem
- From: jamesonang@xxxxxxxxx
- Re: division problem
- From: David T. Ashley
- Re: division problem
- From: Richard Heathfield
- Re: division problem
- From: David T. Ashley
- Re: division problem
- From: dcorbit
- Re: division problem
- From: David T. Ashley
- division problem
- Prev by Date: Re: c / c++ : is it end of era ?
- Next by Date: Re: Files & dirs: historical reasons?
- Previous by thread: Re: division problem
- Next by thread: Re: division problem
- Index(es):
Relevant Pages
|