Re: numeric precision when raising one numeric to another.

From: "Florian G(dot) Pflug" <fgp(at)phlo(dot)org>
To: Martijn van Oosterhout <kleptog(at)svana(dot)org>
Cc: Dann Corbit <DCorbit(at)connx(dot)com>, Alvaro Herrera <alvherre(at)surnet(dot)cl>, John Burger <john(at)mitre(dot)org>, pgsql-general(at)postgresql(dot)org
Subject: Re: numeric precision when raising one numeric to another.
Date: 2005-05-20 17:23:40
Message-ID: 428E1D1C.8060301@phlo.org
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

Martijn van Oosterhout wrote:
> On Thu, May 19, 2005 at 02:25:58PM -0700, Dann Corbit wrote:
>
>>Hmmm....
>>I underestimated.
>>
>>pow(99999.99999,99999.99999) =
>
>
> Yeah, a number with x digits raised to the power with something y digits
> long could have a length approximating:
>
> x * (10^y) digits
>
> So two numbers both 4 digits long can have a result of upto 40,000
> digits. You're only going to be able to them represent exactly for
> cases where y is small and integer.
>
> What's a meaningful limit? Do we simply say, you get upto 100 digits
> and that's it? Or an extra parameter so you can specify directly?
I believe that even this limit is wrong. Consider sqrt(2), which is
2^(1/2).
2 has 1 digit, 1/2 has 2 digits, but the result is irrational, and
therefor cannot be represented with a finit amount of digits.

I believe that there is no mathematically correct way (i.e. a way which
guarantees a 100% correct result) to define pow(numeric, numeric) - at
least in the general case.

In response to

Browse pgsql-general by date

  From Date Subject
Next Message Florian G. Pflug 2005-05-20 17:27:13 Re: numeric precision when raising one numeric to another.
Previous Message Jim C. Nasby 2005-05-20 17:22:33 Re: numeric precision when raising one numeric to another.