Skip to content

Conversation

@tompng
Copy link
Member

@tompng tompng commented Dec 12, 2025

There are many non-integer negative x that gamma(x) intersects with +1 or -1.
For example: -2.4570247382208006, -2.7476826467274127, -3.14358088834998, -3.955294284858598 and so on.
Retry calculation with increased precision if the calculate value is not precise enough (by loss of significance error).

Fixes this bug:

BigMath.lgamma(BigDecimal('-2.4570247382208006230394541'), 20)
# => [0.7222029201935e-25, -1] # on master branch. doesn't have 20 digits.
# => [0.72220292018028449792e-25, -1] # this pull request

There are many non-integer negative x that gamma(x) intersects with +1 or -1.
Retry calculation with increased precision if the calculate value is not precise enough (by loss of significance error).
@mrkn mrkn merged commit 80d66c9 into ruby:master Dec 12, 2025
81 checks passed
@tompng tompng deleted the negative_lgamma_zero_fix branch December 12, 2025 17:50
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants