From 41bb29f53230845833cb52ad348cf6dcb577390f Mon Sep 17 00:00:00 2001 From: Travis Keep Date: Wed, 3 Apr 2013 20:11:01 +0000 Subject: [PATCH] ICU-10045 Fix number of significant digits with 0. X-SVN-Rev: 33487 --- icu4c/source/i18n/decimfmt.cpp | 4 ++-- icu4c/source/test/intltest/numfmtst.cpp | 2 ++ 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/icu4c/source/i18n/decimfmt.cpp b/icu4c/source/i18n/decimfmt.cpp index d38eae56948..750770234d6 100644 --- a/icu4c/source/i18n/decimfmt.cpp +++ b/icu4c/source/i18n/decimfmt.cpp @@ -1805,8 +1805,8 @@ DecimalFormat::subformat(UnicodeString& appendTo, // This handles the special case of formatting 0. For zero only, we count the // zero to the left of the decimal point as one signficant digit. Ordinarily we // do not count any leading 0's as significant. If the number we are formatting - // is not zero, then either sigCount or digits.getDecimalAt() will be non-zero. - if (sigCount == 0 && digits.getDecimalAt() == 0) { + // is not zero, then either sigCount or digits.getCount() will be non-zero. + if (sigCount == 0 && digits.getCount() == 0) { sigCount = 1; } diff --git a/icu4c/source/test/intltest/numfmtst.cpp b/icu4c/source/test/intltest/numfmtst.cpp index cea63bdaf41..9eb79006ac3 100644 --- a/icu4c/source/test/intltest/numfmtst.cpp +++ b/icu4c/source/test/intltest/numfmtst.cpp @@ -6699,6 +6699,7 @@ void NumberFormatTest::TestFormattableSize(void) { void NumberFormatTest::TestSignificantDigits(void) { double input[] = { 0, 0, + 0.1, -0.1, 123, -123, 12345, -12345, 123.45, -123.45, @@ -6713,6 +6714,7 @@ void NumberFormatTest::TestSignificantDigits(void) { }; const char* expected[] = { "0.00", "0.00", + "0.100", "-0.100", "123", "-123", "12345", "-12345", "123.45", "-123.45",