From: | Dmitry Koval <d(dot)koval(at)postgrespro(dot)ru> |
---|---|
To: | pgsql-hackers(at)lists(dot)postgresql(dot)org |
Subject: | Re: gamma() and lgamma() functions |
Date: | 2024-11-14 16:28:27 |
Message-ID: | ab47e6b1-95f9-4de2-9224-f7750e7b2373@postgrespro.ru |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-hackers |
Hi!
I think having gamma() and lgamma() functions in PostgreSQL would be
useful for some users, this is asked [1].
I have a question regarding the current implementation of gamma()
function. Code block:
+ if (errno == ERANGE && arg1 != 0)
+ {
+ if (result != 0.0)
+ float_overflow_error();
+ else
+ float_underflow_error();
+ }
+ else if (isinf(result) && arg1 != 0 && !isinf(arg1))
+ float_overflow_error();
+ else if (result == 0.0)
+ float_underflow_error();
Why in some cases (if arg1 is close to 0, but not 0) an error
(float_overflow_error) will be returned, but in the case of "arg1 = 0"
the value 'Infinity' will be returned?
For example:
>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')?
--
With best regards,
Dmitry Koval
Postgres Professional: http://postgrespro.com
From | Date | Subject | |
---|---|---|---|
Next Message | Christoph Berg | 2024-11-14 16:29:18 | Re: Potential ABI breakage in upcoming minor releases |
Previous Message | Peter Eisentraut | 2024-11-14 16:13:35 | Re: Potential ABI breakage in upcoming minor releases |