ICU-8460 Fixed bug with formatting 0.

X-SVN-Rev: 31568
This commit is contained in:
Mark Davis 2012-03-02 05:12:50 +00:00
parent 2d515412de
commit 4f9f1f602c
2 changed files with 5 additions and 1 deletions

View file

@ -174,7 +174,7 @@ public class CompactDecimalFormat extends DecimalFormat {
if (number < 0.0d) {
throw new UnsupportedOperationException("CompactDecimalFormat doesn't handle negative numbers yet.");
}
int integerCount = (int) Math.log10(number);
int integerCount = number <= 1.0d ? 0 : (int) Math.log10(number);
int base = integerCount > 14 ? 14 : integerCount;
number = number / divisor[base];
setPositivePrefix(prefix[base]);

View file

@ -20,6 +20,9 @@ public class CompactDecimalFormatTest extends TestFmwk {
Object[][] EnglishTestData = {
// default is 2 digits of accuracy
{0.0d, "0.0"},
{0.1d, "0.1"},
{1d, "1"},
{1234, "1.2K"},
{12345, "12K"},
{123456, "120K"},
@ -32,6 +35,7 @@ public class CompactDecimalFormatTest extends TestFmwk {
{1234567890123f, "1.2T"},
{12345678901234f, "12T"},
{123456789012345f, "120T"},
{12345678901234567890f, "12000000T"},
};
Object[][] JapaneseTestData = {