Reviewers: bobv,
Description:
External issue 4171 points out that:
NumberFormat.getFormat("#,##0.##").format(30.555)
should yield 30.56 but yields 30.55 instead.
This is due to the fact that the fractional part of 30.555 (computed as
x - Math.floor(x)) formats as 0.554999... and adding 0.5 still yield
0.559999 which truncates to .55 instead of .56. These sorts of errors
seem inevitable if we try to extract the fractional part using
arithmetic ops and work on it separately. If instead we format the
whole number using Double.toString and extract the desired digits we can
guarantee results that appear consistent, which is highly desirable for
numbers that might be user visible.
Please review this at http://gwt-code-reviews.appspot.com/97812
Affected files:
user/src/com/google/gwt/i18n/client/NumberFormat.java
user/test/com/google/gwt/i18n/client/NumberFormat_en_Test.java
--~--~---------~--~----~------------~-------~--~----~
http://groups.google.com/group/Google-Web-Toolkit-Contributors
-~----------~----~----~----~------~----~------~--~---