Re: numeric precision when raising one numeric to

From: Scott Marlowe <smarlowe(at)g2switchworks(dot)com>
To: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
Cc: "Jim C(dot) Nasby" <decibel(at)decibel(dot)org>, pgsql-general(at)postgresql(dot)org
Subject: Re: numeric precision when raising one numeric to
Date: 2005-05-20 17:29:10
Message-ID: 1116610150.31821.179.camel@state.g2switchworks.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general pgsql-patches

On Fri, 2005-05-20 at 12:03, Tom Lane wrote:
> "Jim C. Nasby" <decibel(at)decibel(dot)org> writes:
> > Why are we allowing implicit casts from numeric to floating point?
>
> Because the SQL spec requires it.
>
> 2) If the data type of either operand of a dyadic arithmetic op-
> erator is approximate numeric, then the data type of the re-
> sult is approximate numeric.
>
> It doesn't say to throw an error for mixed-type arithmetic.
>
> Now it also says
>
> 1) If the data type of both operands of a dyadic arithmetic opera-
> tor is exact numeric, then the data type of the result is exact
> numeric, ...
>
> which you could take as requiring us to provide numeric equivalents of
> every floating-point operator, but I don't find that argument very
> convincing for operations that are inherently not going to give exact
> results.

Are you saying that the exponent operator will return inexact results?
OR talking about other operators

> The spec demands exact results from addition, subtraction,
> and multiplication, but as soon as you get to division they punt; let
> alone transcendental functions.

If you're quoting the 92 spec, it seems to say that multiplication
precision is also implementation specific.

> But having said that, I don't have a problem with putting in a
> pg_operator entry for numeric_power. And if someone wants to improve
> the scale factor calculations therein, go for it.

OK, I'm gonna look at it this weekend. I might have some questions
before I really get anything working, this being my first real adventure
hacking pgsql.

> But so far there's
> been an extremely low signal-to-noise ratio in this thread ...

Really, I've found it quite informative. I see no reason to insult the
people who've contributed to it.

In response to

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Duane Winner 2005-05-20 17:35:38 Re: starting postgresql with pgsql password - workarounds?
Previous Message Florian G. Pflug 2005-05-20 17:27:13 Re: numeric precision when raising one numeric to another.

Browse pgsql-patches by date

  From Date Subject
Next Message Tom Lane 2005-05-20 18:26:08 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.