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/19 21:13:11 UTC

svn commit: r1060960 - /commons/proper/math/branches/MATH_2_X/src/main/java/org/apache/commons/math/util/FastMath.java

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;
     }
 
     /**