JDK-4106658 : java.text.DecimalFormat.format() incorrectly formats negative doubles
  • Type: Bug
  • Component: core-libs
  • Sub-Component: java.text
  • Affected Version: 1.1.6
  • Priority: P3
  • Status: Closed
  • Resolution: Fixed
  • OS: solaris_2.5
  • CPU: sparc
  • Submitted: 1998-01-26
  • Updated: 1999-01-13
  • Resolved: 1998-03-10
The Version table provides details related to the release that this issue/RFE will be addressed.

Unresolved : Release in which this issue/RFE will be addressed.
Resolved: Release in which this issue/RFE has been resolved.
Fixed : Release in which this issue/RFE has been fixed. The release containing this fix may be available for download as an Early Access Release or a General Availability Release.

To download the current JDK release, click here.
Other
1.2.0 1.2beta4Fixed
Related Reports
Duplicate :  
Description

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
--------------------------------------------------

======================================================================

Comments
CONVERTED DATA BugTraq+ Release Management Values COMMIT TO FIX: 1.2beta4 FIXED IN: 1.2beta4 INTEGRATED IN: 1.2beta4 VERIFIED IN: 1.2fcs
14-06-2004

EVALUATION Fix added to recognize -0.0 correctly in DigitList. helena.shih@eng 1998-03-10
10-03-1998