ICU-21693 Fix FormattedNumber::toDecimalNumber on 0

This commit is contained in:
Shane F. Carr 2021-08-20 22:30:31 -05:00
parent 41aa7159ea
commit e2acbdee22
2 changed files with 7 additions and 0 deletions

View file

@ -639,6 +639,7 @@ DecNum& DecimalQuantity::toDecNum(DecNum& output, UErrorCode& status) const {
// Special handling for zero
if (precision == 0) {
output.setTo("0", status);
return output;
}
// Use the BCD constructor. We need to do a little bit of work to convert, though.

View file

@ -5378,6 +5378,12 @@ void NumberFormatterApiTest::toDecimalNumber() {
u"৯৮,৭৬,৫০,,,,", fn.toString(status));
assertEquals(u"Should have expected toDecimalNumber string result",
"9.8765E+14", fn.toDecimalNumber<std::string>(status).c_str());
fn = NumberFormatter::withLocale("bn-BD").formatDouble(0, status);
assertEquals("Should have expected localized string result",
u"", fn.toString(status));
assertEquals(u"Should have expected toDecimalNumber string result",
"0", fn.toDecimalNumber<std::string>(status).c_str());
}
void NumberFormatterApiTest::microPropsInternals() {