-
Bug
-
Resolution: Duplicate
-
P3
-
None
-
1.1.6
-
sparc
-
solaris_2.5
Name: dfC67450 Date: 01/26/98
java.text.DecimalFormat.format(double, StringBuffer, FieldPosition) formats -0.0
as +-0 if positivePrefix set to "+".
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();
df.setPositivePrefix("+");
double d = -0.0;
System.out.println("pattern: \"" + df.toPattern() + "\"");
System.out.println(d + " is formatted as " +
df.format(d, new StringBuffer(), new FieldPosition(0)));
}
}
---------Output from the test---------------------
pattern: "+#,##0.###;-#,##0.###"
-0.0 is formatted as +-0
--------------------------------------------------
======================================================================
- duplicates
-
JDK-4106658 java.text.DecimalFormat.format() incorrectly formats negative doubles
- Closed