Re: Extended-Precision Division
- From: "Matt" <spamtrap@xxxxxxxxxx>
- Date: Tue, 5 Apr 2005 10:01:14 +0000 (UTC)
Terje Mathisen wrote:
>> Matt wrote:
>>> Terje Mathisen wrote:
>>>
>>>> Matt wrote:
>>>
>>> [...]
>>>
>>>>> The division isn't really avoidable, but it isn't part of a
>>>>> critical loop either. I am mostly interested because I know how
>>>>> to extend addition, subtraction, and multiplication out to
>>>>> arbitrary precisions. Division is the only one that I do not know
>>>>> about. It is easy to extend the numerator out to arbitrary
>>>>> precision, but the denominator does not easily follow.
>>>>
>>>> Not at all:
>>>>
>>>> The easy way to solve your assumed problem _exactly_ is to
>>>> calculate a 65-bit accurate reciprocal value, and use this to
>>>> multiply the timestamp difference. Do a final shift, and you have
>>>> the same answer as you'd get from a full division.
>>>
>>> [...]
>>>
>>> Now that I think about it, this seems very reasonable. I can use a
>>> crappy shift-and-subtract algorithm, and I only pay that cost once.
>>> The multiplies may well be as fast as a single divide.
>>>
>>> I am still fairly interested in a more mathematical answer. At
>>> Grumble's recommendation, I have posted the same question in
>>> comp.programming, and already a couple of interesting replies have
>>> come up.
>>
>> The 65-bit reciprocal _will_ give mathematically exact answers.
>>
>> For a proof, search for the article Agner Fog wrote after he & I
>> reinvented the algorithm and proved that it works for all possible
>> combinations of divisor and dividend.
I know...I meant that I'd like to see the mathematics of how to perform long
division. Every grade school child taking Algebra can tell you that X/(Y +
Z) != X/Y * (Y + Z). A reciprocal multiply is a good solution, but it also
requires an existing reciprocal or division algorithm. IIRC reciprocal can
be computed iteratively with only multiplies, but...
I suppose for the reciprocal that means that for Q = X / Y I compute R =
2^65 / Y and Q = (X * R) >> 65?
How exactly do you come by 65-bit reciprocal? Rather, what is the
significance of 65 bits?
-Matt
.
- Follow-Ups:
- Re: Extended-Precision Division
- From: Terje Mathisen
- Re: Extended-Precision Division
- References:
- Extended-Precision Division
- From: Matt
- Re: Extended-Precision Division
- From: wolfgang kern
- Re: Extended-Precision Division
- From: Matt
- Re: Extended-Precision Division
- From: Terje Mathisen
- Re: Extended-Precision Division
- From: Matt
- Re: Extended-Precision Division
- From: Terje Mathisen
- Extended-Precision Division
- Prev by Date: Re: vga
- Next by Date: Re: Converting Binary Fractions to BCD
- Previous by thread: Re: Extended-Precision Division
- Next by thread: Re: Extended-Precision Division
- Index(es):
Relevant Pages
|