ICU-10045 Fix number of significant digits with 0.

X-SVN-Rev: 33487
This commit is contained in:
Travis Keep 2013-04-03 20:11:01 +00:00
parent 6125cf2eff
commit 41bb29f532
2 changed files with 4 additions and 2 deletions

View 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;
}

View 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",