commons-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From s...@apache.org
Subject svn commit: r1060960 - /commons/proper/math/branches/MATH_2_X/src/main/java/org/apache/commons/math/util/FastMath.java
Date Wed, 19 Jan 2011 20:13:11 GMT
Author: sebb
Date: Wed Jan 19 20:13:11 2011
New Revision: 1060960

URL: http://svn.apache.org/viewvc?rev=1060960&view=rev
Log:
Ensure correct sign when toRadians() returns zero
[Not needed for toDegrees() as the calculation does not underflow]

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=1060960&r1=1060959&r2=1060960&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
Wed Jan 19 20:13:11 2011
@@ -3243,7 +3243,11 @@ public class FastMath {
         double xa = x + temp - temp;
         double xb = x - xa;
 
-        return xb * factb + xb * facta + xa * factb + xa * facta;
+        double result = xb * factb + xb * facta + xa * factb + xa * facta;
+        if (result == 0) {
+            result = result * x; // ensure correct sign
+        }
+        return result;
     }
 
     /**



Mime
View raw message