Uploaded image for project: 'JDK'
  1. JDK
  2. JDK-4106667

java.text.DecimalFormat.format incorrectly formats -0.0

    XMLWordPrintable

    Details

    • Subcomponent:
    • CPU:
      sparc
    • OS:
      solaris_2.5

      Description



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

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

        Attachments

          Issue Links

            Activity

              People

              Assignee:
              duke J. Duke (Inactive)
              Reporter:
              dfazunensunw Dmitri Fazunenko (Inactive)
              Votes:
              0 Vote for this issue
              Watchers:
              0 Start watching this issue

                Dates

                Created:
                Updated:
                Resolved:
                Imported:
                Indexed: