commons-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From s...@apache.org
Subject svn commit: r1062257 - /commons/proper/math/trunk/src/main/java/org/apache/commons/math/util/FastMath.java
Date Sat, 22 Jan 2011 20:26:11 GMT
Author: sebb
Date: Sat Jan 22 20:26:11 2011
New Revision: 1062257

URL: http://svn.apache.org/viewvc?rev=1062257&view=rev
Log:
Simplify code by using doubleHighPart

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=1062257&r1=1062256&r2=1062257&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 Sat
Jan 22 20:26:11 2011
@@ -3205,13 +3205,7 @@ public class FastMath {
           return Math.PI/2; // so return the appropriate value
       }
 
-      if (abs(r) < Double.MAX_VALUE/HEX_40000000){ // is it safe to split r ?
-          temp = r * HEX_40000000;
-      } else {
-          temp = 0.0;
-      }
-
-      double ra = r + temp - temp;
+      double ra = doubleHighPart(r);
       double rb = r - ra;
 
       rb += (y - ra*xa - ra*xb - rb*xa - rb*xb) / x;  // Correct for rounding in division
@@ -3323,11 +3317,7 @@ public class FastMath {
         final double facta = 0.01745329052209854;
         final double factb = 1.997844754509471E-9;
 
-        double temp = 0;
-        if (abs(x) < Double.MAX_VALUE/HEX_40000000) { // prevent overflow to infinity
-            temp = x * HEX_40000000;
-        }
-        double xa = x + temp - temp;
+        double xa = doubleHighPart(x);
         double xb = x - xa;
 
         double result = xb * factb + xb * facta + xa * factb + xa * facta;
@@ -3352,11 +3342,7 @@ public class FastMath {
         final double facta = 57.2957763671875;
         final double factb = 3.145894820876798E-6;
 
-        double temp = 0;
-        if (abs(x) < Double.MAX_VALUE/HEX_40000000) { // prevent overflow to infinity
-            temp = x * HEX_40000000;
-        }
-        double xa = x + temp - temp;
+        double xa = doubleHighPart(x);
         double xb = x - xa;
 
         return xb * factb + xb * facta + xa * factb + xa * facta;



Mime
View raw message