-
Bug
-
Resolution: Duplicate
-
P3
-
None
-
1.1.4
-
sparc
-
solaris_2.5
Name: dfC67450 Date: 11/04/97
java.text.DecimalFormat.format(double n, StringBuffer str, FieldPosition fp) incorrectly
uses internal representation of double.
See similar bug #4054318.
Here is the test demonstrating the bug:
-----------------Test.java------------------------
import java.text.*;
import java.math.*;
public class Test {
public static void main (String args[]){
DecimalFormat df = new DecimalFormat();
df.setMinimumFractionDigits(10);
df.setGroupingUsed(false);
double d = 1.000000000000001E7;
BigDecimal bd = new BigDecimal(d);
StringBuffer sb = new StringBuffer("");
FieldPosition fp = new FieldPosition(0);
System.out.println("d = " + d);
System.out.println("BigDecimal.toString(): " + bd.toString());
System.out.println("DecimalFormat.format(): " + df.format(d, sb, fp));
}
}
---------Output from the test---------------------
d = 1.000000000000001E7
BigDecimal.toString(): 10000000.00000000931322574615478515625
DecimalFormat.format(): 10000000.0000000096
--------------------------------------------------
======================================================================
- duplicates
-
JDK-4117447 RFE: No BigDecimalFormat & Format has and UNACCEPTABLE final method
-
- Closed
-