1.1 --- a/emul/src/main/java/java/lang/StrictMath.java Sat Sep 29 11:37:46 2012 +0200
1.2 +++ b/emul/src/main/java/java/lang/StrictMath.java Sun Sep 30 18:29:37 2012 -0700
1.3 @@ -24,9 +24,6 @@
1.4 */
1.5
1.6 package java.lang;
1.7 -import java.util.Random;
1.8 -import sun.misc.FpUtils;
1.9 -import sun.misc.DoubleConsts;
1.10
1.11 /**
1.12 * The class {@code StrictMath} contains methods for performing basic
1.13 @@ -352,7 +349,7 @@
1.14 double negativeBoundary,
1.15 double positiveBoundary,
1.16 double sign) {
1.17 - int exponent = Math.getExponent(a);
1.18 + int exponent = getExponent(a);
1.19
1.20 if (exponent < 0) {
1.21 /*
1.22 @@ -373,7 +370,7 @@
1.23 assert exponent >= 0 && exponent <= 51;
1.24
1.25 long doppel = Double.doubleToRawLongBits(a);
1.26 - long mask = DoubleConsts.SIGNIF_BIT_MASK >> exponent;
1.27 + long mask = 0; // DoubleConsts.SIGNIF_BIT_MASK >> exponent;
1.28
1.29 if ( (mask & doppel) == 0L )
1.30 return a; // integral value
1.31 @@ -402,6 +399,7 @@
1.32 * @author Joseph D. Darcy
1.33 */
1.34 public static double rint(double a) {
1.35 + throw new UnsupportedOperationException();
1.36 /*
1.37 * If the absolute value of a is not less than 2^52, it
1.38 * is either a finite integer (the double format does not have
1.39 @@ -427,15 +425,15 @@
1.40 * last multiply in the return statement is by plus or minus
1.41 * 1.0, which is exact too.
1.42 */
1.43 - double twoToThe52 = (double)(1L << 52); // 2^52
1.44 - double sign = FpUtils.rawCopySign(1.0, a); // preserve sign info
1.45 - a = Math.abs(a);
1.46 -
1.47 - if (a < twoToThe52) { // E_min <= ilogb(a) <= 51
1.48 - a = ((twoToThe52 + a ) - twoToThe52);
1.49 - }
1.50 -
1.51 - return sign * a; // restore original sign
1.52 +// double twoToThe52 = (double)(1L << 52); // 2^52
1.53 +// double sign = FpUtils.rawCopySign(1.0, a); // preserve sign info
1.54 +// a = Math.abs(a);
1.55 +//
1.56 +// if (a < twoToThe52) { // E_min <= ilogb(a) <= 51
1.57 +// a = ((twoToThe52 + a ) - twoToThe52);
1.58 +// }
1.59 +//
1.60 +// return sign * a; // restore original sign
1.61 }
1.62
1.63 /**
1.64 @@ -659,13 +657,6 @@
1.65 return Math.round(a);
1.66 }
1.67
1.68 - private static Random randomNumberGenerator;
1.69 -
1.70 - private static synchronized Random initRNG() {
1.71 - Random rnd = randomNumberGenerator;
1.72 - return (rnd == null) ? (randomNumberGenerator = new Random()) : rnd;
1.73 - }
1.74 -
1.75 /**
1.76 * Returns a {@code double} value with a positive sign, greater
1.77 * than or equal to {@code 0.0} and less than {@code 1.0}.
1.78 @@ -690,9 +681,7 @@
1.79 * @see Random#nextDouble()
1.80 */
1.81 public static double random() {
1.82 - Random rnd = randomNumberGenerator;
1.83 - if (rnd == null) rnd = initRNG();
1.84 - return rnd.nextDouble();
1.85 + throw new UnsupportedOperationException();
1.86 }
1.87
1.88 /**
1.89 @@ -955,7 +944,7 @@
1.90 * @since 1.5
1.91 */
1.92 public static double ulp(double d) {
1.93 - return sun.misc.FpUtils.ulp(d);
1.94 + throw new UnsupportedOperationException();
1.95 }
1.96
1.97 /**
1.98 @@ -982,7 +971,7 @@
1.99 * @since 1.5
1.100 */
1.101 public static float ulp(float f) {
1.102 - return sun.misc.FpUtils.ulp(f);
1.103 + throw new UnsupportedOperationException();
1.104 }
1.105
1.106 /**
1.107 @@ -1003,7 +992,7 @@
1.108 * @since 1.5
1.109 */
1.110 public static double signum(double d) {
1.111 - return sun.misc.FpUtils.signum(d);
1.112 + throw new UnsupportedOperationException();
1.113 }
1.114
1.115 /**
1.116 @@ -1024,7 +1013,7 @@
1.117 * @since 1.5
1.118 */
1.119 public static float signum(float f) {
1.120 - return sun.misc.FpUtils.signum(f);
1.121 + throw new UnsupportedOperationException();
1.122 }
1.123
1.124 /**
1.125 @@ -1202,7 +1191,7 @@
1.126 * @since 1.6
1.127 */
1.128 public static double copySign(double magnitude, double sign) {
1.129 - return sun.misc.FpUtils.copySign(magnitude, sign);
1.130 + throw new UnsupportedOperationException();
1.131 }
1.132
1.133 /**
1.134 @@ -1218,7 +1207,7 @@
1.135 * @since 1.6
1.136 */
1.137 public static float copySign(float magnitude, float sign) {
1.138 - return sun.misc.FpUtils.copySign(magnitude, sign);
1.139 + throw new UnsupportedOperationException();
1.140 }
1.141 /**
1.142 * Returns the unbiased exponent used in the representation of a
1.143 @@ -1234,7 +1223,7 @@
1.144 * @since 1.6
1.145 */
1.146 public static int getExponent(float f) {
1.147 - return sun.misc.FpUtils.getExponent(f);
1.148 + throw new UnsupportedOperationException();
1.149 }
1.150
1.151 /**
1.152 @@ -1251,7 +1240,7 @@
1.153 * @since 1.6
1.154 */
1.155 public static int getExponent(double d) {
1.156 - return sun.misc.FpUtils.getExponent(d);
1.157 + throw new UnsupportedOperationException();
1.158 }
1.159
1.160 /**
1.161 @@ -1294,7 +1283,7 @@
1.162 * @since 1.6
1.163 */
1.164 public static double nextAfter(double start, double direction) {
1.165 - return sun.misc.FpUtils.nextAfter(start, direction);
1.166 + throw new UnsupportedOperationException();
1.167 }
1.168
1.169 /**
1.170 @@ -1336,7 +1325,7 @@
1.171 * @since 1.6
1.172 */
1.173 public static float nextAfter(float start, double direction) {
1.174 - return sun.misc.FpUtils.nextAfter(start, direction);
1.175 + throw new UnsupportedOperationException();
1.176 }
1.177
1.178 /**
1.179 @@ -1365,7 +1354,7 @@
1.180 * @since 1.6
1.181 */
1.182 public static double nextUp(double d) {
1.183 - return sun.misc.FpUtils.nextUp(d);
1.184 + throw new UnsupportedOperationException();
1.185 }
1.186
1.187 /**
1.188 @@ -1394,7 +1383,7 @@
1.189 * @since 1.6
1.190 */
1.191 public static float nextUp(float f) {
1.192 - return sun.misc.FpUtils.nextUp(f);
1.193 + throw new UnsupportedOperationException();
1.194 }
1.195
1.196
1.197 @@ -1429,7 +1418,7 @@
1.198 * @since 1.6
1.199 */
1.200 public static double scalb(double d, int scaleFactor) {
1.201 - return sun.misc.FpUtils.scalb(d, scaleFactor);
1.202 + throw new UnsupportedOperationException();
1.203 }
1.204
1.205 /**
1.206 @@ -1463,6 +1452,6 @@
1.207 * @since 1.6
1.208 */
1.209 public static float scalb(float f, int scaleFactor) {
1.210 - return sun.misc.FpUtils.scalb(f, scaleFactor);
1.211 + throw new UnsupportedOperationException();
1.212 }
1.213 }