Re: gamma() and lgamma() functions - Mailing list pgsql-hackers

From Dean Rasheed
Subject Re: gamma() and lgamma() functions
Date
Msg-id CAEZATCWm7NdTiCN9CbaVEkgcEb0UT7enxnxwck5BHvVR28658g@mail.gmail.com
Whole thread Raw
In response to Re: gamma() and lgamma() functions  (Dean Rasheed <dean.a.rasheed@gmail.com>)
List pgsql-hackers
On Thu, 14 Nov 2024 at 22:35, Dean Rasheed <dean.a.rasheed@gmail.com> wrote:
>
> On Thu, 14 Nov 2024 at 16:28, Dmitry Koval <d.koval@postgrespro.ru> wrote:
> >
> >  >SELECT gamma(float8 '1e-320');
> > ERROR:  value out of range: overflow
> >
> >  >SELECT gamma(float8 '0');
> >    gamma
> > ----------
> >   Infinity
> > (1 row)
> >
> > Perhaps it would be logical if the behavior in these cases was the same
> > (either ERROR or 'Infinity')?
>
> In general, I think that having gamma() throw overflow errors is
> useful for spotting real problems in user code.
>

Thinking about this afresh, I remain of the opinion that having the
gamma function throw overflow errors is useful for inputs that are too
large, like gamma(200). But then, if we're going to do that, maybe we
should just do the same for other invalid inputs (zero, negative
integers, and -Inf). That resolves the consistency issue with inputs
very close to zero, and seems like a practical solution.

Attached is an update doing that.

Regards,
Dean

Attachment

pgsql-hackers by date:

Previous
From: jian he
Date:
Subject: Re: bug when apply fast default mechanism for adding new column over domain with default value
Next
From: Alex Friedman
Date:
Subject: Re: Doc: clarify possibility of ephemeral discrepancies between state and wait_event in pg_stat_activity