1.1 --- a/emul/src/main/java/java/lang/Double.java Sat Sep 29 10:56:23 2012 +0200
1.2 +++ b/emul/src/main/java/java/lang/Double.java Sun Sep 30 18:29:37 2012 -0700
1.3 @@ -25,10 +25,6 @@
1.4
1.5 package java.lang;
1.6
1.7 -import sun.misc.FloatingDecimal;
1.8 -import sun.misc.FpUtils;
1.9 -import sun.misc.DoubleConsts;
1.10 -
1.11 /**
1.12 * The {@code Double} class wraps a value of the primitive type
1.13 * {@code double} in an object. An object of type
1.14 @@ -193,7 +189,7 @@
1.15 * @return a string representation of the argument.
1.16 */
1.17 public static String toString(double d) {
1.18 - return new FloatingDecimal(d).toJavaFormatString();
1.19 + throw new UnsupportedOperationException();
1.20 }
1.21
1.22 /**
1.23 @@ -271,61 +267,62 @@
1.24 * @author Joseph D. Darcy
1.25 */
1.26 public static String toHexString(double d) {
1.27 - /*
1.28 - * Modeled after the "a" conversion specifier in C99, section
1.29 - * 7.19.6.1; however, the output of this method is more
1.30 - * tightly specified.
1.31 - */
1.32 - if (!FpUtils.isFinite(d) )
1.33 - // For infinity and NaN, use the decimal output.
1.34 - return Double.toString(d);
1.35 - else {
1.36 - // Initialized to maximum size of output.
1.37 - StringBuffer answer = new StringBuffer(24);
1.38 -
1.39 - if (FpUtils.rawCopySign(1.0, d) == -1.0) // value is negative,
1.40 - answer.append("-"); // so append sign info
1.41 -
1.42 - answer.append("0x");
1.43 -
1.44 - d = Math.abs(d);
1.45 -
1.46 - if(d == 0.0) {
1.47 - answer.append("0.0p0");
1.48 - }
1.49 - else {
1.50 - boolean subnormal = (d < DoubleConsts.MIN_NORMAL);
1.51 -
1.52 - // Isolate significand bits and OR in a high-order bit
1.53 - // so that the string representation has a known
1.54 - // length.
1.55 - long signifBits = (Double.doubleToLongBits(d)
1.56 - & DoubleConsts.SIGNIF_BIT_MASK) |
1.57 - 0x1000000000000000L;
1.58 -
1.59 - // Subnormal values have a 0 implicit bit; normal
1.60 - // values have a 1 implicit bit.
1.61 - answer.append(subnormal ? "0." : "1.");
1.62 -
1.63 - // Isolate the low-order 13 digits of the hex
1.64 - // representation. If all the digits are zero,
1.65 - // replace with a single 0; otherwise, remove all
1.66 - // trailing zeros.
1.67 - String signif = Long.toHexString(signifBits).substring(3,16);
1.68 - answer.append(signif.equals("0000000000000") ? // 13 zeros
1.69 - "0":
1.70 - signif.replaceFirst("0{1,12}$", ""));
1.71 -
1.72 - // If the value is subnormal, use the E_min exponent
1.73 - // value for double; otherwise, extract and report d's
1.74 - // exponent (the representation of a subnormal uses
1.75 - // E_min -1).
1.76 - answer.append("p" + (subnormal ?
1.77 - DoubleConsts.MIN_EXPONENT:
1.78 - FpUtils.getExponent(d) ));
1.79 - }
1.80 - return answer.toString();
1.81 - }
1.82 + throw new UnsupportedOperationException();
1.83 +// /*
1.84 +// * Modeled after the "a" conversion specifier in C99, section
1.85 +// * 7.19.6.1; however, the output of this method is more
1.86 +// * tightly specified.
1.87 +// */
1.88 +// if (!FpUtils.isFinite(d) )
1.89 +// // For infinity and NaN, use the decimal output.
1.90 +// return Double.toString(d);
1.91 +// else {
1.92 +// // Initialized to maximum size of output.
1.93 +// StringBuffer answer = new StringBuffer(24);
1.94 +//
1.95 +// if (FpUtils.rawCopySign(1.0, d) == -1.0) // value is negative,
1.96 +// answer.append("-"); // so append sign info
1.97 +//
1.98 +// answer.append("0x");
1.99 +//
1.100 +// d = Math.abs(d);
1.101 +//
1.102 +// if(d == 0.0) {
1.103 +// answer.append("0.0p0");
1.104 +// }
1.105 +// else {
1.106 +// boolean subnormal = (d < DoubleConsts.MIN_NORMAL);
1.107 +//
1.108 +// // Isolate significand bits and OR in a high-order bit
1.109 +// // so that the string representation has a known
1.110 +// // length.
1.111 +// long signifBits = (Double.doubleToLongBits(d)
1.112 +// & DoubleConsts.SIGNIF_BIT_MASK) |
1.113 +// 0x1000000000000000L;
1.114 +//
1.115 +// // Subnormal values have a 0 implicit bit; normal
1.116 +// // values have a 1 implicit bit.
1.117 +// answer.append(subnormal ? "0." : "1.");
1.118 +//
1.119 +// // Isolate the low-order 13 digits of the hex
1.120 +// // representation. If all the digits are zero,
1.121 +// // replace with a single 0; otherwise, remove all
1.122 +// // trailing zeros.
1.123 +// String signif = Long.toHexString(signifBits).substring(3,16);
1.124 +// answer.append(signif.equals("0000000000000") ? // 13 zeros
1.125 +// "0":
1.126 +// signif.replaceFirst("0{1,12}$", ""));
1.127 +//
1.128 +// // If the value is subnormal, use the E_min exponent
1.129 +// // value for double; otherwise, extract and report d's
1.130 +// // exponent (the representation of a subnormal uses
1.131 +// // E_min -1).
1.132 +// answer.append("p" + (subnormal ?
1.133 +// DoubleConsts.MIN_EXPONENT:
1.134 +// FpUtils.getExponent(d) ));
1.135 +// }
1.136 +// return answer.toString();
1.137 +// }
1.138 }
1.139
1.140 /**
1.141 @@ -501,7 +498,8 @@
1.142 * parsable number.
1.143 */
1.144 public static Double valueOf(String s) throws NumberFormatException {
1.145 - return new Double(FloatingDecimal.readJavaFormatString(s).doubleValue());
1.146 + throw new UnsupportedOperationException();
1.147 +// return new Double(FloatingDecimal.readJavaFormatString(s).doubleValue());
1.148 }
1.149
1.150 /**
1.151 @@ -537,7 +535,8 @@
1.152 * @since 1.2
1.153 */
1.154 public static double parseDouble(String s) throws NumberFormatException {
1.155 - return FloatingDecimal.readJavaFormatString(s).doubleValue();
1.156 + throw new UnsupportedOperationException();
1.157 +// return FloatingDecimal.readJavaFormatString(s).doubleValue();
1.158 }
1.159
1.160 /**
1.161 @@ -805,14 +804,15 @@
1.162 * @return the bits that represent the floating-point number.
1.163 */
1.164 public static long doubleToLongBits(double value) {
1.165 - long result = doubleToRawLongBits(value);
1.166 - // Check for NaN based on values of bit fields, maximum
1.167 - // exponent and nonzero significand.
1.168 - if ( ((result & DoubleConsts.EXP_BIT_MASK) ==
1.169 - DoubleConsts.EXP_BIT_MASK) &&
1.170 - (result & DoubleConsts.SIGNIF_BIT_MASK) != 0L)
1.171 - result = 0x7ff8000000000000L;
1.172 - return result;
1.173 + throw new UnsupportedOperationException();
1.174 +// long result = doubleToRawLongBits(value);
1.175 +// // Check for NaN based on values of bit fields, maximum
1.176 +// // exponent and nonzero significand.
1.177 +// if ( ((result & DoubleConsts.EXP_BIT_MASK) ==
1.178 +// DoubleConsts.EXP_BIT_MASK) &&
1.179 +// (result & DoubleConsts.SIGNIF_BIT_MASK) != 0L)
1.180 +// result = 0x7ff8000000000000L;
1.181 +// return result;
1.182 }
1.183
1.184 /**