2 # Parent 7965d384123c42ca0e4e4b18bc3ad73b26369f16
3 # User Norbert Lindenberg <mozilladev@lindenbergsoftware.com>
4 Bug 853706 - Backported fix for formatting 0 with significant digits from ICU.
6 diff --git a/intl/icu/source/i18n/decimfmt.cpp b/intl/icu/source/i18n/decimfmt.cpp
7 --- a/intl/icu/source/i18n/decimfmt.cpp
8 +++ b/intl/icu/source/i18n/decimfmt.cpp
9 @@ -1709,16 +1709,24 @@ DecimalFormat::subformat(UnicodeString&
12 // Output grouping separator if necessary.
13 if (isGroupingPosition(i)) {
14 currentLength = appendTo.length();
15 appendTo.append(*grouping);
16 handler.addAttribute(kGroupingSeparatorField, currentLength, appendTo.length());
20 + // This handles the special case of formatting 0. For zero only, we count the
21 + // zero to the left of the decimal point as one signficant digit. Ordinarily we
22 + // do not count any leading 0's as significant. If the number we are formatting
23 + // is not zero, then either sigCount or digits.getCount() will be non-zero.
24 + if (sigCount == 0 && digits.getCount() == 0) {
28 // TODO(dlf): this looks like it was a bug, we marked the int field as ending
29 // before the zero was generated.
30 // Record field information for caller.
31 // if (fieldPosition.getField() == NumberFormat::kIntegerField)
32 // fieldPosition.setEndIndex(appendTo.length());