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

java.text.DecimalFormat.parse() is inconsistent with Double(String) constructor

    XMLWordPrintable

Details

    • 1.1.6
    • sparc
    • solaris_2.5
    • Verified

    Backports

      Description



        Name: dfC67450 Date: 11/27/97



        java.text.DecimalFormat.parse(String str, ParsePosition pp) loses precision
        when str is parsed as double.
         
        Here is the test demonstrating the bug:

        -----------------Test.java------------------------
        import java.text.*;

        public class TestP {
            public static void main (String args[]){
                DecimalFormat df = new DecimalFormat();
                String str = "0.1234";
                Double d1 = new Double(str);
                Double d2 = (Double) df.parse(str, new ParsePosition(0));
                System.out.println(d1.doubleValue());
                System.out.println(d2.doubleValue());
            }
        }

        ---------Output from the test---------------------
        0.1234
        0.12340000000000001
        --------------------------------------------------

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

        Attachments

          Issue Links

            Activity

              People

                joconnersunw John Oconner (Inactive)
                dfazunensunw Dmitri Fazunenko (Inactive)
                Votes:
                0 Vote for this issue
                Watchers:
                0 Start watching this issue

                Dates

                  Created:
                  Updated:
                  Resolved:
                  Imported:
                  Indexed: