Request for approval: fix 4428022, System.out.println(0.001) outputs 0.0010

Andrew Haley aph at redhat.com
Fri May 22 10:37:31 UTC 2009


This bug has been in Java for a long time, and the fix has been in IcedTea
for a year and a half.

The bug is a trivial off-by-one error.

OK for OpenJDK7 and OpenJDK6?

Andrew.


--- oipenjdk/jdk/src/share/classes/sun/misc/FloatingDecimal.java        Thu Sep 27 12:56:46 2007 -0700
+++ openjdk/jdk/src/share/classes/sun/misc/FloatingDecimal.java 2007-11-13 13:39:18.000000000 -0500
@@ -730,7 +730,7 @@
                  * Thus we will need more than one digit if we're using
                  * E-form
                  */
-                if ( decExp <= -3 || decExp >= 8 ){
+                if ( decExp < -3 || decExp >= 8 ){
                     high = low = false;
                 }
                 while( ! low && ! high ){
@@ -783,7 +783,7 @@
                  * Thus we will need more than one digit if we're using
                  * E-form
                  */
-                if ( decExp <= -3 || decExp >= 8 ){
+                if ( decExp < -3 || decExp >= 8 ){
                     high = low = false;
                 }
                 while( ! low && ! high ){
@@ -847,7 +847,7 @@
              * Thus we will need more than one digit if we're using
              * E-form
              */
-            if ( decExp <= -3 || decExp >= 8 ){
+            if ( decExp < -3 || decExp >= 8 ){
                 high = low = false;
             }
             while( ! low && ! high ){



More information about the core-libs-dev mailing list