Re: NUMERIC's transcendental functions

From: Bruce Momjian <pgman(at)candle(dot)pha(dot)pa(dot)us>
To: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
Cc: Jan Wieck <JanWieck(at)Yahoo(dot)com>, pgsql-hackers(at)postgresql(dot)org
Subject: Re: NUMERIC's transcendental functions
Date: 2002-09-23 01:57:17
Message-ID: 200209230157.g8N1vHi22968@candle.pha.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers


When you say:

> So proposal #1 is to rip out the numeric versions of these functions.

you mean remove the ability to do transendentals on numerics to prevent
such unusual auto-casting? Are you suggesting that in all other cases,
autocast to numeric is OK? I am a little confused.

---------------------------------------------------------------------------

Tom Lane wrote:
> I have noticed a change in behavior following the recent changes for
> casting of numeric constants. In prior releases, we got
>
> regression=# select log(10.1);
> log
> ------------------
> 1.00432137378264
> (1 row)
>
> CVS tip gives
>
> regression=# select log(10.1);
> log
> --------------
> 1.0043213738
> (1 row)
>
> The reason for the change is that 10.1 used to be implicitly typed as
> float8, but now it's typed as numeric, so this command invokes
> log(numeric) instead of log(float8). And log(numeric)'s idea of
> adequate output precision seems low.
>
> Similar problems occur with sqrt(), exp(), ln(), pow().
>
> I realize that there's a certain amount of cuteness in being able to
> calculate these functions to arbitrary precision, but this is a database
> not a replacement for bc(1). ISTM the numeric datatype is intended for
> exact calculations, and so transcendental functions (which inherently
> have inexact results) don't belong.
>
> So proposal #1 is to rip out the numeric versions of these functions.
>
> If you're too attached to them, proposal #2 is to force them to
> calculate at least 16 digits of output, so that we aren't losing any
> accuracy compared to prior behavior.
>
> Comments?
>
> regards, tom lane
>
> ---------------------------(end of broadcast)---------------------------
> TIP 3: if posting/reading through Usenet, please send an appropriate
> subscribe-nomail command to majordomo(at)postgresql(dot)org so that your
> message can get through to the mailing list cleanly
>

--
Bruce Momjian | http://candle.pha.pa.us
pgman(at)candle(dot)pha(dot)pa(dot)us | (610) 359-1001
+ If your life is a hard drive, | 13 Roberts Road
+ Christ can be your backup. | Newtown Square, Pennsylvania 19073

In response to

Browse pgsql-hackers by date

  From Date Subject
Next Message Marc G. Fournier 2002-09-23 02:31:13 Re: PGXLOG variable worthwhile?
Previous Message Bruce Momjian 2002-09-23 01:53:25 Re: Memory Errors...