Name: dfC67450 Date: 01/26/98
java.text.DecimalFormat.format(double, StringBuffer, FieldPosition) formats -0.0
as -0 whereas -0.0001 as 0.
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 d1 = -0.0;
double d2 = -0.0001;
System.out.println("pattern: \"" + df.toPattern() + "\"");
System.out.println(d1 + " is formatted as " +
df.format(d1, new StringBuffer(), new FieldPosition(0)));
System.out.println(d2 + " is formatted as " +
df.format(d2, new StringBuffer(), new FieldPosition(0)));
}
}
---------Output from the test---------------------
pattern: "#,##0.###"
-0.0 is formatted as -0
-1.0E-4 is formatted as 0
--------------------------------------------------
======================================================================