[PATCH] java.math/4428022 Float/Double.toString trailing zeros
Hi, I believe the attached patch fixes the trailing zero problem mentioned in several bugs (in addition to $SUBJECT), including 4511638, 6575880, and 4191279. The problem arises because sun.misc.FloatingDecimal.getChars and sun.misc.FloatingDecimal.dtoa disagree about when numbers are represented in E-form and when they are not. As a result, dtoa stuffs one too many numbers (a '0' in this case) into digits[], and getChars blindly returns them to FloatingDecimal.toJavaFormatString. I have also attached a jtreg test for this, based on various testcases given in several bug requests. Keith
Hi Keith. Thanks for your patch with test. I'll try to look into incorporating this soon (I'm busy with OpenJDK 6). -Joe Keith Seitz wrote:
Hi,
I believe the attached patch fixes the trailing zero problem mentioned in several bugs (in addition to $SUBJECT), including 4511638, 6575880, and 4191279.
The problem arises because sun.misc.FloatingDecimal.getChars and sun.misc.FloatingDecimal.dtoa disagree about when numbers are represented in E-form and when they are not. As a result, dtoa stuffs one too many numbers (a '0' in this case) into digits[], and getChars blindly returns them to FloatingDecimal.toJavaFormatString.
I have also attached a jtreg test for this, based on various testcases given in several bug requests.
Keith
participants (2)
-
Joseph D. Darcy
-
Keith Seitz