commons-issues mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Gal Lalouche (JIRA)" <j...@apache.org>
Subject [jira] [Created] (MATH-1068) KendallsCorrelation suffers from integer overflow for large arrays.
Date Sun, 01 Dec 2013 11:49:35 GMT
Gal Lalouche created MATH-1068:
----------------------------------

             Summary: KendallsCorrelation suffers from integer overflow for large arrays.
                 Key: MATH-1068
                 URL: https://issues.apache.org/jira/browse/MATH-1068
             Project: Commons Math
          Issue Type: Bug
    Affects Versions: 3.3
            Reporter: Gal Lalouche
            Priority: Minor
             Fix For: 3.3


For large array size (say, over 5,000), numPairs > 10 million.
in line 258, (numPairs - tiedXPairs) * (numPairs - tiedYPairs) possibly > 100 billion,
which will cause an integer overflow, resulting in a negative number, which will result in
the end result in a NaN since the square-root of that number is calculated.
This can easily be solved by changing line 163 to
final long numPairs = ((long)n) * (n - 1) / 2; // to avoid overflow



--
This message was sent by Atlassian JIRA
(v6.1#6144)

Mime
View raw message