commons-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From s...@apache.org
Subject svn commit: r1062040 - /commons/proper/math/trunk/src/main/java/org/apache/commons/math/util/FastMath.java
Date Fri, 21 Jan 2011 21:46:13 GMT
Author: sebb
Date: Fri Jan 21 21:46:13 2011
New Revision: 1062040

URL: http://svn.apache.org/viewvc?rev=1062040&view=rev
Log:
MATH-493 FastMath min and max fail with (Infinity,-Infinity)
(still to fix zero case)

Modified:
    commons/proper/math/trunk/src/main/java/org/apache/commons/math/util/FastMath.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=1062040&r1=1062039&r2=1062040&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 Fri
Jan 21 21:46:13 2011
@@ -3620,7 +3620,7 @@ public class FastMath {
      * @return a if a is lesser or equal to b, b otherwise
      */
     public static float min(final float a, final float b) {
-        return (a <= b) ? a : (Float.isNaN(a + b) ? Float.NaN : b);
+        return (a <= b) ? a : ((a!=a||b!=b) ? Float.NaN : b);
     }
 
     /** Compute the minimum of two values
@@ -3629,7 +3629,7 @@ public class FastMath {
      * @return a if a is lesser or equal to b, b otherwise
      */
     public static double min(final double a, final double b) {
-        return (a <= b) ? a : (Double.isNaN(a + b) ? Double.NaN : b);
+        return (a <= b) ? a : ((a!=a||b!=b) ? Double.NaN : b);
     }
 
     /** Compute the maximum of two values
@@ -3656,7 +3656,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 : a);
+        return (a < b) ? b : ((a!=a||b!=b) ? Float.NaN : a);
     }
 
     /** Compute the maximum of two values
@@ -3665,7 +3665,7 @@ public class FastMath {
      * @return b if a is lesser or equal to b, a otherwise
      */
     public static double max(final double a, final double b) {
-        return (a <= b) ? b : (Double.isNaN(a + b) ? Double.NaN : a);
+        return (a <= b) ? b : ((a!=a||b!=b) ? Double.NaN : a);
     }
 
     /**
@@ -3685,6 +3685,7 @@ public class FastMath {
     public static double hypot(double x, double y) {
         return StrictMath.hypot(x, y); // TODO provide our own implementation
     }
+
     /**
      * Computes the remainder as prescribed by the IEEE 754 standard.
      * The remainder value is mathematically equal to {@code x - y*n}



Mime
View raw message