You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@commons.apache.org by se...@apache.org on 2011/01/21 22:45:30 UTC
svn commit: r1062038 -
/commons/proper/math/branches/MATH_2_X/src/main/java/org/apache/commons/math/util/FastMath.java
Author: sebb
Date: Fri Jan 21 21:45:29 2011
New Revision: 1062038
URL: http://svn.apache.org/viewvc?rev=1062038&view=rev
Log:
MATH-493 FastMath min and max fail with (Infinity,-Infinity)
(still to fix zero case)
Modified:
commons/proper/math/branches/MATH_2_X/src/main/java/org/apache/commons/math/util/FastMath.java
Modified: commons/proper/math/branches/MATH_2_X/src/main/java/org/apache/commons/math/util/FastMath.java
URL: http://svn.apache.org/viewvc/commons/proper/math/branches/MATH_2_X/src/main/java/org/apache/commons/math/util/FastMath.java?rev=1062038&r1=1062037&r2=1062038&view=diff
==============================================================================
--- commons/proper/math/branches/MATH_2_X/src/main/java/org/apache/commons/math/util/FastMath.java (original)
+++ commons/proper/math/branches/MATH_2_X/src/main/java/org/apache/commons/math/util/FastMath.java Fri Jan 21 21:45:29 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}