]> granicus.if.org Git - icu/commitdiff
ICU-10045 Fix number of significant digits with 0.
authorTravis Keep <keep94@gmail.com>
Wed, 3 Apr 2013 20:11:01 +0000 (20:11 +0000)
committerTravis Keep <keep94@gmail.com>
Wed, 3 Apr 2013 20:11:01 +0000 (20:11 +0000)
X-SVN-Rev: 33487

icu4c/source/i18n/decimfmt.cpp
icu4c/source/test/intltest/numfmtst.cpp

index d38eae5694894ddf52591ad3048c82ad3b23676e..750770234d6ae94fb74e5b5d33746561b2b800bd 100644 (file)
@@ -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;
         }
 
index cea63bdaf412eb1133eeb314e8bf2f492e4cabc2..9eb79006ac3313f2aea13e0153106ea1f90c2442 100644 (file)
@@ -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",