commons-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From m...@apache.org
Subject svn commit: r1349372 - /commons/proper/math/trunk/src/main/java/org/apache/commons/math3/stat/inference/MannWhitneyUTest.java
Date Tue, 12 Jun 2012 14:27:57 GMT
Author: mikl
Date: Tue Jun 12 14:27:56 2012
New Revision: 1349372

URL: http://svn.apache.org/viewvc?rev=1349372&view=rev
Log:
MATH-790: Patch applied to fix the second overflow issue.

Modified:
    commons/proper/math/trunk/src/main/java/org/apache/commons/math3/stat/inference/MannWhitneyUTest.java

Modified: commons/proper/math/trunk/src/main/java/org/apache/commons/math3/stat/inference/MannWhitneyUTest.java
URL: http://svn.apache.org/viewvc/commons/proper/math/trunk/src/main/java/org/apache/commons/math3/stat/inference/MannWhitneyUTest.java?rev=1349372&r1=1349371&r2=1349372&view=diff
==============================================================================
--- commons/proper/math/trunk/src/main/java/org/apache/commons/math3/stat/inference/MannWhitneyUTest.java
(original)
+++ commons/proper/math/trunk/src/main/java/org/apache/commons/math3/stat/inference/MannWhitneyUTest.java
Tue Jun 12 14:27:56 2012
@@ -170,7 +170,10 @@ public class MannWhitneyUTest {
                                              final int n2)
         throws ConvergenceException, MaxCountExceededException {
 
-        final double n1n2prod = n1 * n2;
+        /* long multiplication to avoid overflow (double not used due to efficiency 
+         * and to avoid precision loss)
+         */
+        final long n1n2prod = (long) n1 * n2;
 
         // http://en.wikipedia.org/wiki/Mann%E2%80%93Whitney_U#Normal_approximation
         final double EU = n1n2prod / 2.0;



Mime
View raw message