-
Bug
-
Resolution: Fixed
-
P3
-
1.1.4
-
1.1.6
-
sparc
-
solaris_2.5
-
Verified
Issue | Fix Version | Assignee | Priority | Status | Resolution | Resolved In Build |
---|---|---|---|---|---|---|
JDK-2017525 | 1.2.0 | John Oconner | P3 | Closed | Fixed | 1.2beta4 |
Name: dfC67450 Date: 10/23/97
java.text.DecimalFormat.format(double n, StringBuffer str, FieldPosition fp) formats
wrong if `Math.pow(10, getMaximumFractionDigits()) * n' greater than Long.MAX_VALUE or
less than Long.MIN_VALUE.
Here is the test demonstrating the bug:
-----------------Test.java------------------------
import java.text.*;
public class Test {
public static void main (String args[]){
DecimalFormat df = new DecimalFormat();
double d = 100;
df.setMinimumFractionDigits(0);
df.setMaximumFractionDigits(16);
StringBuffer sBuf1 = new StringBuffer("");
FieldPosition fp1 = new FieldPosition(0);
System.out.println("d = " + d);
System.out.println("maxFractionDigits = " + df.getMaximumFractionDigits());
System.out.println(" format(d) = '" + df.format(d, sBuf1, fp1) + "'");
System.out.println();
df.setMaximumFractionDigits(17);
StringBuffer sBuf2 = new StringBuffer("");
FieldPosition fp2 = new FieldPosition(0);
System.out.println("maxFractionDigits = " + df.getMaximumFractionDigits());
System.out.println(" format(d) = '" + df.format(d, sBuf2, fp2) + "'");
}
}
---------Output from the test---------------------
d = 100.0
maxFractionDigits = 16
format(d) = '100'
maxFractionDigits = 17
format(d) = '92.23372036854775807'
--------------------------------------------------
======================================================================
- backported by
-
JDK-2017525 java.text.DecimalFormat.format() incorrectly uses maxFractionDigits setting
-
- Closed
-