Author: sebb
Date: Wed Jan 19 20:12:38 2011
New Revision: 1060959
URL: http://svn.apache.org/viewvc?rev=1060959&view=rev
Log:
Ensure correct sign when toRadians() returns zero
[Not needed for toDegrees() as the calculation does not underflow]
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=1060959&r1=1060958&r2=1060959&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
Wed Jan 19 20:12:38 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;
}
/**