This commit is contained in:
Looly 2022-05-18 10:35:31 +08:00
parent 95f00b8712
commit 858be6aafa
2 changed files with 7 additions and 1 deletions

View File

@ -63,7 +63,7 @@ public class NumberWordFormatter {
int index = -1;
double res = value;
while (res > 10 && (false == isTwo || index < 1)) {
if (res > 1000) {
if (res >= 1000) {
res = res / 1000;
index++;
}

View File

@ -31,4 +31,10 @@ public class NumberWordFormatTest {
final String format5 = NumberWordFormatter.formatSimple(438);
Assert.assertEquals("438", format5);
}
@Test
public void formatSimpleTest2(){
final String s = NumberWordFormatter.formatSimple(1000);
Assert.assertEquals("1k", s);
}
}