-
Notifications
You must be signed in to change notification settings - Fork 173
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
fix(factorial): result should be of the default kind, not double default kind #876
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM. @jvdp1 what do you think?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM. Thank you @cyrilgandon
Thank you @cyrilgandon . I will merge this PR. |
Fixes #875
The parameter
1.0D0
is 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_gamma
function.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_gamma
function. 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.