fix(factorial): result should be of the default kind, not double default kind#876
Conversation
perazz
left a comment
There was a problem hiding this comment.
LGTM, this looks like the right thing to do here. Thank you @cyrilgandon
|
After reading attentively the code, the 2nd parameter of the Here is some test on log(10!): |
|
@cyrilgandon, this is very interesting. It looks like the error here is close to |
cb6f989 to
c14c9d8
Compare
|
@perazz Yes!! I think it's an easy fix and should answer the problem. For most people having the default real(4), it will not change the result. |
|
If I read the OP's comment well, a double precision version (integer(int64) input as far as I understand) may benefit from a quad-precision internal calculation. |
|
Yes that makes sense, also rename zero_k2 to zero_dp, as the k2 paramter did not exist in this function |
|
Thank you @cyrilgandon . I will merge this PR. |
Fixes #875
The parameter
1.0D0is promoted to a real kind 16 when use in conjunction with the flag of gfortrandefault-real-8, and there is not such an overload for thel_gammafunction.Using a double precision number seems a bug here, nowhere else in the stdlib we have this usage.
Especially when the result is defined as a default real:
I don't see a reason to pass a double precision parameter to the
l_gammafunction. I propose to drop the double precision here.Edit: here is a comment by OP
#625 (comment)
So I'm not sure anymore that I should drop that double precision.
Maybe @Jim-215-Fisher can help here. What should happen if default real size is 64bit, should we still do calculation with 128bits real? I think not since most of architecture are not 128bits..
I'd say that double precision logic is included is the gamma functions, no need to have that at the level of the l_factorial.