[
https://issues.apache.org/jira/browse/MATH-240?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
]
Christian Semrau updated MATH-240:
----------------------------------
Description:
The result of MathUtils.factorial( n ) for n = 17, 18, 19 is wrong, probably
because of rounding errors in the double calculations.
Replace the first line of MathUtilsTest.testFactorial() by
for (int i = 1; i <= 20; i++) {
to check all valid arguments for the long result and see the failure.
I suggest implementing a simple loop to multiply the long result - or even
using a precomputed long[] - instead of adding logarithms.
was:
The result of MathUtils.factorial( n ) for n = 17...20 is wrong, probably
because of rounding errors in the double calculations.
Replace the first line of MathUtilsTest.testFactorial() by
for (int i = 1; i <= 20; i++) {
to check all valid arguments for the long result and see the failure.
> MathUtils.factorial(n) fails for n >= 17
> ----------------------------------------
>
> Key: MATH-240
> URL: https://issues.apache.org/jira/browse/MATH-240
> Project: Commons Math
> Issue Type: Bug
> Affects Versions: 2.0
> Reporter: Christian Semrau
> Priority: Minor
>
> The result of MathUtils.factorial( n ) for n = 17, 18, 19 is wrong, probably
> because of rounding errors in the double calculations.
> Replace the first line of MathUtilsTest.testFactorial() by
> for (int i = 1; i <= 20; i++) {
> to check all valid arguments for the long result and see the failure.
> I suggest implementing a simple loop to multiply the long result - or even
> using a precomputed long[] - instead of adding logarithms.
--
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.