Re: Arbitrary precision modulo operation - Mailing list pgsql-general

From Tom Lane
Subject Re: Arbitrary precision modulo operation
Date
Msg-id 16943.1083274288@sss.pgh.pa.us
Whole thread Raw
In response to Re: Arbitrary precision modulo operation  ("Dann Corbit" <DCorbit@connx.com>)
List pgsql-general
"Dann Corbit" <DCorbit@connx.com> writes:
> From: Tom Lane [mailto:tgl@sss.pgh.pa.us]
>> Fine.  How many is that, exactly?

> Here is what I would suggest:
> Using the outline I proposed before (starting with a floating point
> divide of DBL_DIG digits of precision), keep doubling the precision
> until the precision is 5 digits larger than either operand.  If the last
> doubling makes the precision larger (quite likely) simply reduce it to
> the smaller margin.

And this guarantees a correct answer why?

AFAIK div_var is already correct per its spec, which is that it
generates an answer rounded to the requested number of digits.
The question at hand is what number of digits to request.

After thinking about it I don't see any reason that DBL_DIG has
anything to do with a non-surprising answer ... much less "DBL_DIG + 5"
which seems picked out of the air ...

            regards, tom lane

pgsql-general by date:

Previous
From: "Dann Corbit"
Date:
Subject: Re: Arbitrary precision modulo operation
Next
From: "Karl O. Pinc"
Date:
Subject: Plpgsql problem passing ROWTYPE to function