src/share/classes/java/text/DigitList.java

Print this page

        

@@ -269,11 +269,11 @@
      * @param source Value to be converted; must not be Inf, -Inf, Nan,
      * or a value <= 0.
      * @param maximumFractionDigits The most fractional digits which should
      * be converted.
      */
-    public final void set(boolean isNegative, double source, int maximumFractionDigits) {
+    final void set(boolean isNegative, double source, int maximumFractionDigits) {
         set(isNegative, source, maximumFractionDigits, true);
     }
 
     /**
      * Set the digit list to a representation of the given double value.

@@ -286,14 +286,15 @@
      * @param fixedPoint If true, then maximumDigits is the maximum
      * fractional digits to be converted.  If false, total digits.
      */
     final void set(boolean isNegative, double source, int maximumDigits, boolean fixedPoint) {
 
-        FloatingDecimal fd = new FloatingDecimal(source);
-        boolean hasBeenRoundedUp = fd.digitsRoundedUp();
-        boolean allDecimalDigits = fd.decimalDigitsExact();
-        String digitsString = fd.toJavaFormatString();
+        FloatingDecimal.BinaryToASCIIConverter fdConverter  = FloatingDecimal.getBinaryToASCIIConverter(source);
+        boolean hasBeenRoundedUp = fdConverter.digitsRoundedUp();
+        boolean allDecimalDigits = fdConverter.decimalDigitsExact();
+        assert !fdConverter.isExceptional();
+        String digitsString = fdConverter.toJavaFormatString();
 
         set(isNegative, digitsString,
             hasBeenRoundedUp, allDecimalDigits,
             maximumDigits, fixedPoint);
     }

@@ -303,11 +304,11 @@
      * DDDDDE+/-DDDDD.
      * @param roundedUp Boolean value indicating if the s digits were rounded-up.
      * @param allDecimalDigits Boolean value indicating if the digits in s are
      * an exact decimal representation of the double that was passed.
      */
-    final void set(boolean isNegative, String s,
+    private void set(boolean isNegative, String s,
                    boolean roundedUp, boolean allDecimalDigits,
                    int maximumDigits, boolean fixedPoint) {
         this.isNegative = isNegative;
         int len = s.length();
         char[] source = getDataChars(len);

@@ -605,11 +606,11 @@
     }
 
     /**
      * Utility routine to set the value of the digit list from a long
      */
-    public final void set(boolean isNegative, long source) {
+    final void set(boolean isNegative, long source) {
         set(isNegative, source, 0);
     }
 
     /**
      * Set the digit list to a representation of the given long value.

@@ -618,11 +619,11 @@
      * Long.MIN_VALUE.
      * @param maximumDigits The most digits which should be converted.
      * If maximumDigits is lower than the number of significant digits
      * in source, the representation will be rounded.  Ignored if <= 0.
      */
-    public final void set(boolean isNegative, long source, int maximumDigits) {
+    final void set(boolean isNegative, long source, int maximumDigits) {
         this.isNegative = isNegative;
 
         // This method does not expect a negative number. However,
         // "source" can be a Long.MIN_VALUE (-9223372036854775808),
         // if the number being formatted is a Long.MIN_VALUE.  In that