src/share/classes/java/lang/StrictMath.java

Print this page

        

@@ -23,11 +23,10 @@
  * questions.
  */
 
 package java.lang;
 import java.util.Random;
-import sun.misc.FpUtils;
 import sun.misc.DoubleConsts;
 
 /**
  * The class {@code StrictMath} contains methods for performing basic
  * numeric operations such as the elementary exponential, logarithm,

@@ -426,11 +425,11 @@
          * cannot overflow or meaningfully underflow.  Finally, the
          * last multiply in the return statement is by plus or minus
          * 1.0, which is exact too.
          */
         double twoToThe52 = (double)(1L << 52); // 2^52
-        double sign = FpUtils.rawCopySign(1.0, a); // preserve sign info
+        double sign = Math.copySign(1.0, a); // preserve sign info
         a = Math.abs(a);
 
         if (a < twoToThe52) { // E_min <= ilogb(a) <= 51
             a = ((twoToThe52 + a ) - twoToThe52);
         }

@@ -953,11 +952,11 @@
      * @return the size of an ulp of the argument
      * @author Joseph D. Darcy
      * @since 1.5
      */
     public static double ulp(double d) {
-        return sun.misc.FpUtils.ulp(d);
+        return Math.ulp(d);
     }
 
     /**
      * Returns the size of an ulp of the argument.  An ulp, unit in
      * the last place, of a {@code float} value is the positive

@@ -980,11 +979,11 @@
      * @return the size of an ulp of the argument
      * @author Joseph D. Darcy
      * @since 1.5
      */
     public static float ulp(float f) {
-        return sun.misc.FpUtils.ulp(f);
+        return Math.ulp(f);
     }
 
     /**
      * Returns the signum function of the argument; zero if the argument
      * is zero, 1.0 if the argument is greater than zero, -1.0 if the

@@ -1001,11 +1000,11 @@
      * @return the signum function of the argument
      * @author Joseph D. Darcy
      * @since 1.5
      */
     public static double signum(double d) {
-        return sun.misc.FpUtils.signum(d);
+        return Math.signum(d);
     }
 
     /**
      * Returns the signum function of the argument; zero if the argument
      * is zero, 1.0f if the argument is greater than zero, -1.0f if the

@@ -1022,11 +1021,11 @@
      * @return the signum function of the argument
      * @author Joseph D. Darcy
      * @since 1.5
      */
     public static float signum(float f) {
-        return sun.misc.FpUtils.signum(f);
+        return Math.signum(f);
     }
 
     /**
      * Returns the hyperbolic sine of a {@code double} value.
      * The hyperbolic sine of <i>x</i> is defined to be

@@ -1200,11 +1199,11 @@
      * @return a value with the magnitude of {@code magnitude}
      * and the sign of {@code sign}.
      * @since 1.6
      */
     public static double copySign(double magnitude, double sign) {
-        return sun.misc.FpUtils.copySign(magnitude, sign);
+        return Math.copySign(magnitude, (Double.isNaN(sign)?1.0d:sign));
     }
 
     /**
      * Returns the first floating-point argument with the sign of the
      * second floating-point argument.  For this method, a NaN

@@ -1216,11 +1215,11 @@
      * @return a value with the magnitude of {@code magnitude}
      * and the sign of {@code sign}.
      * @since 1.6
      */
     public static float copySign(float magnitude, float sign) {
-        return sun.misc.FpUtils.copySign(magnitude, sign);
+        return Math.copySign(magnitude, (Float.isNaN(sign)?1.0f:sign));
     }
     /**
      * Returns the unbiased exponent used in the representation of a
      * {@code float}.  Special cases:
      *

@@ -1232,11 +1231,11 @@
      * </ul>
      * @param f a {@code float} value
      * @since 1.6
      */
     public static int getExponent(float f) {
-        return sun.misc.FpUtils.getExponent(f);
+        return Math.getExponent(f);
     }
 
     /**
      * Returns the unbiased exponent used in the representation of a
      * {@code double}.  Special cases:

@@ -1249,11 +1248,11 @@
      * </ul>
      * @param d a {@code double} value
      * @since 1.6
      */
     public static int getExponent(double d) {
-        return sun.misc.FpUtils.getExponent(d);
+        return Math.getExponent(d);
     }
 
     /**
      * Returns the floating-point number adjacent to the first
      * argument in the direction of the second argument.  If both

@@ -1292,11 +1291,11 @@
      * @return The floating-point number adjacent to {@code start} in the
      * direction of {@code direction}.
      * @since 1.6
      */
     public static double nextAfter(double start, double direction) {
-        return sun.misc.FpUtils.nextAfter(start, direction);
+        return Math.nextAfter(start, direction);
     }
 
     /**
      * Returns the floating-point number adjacent to the first
      * argument in the direction of the second argument.  If both

@@ -1334,11 +1333,11 @@
      * @return The floating-point number adjacent to {@code start} in the
      * direction of {@code direction}.
      * @since 1.6
      */
     public static float nextAfter(float start, double direction) {
-        return sun.misc.FpUtils.nextAfter(start, direction);
+        return Math.nextAfter(start, direction);
     }
 
     /**
      * Returns the floating-point value adjacent to {@code d} in
      * the direction of positive infinity.  This method is

@@ -1363,11 +1362,11 @@
      * @return The adjacent floating-point value closer to positive
      * infinity.
      * @since 1.6
      */
     public static double nextUp(double d) {
-        return sun.misc.FpUtils.nextUp(d);
+        return Math.nextUp(d);
     }
 
     /**
      * Returns the floating-point value adjacent to {@code f} in
      * the direction of positive infinity.  This method is

@@ -1392,14 +1391,13 @@
      * @return The adjacent floating-point value closer to positive
      * infinity.
      * @since 1.6
      */
     public static float nextUp(float f) {
-        return sun.misc.FpUtils.nextUp(f);
+        return Math.nextUp(f);
     }
 
-
     /**
      * Return {@code d} &times;
      * 2<sup>{@code scaleFactor}</sup> rounded as if performed
      * by a single correctly rounded floating-point multiply to a
      * member of the double value set.  See the Java

@@ -1427,11 +1425,11 @@
      * @param scaleFactor power of 2 used to scale {@code d}
      * @return {@code d} &times; 2<sup>{@code scaleFactor}</sup>
      * @since 1.6
      */
     public static double scalb(double d, int scaleFactor) {
-        return sun.misc.FpUtils.scalb(d, scaleFactor);
+        return Math.scalb(d, scaleFactor);
     }
 
     /**
      * Return {@code f} &times;
      * 2<sup>{@code scaleFactor}</sup> rounded as if performed

@@ -1461,8 +1459,8 @@
      * @param scaleFactor power of 2 used to scale {@code f}
      * @return {@code f} &times; 2<sup>{@code scaleFactor}</sup>
      * @since 1.6
      */
     public static float scalb(float f, int scaleFactor) {
-        return sun.misc.FpUtils.scalb(f, scaleFactor);
+        return Math.scalb(f, scaleFactor);
     }
 }