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

DecimalFormat method format loses precision for float

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Duplicate
    • Icon: P4 P4
    • None
    • 1.1
    • core-libs
    • sparc
    • solaris_2.5.1



      Name: sgC58550 Date: 05/15/97


      import java.text.*;
      import java.lang.*;
      class Test {
          public static void main( String [] args) {
              DecimalFormat df = new decimalformat("########.##");
              float x = -999.99f;
              System.out.println(x + " " + df.format(x));
           }
      }

      PRODUCES THE FOLLOWING OUTPUT: -999.99 -999.98

      (if more fractional chars are allowed you see -999.9899999999)


      company - SOEKOR Exploration and Production
      ======================================================================

            Unassigned Unassigned
            sgoodsunw Sheri Good (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

              Created:
              Updated:
              Resolved:
              Imported:
              Indexed: