MATH-849: Gamma.gamma(double) returns NaN if called on negative integer.
git-svn-id: https://svn.apache.org/repos/asf/commons/proper/math/trunk@1413802 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
f348a29e5f
commit
fec7740958
|
@ -706,7 +706,9 @@ public class Gamma {
|
|||
*/
|
||||
public static double gamma(final double x) {
|
||||
|
||||
// TODO Check whether x is a negative integer
|
||||
if ((x == FastMath.rint(x)) && (x <= 0.0)) {
|
||||
return Double.NaN;
|
||||
}
|
||||
|
||||
final double ret;
|
||||
final double absX = FastMath.abs(x);
|
||||
|
|
|
@ -954,6 +954,14 @@ public class GammaTest {
|
|||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testGammaNegativeInteger() {
|
||||
|
||||
for (int i = -100; i <= 0; i++) {
|
||||
Assert.assertTrue(Integer.toString(i), Double.isNaN(Gamma.gamma(i)));
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Reference data for the {@link Gamma#logGammaSum(double, double)}
|
||||
* function. This data was generated with the following
|
||||
|
|
Loading…
Reference in New Issue