Float.parseFloat rounding patch

Louis Wasserman wasserman.louis at gmail.com
Wed Jan 18 19:14:33 UTC 2012


A while back I independently discovered Sun bug
6358355<http://bugs.sun.com/bugdatabase/view_bug.do?bug_id=6358355> --
basically, under certain conditions, Float.parseFloat just uses a heuristic
to round from Double.parseDouble (it tries to round in the opposite
direction from parseDouble), which predictably enough for a hackish
approach to floating-point rounding, doesn't work correctly in all cases.
 The relevant source is
here<https://bugs.openjdk.java.net/attachment.cgi?id=243&action=diff#a/src/share/classes/sun/misc/FloatingDecimal.java_sec5>;
the comment: "look at the class instance variable roundDir, which should
help us avoid double-rounding error. roundDir was set in hardValueOf if the
estimate was close enough, but not exact. It tells us which direction of
rounding is preferred."

I have a patch and a test at
https://bugs.openjdk.java.net/show_bug.cgi?id=100208, and I was advised to
contact this mailing list to get it reviewed.  What do I need to do?

Louis Wasserman
wasserman.louis at gmail.com
http://profiles.google.com/wasserman.louis



More information about the core-libs-dev mailing list