commons-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From s...@apache.org
Subject svn commit: r1060060 - in /commons/proper/math/trunk/src: main/java/org/apache/commons/math/util/FastMath.java site/xdoc/changes.xml test/java/org/apache/commons/math/util/FastMathTest.java
Date Mon, 17 Jan 2011 19:55:01 GMT
Author: sebb
Date: Mon Jan 17 19:55:01 2011
New Revision: 1060060

URL: http://svn.apache.org/viewvc?rev=1060060&view=rev
Log:
MATH-482 FastMath.max(50.0f, -50.0f) => -50.0f; should be +50.0f

Modified:
    commons/proper/math/trunk/src/main/java/org/apache/commons/math/util/FastMath.java
    commons/proper/math/trunk/src/site/xdoc/changes.xml
    commons/proper/math/trunk/src/test/java/org/apache/commons/math/util/FastMathTest.java

Modified: commons/proper/math/trunk/src/main/java/org/apache/commons/math/util/FastMath.java
URL: http://svn.apache.org/viewvc/commons/proper/math/trunk/src/main/java/org/apache/commons/math/util/FastMath.java?rev=1060060&r1=1060059&r2=1060060&view=diff
==============================================================================
--- commons/proper/math/trunk/src/main/java/org/apache/commons/math/util/FastMath.java (original)
+++ commons/proper/math/trunk/src/main/java/org/apache/commons/math/util/FastMath.java Mon
Jan 17 19:55:01 2011
@@ -3479,7 +3479,7 @@ public class FastMath {
      * @return b if a is lesser or equal to b, a otherwise
      */
     public static float max(final float a, final float b) {
-        return (a <= b) ? b : (Float.isNaN(a + b) ? Float.NaN : b);
+        return (a <= b) ? b : (Float.isNaN(a + b) ? Float.NaN : a);
     }
 
     /** Compute the maximum of two values

Modified: commons/proper/math/trunk/src/site/xdoc/changes.xml
URL: http://svn.apache.org/viewvc/commons/proper/math/trunk/src/site/xdoc/changes.xml?rev=1060060&r1=1060059&r2=1060060&view=diff
==============================================================================
--- commons/proper/math/trunk/src/site/xdoc/changes.xml (original)
+++ commons/proper/math/trunk/src/site/xdoc/changes.xml Mon Jan 17 19:55:01 2011
@@ -52,6 +52,10 @@ The <action> type attribute can be add,u
     If the output is not quite correct, check for invisible trailing spaces!
      -->
     <release version="3.0" date="TBD" description="TBD">
+      <action dev="sebb" type="fix" issue="MATH-82">
+        FastMath.max(50.0f, -50.0f) => -50.0f; should be +50.0f
+        Fixed FastMath.max(float, float) so it returns correct value.
+      </action>
       <action dev="erans" type="fix" issue="MATH-458">
         Removed "MathException" from the "throws" clause of the "interpolate" method
         of the interpolators interfaces (package "analysis.interpolation").

Modified: commons/proper/math/trunk/src/test/java/org/apache/commons/math/util/FastMathTest.java
URL: http://svn.apache.org/viewvc/commons/proper/math/trunk/src/test/java/org/apache/commons/math/util/FastMathTest.java?rev=1060060&r1=1060059&r2=1060060&view=diff
==============================================================================
--- commons/proper/math/trunk/src/test/java/org/apache/commons/math/util/FastMathTest.java
(original)
+++ commons/proper/math/trunk/src/test/java/org/apache/commons/math/util/FastMathTest.java
Mon Jan 17 19:55:01 2011
@@ -76,18 +76,18 @@ public class FastMathTest {
 
     @Test
     public void testMinMaxFloat() {
-        double[][] pairs = {
-            { -50.0, 50.0 },
-            {  Float.POSITIVE_INFINITY, 1.0 },
-            {  Float.NEGATIVE_INFINITY, 1.0 },
-            {  Float.NaN, 1.0 },
-            {  Float.POSITIVE_INFINITY, 0.0 },
-            {  Float.NEGATIVE_INFINITY, 0.0 },
-            {  Float.NaN, 0.0 },
+        float[][] pairs = {
+            { -50.0f, 50.0f },
+            {  Float.POSITIVE_INFINITY, 1.0f },
+            {  Float.NEGATIVE_INFINITY, 1.0f },
+            {  Float.NaN, 1.0f },
+            {  Float.POSITIVE_INFINITY, 0.0f },
+            {  Float.NEGATIVE_INFINITY, 0.0f },
+            {  Float.NaN, 0.0f },
             {  Float.NaN, Float.NEGATIVE_INFINITY },
             {  Float.NaN, Float.POSITIVE_INFINITY }
         };
-        for (double[] pair : pairs) {
+        for (float[] pair : pairs) {
             Assert.assertEquals("min(" + pair[0] + ", " + pair[1] + ")",
                                 Math.min(pair[0], pair[1]),
                                 FastMath.min(pair[0], pair[1]),



Mime
View raw message