1 # Fully clear the decimal quantity before setting it to a new value.
3 # ICU bug: https://unicode-org.atlassian.net/browse/ICU-21674
5 diff --git a/intl/icu/source/i18n/number_capi.cpp b/intl/icu/source/i18n/number_capi.cpp
6 --- a/intl/icu/source/i18n/number_capi.cpp
7 +++ b/intl/icu/source/i18n/number_capi.cpp
8 @@ -112,40 +112,43 @@ unumf_openForSkeletonAndLocaleWithError(
10 unumf_formatInt(const UNumberFormatter* uformatter, int64_t value, UFormattedNumber* uresult,
12 const UNumberFormatterData* formatter = UNumberFormatterData::validate(uformatter, *ec);
13 auto* result = UFormattedNumberApiHelper::validate(uresult, *ec);
14 if (U_FAILURE(*ec)) { return; }
16 result->fData.getStringRef().clear();
17 + result->fData.quantity.clear();
18 result->fData.quantity.setToLong(value);
19 formatter->fFormatter.formatImpl(&result->fData, *ec);
23 unumf_formatDouble(const UNumberFormatter* uformatter, double value, UFormattedNumber* uresult,
25 const UNumberFormatterData* formatter = UNumberFormatterData::validate(uformatter, *ec);
26 auto* result = UFormattedNumberApiHelper::validate(uresult, *ec);
27 if (U_FAILURE(*ec)) { return; }
29 result->fData.getStringRef().clear();
30 + result->fData.quantity.clear();
31 result->fData.quantity.setToDouble(value);
32 formatter->fFormatter.formatImpl(&result->fData, *ec);
36 unumf_formatDecimal(const UNumberFormatter* uformatter, const char* value, int32_t valueLen,
37 UFormattedNumber* uresult, UErrorCode* ec) {
38 const UNumberFormatterData* formatter = UNumberFormatterData::validate(uformatter, *ec);
39 auto* result = UFormattedNumberApiHelper::validate(uresult, *ec);
40 if (U_FAILURE(*ec)) { return; }
42 result->fData.getStringRef().clear();
43 + result->fData.quantity.clear();
44 result->fData.quantity.setToDecNumber({value, valueLen}, *ec);
45 if (U_FAILURE(*ec)) { return; }
46 formatter->fFormatter.formatImpl(&result->fData, *ec);
49 U_CAPI int32_t U_EXPORT2
50 unumf_resultToString(const UFormattedNumber* uresult, UChar* buffer, int32_t bufferCapacity,