I am upgrading from JDK6 to JDK7. The following code demonstrate shows a minor change in Double.toString()
public class StringDemo
{
public static void main(String[] args)
{
System.out.println(Double.toString(.0005));
System.out.println(Double.toString(.005)); //different string
System.out.println(Double.toString(.05));
System.out.println(Double.toString(.5));
}
}
JRE6
5.0E-4
0.0050
0.05
0.5
JRE7
I am looking for any documentation related to above change. The compatibility page does not cover it.
5.0E-4
0.005 //changed.
0.05
0.5
The output was saved in many reference files, and compared by string comparison- I need to fix the comparison, but curious to know more details about this change. Authoritative answer on why this change will get bounty.
This was a bug in Java 1.3 through 1.6 (resolved in 1.7).
http://bugs.sun.com/bugdatabase/view_bug.do?bug_id=4511638 The bug report http://bugs.sun.com/view_bug.do?bug_id=4428022 contains more details. Fixed in JDK 7 (b75).
Related Reports- Quoted from the link above.
The changes for OpenJDK 7 to fix this issue are available at: http://hg.openjdk.java.net/jdk7/tl/jdk/rev/f85aa3aedf41
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With