mirror of
https://github.com/sudoxnym/habitica-android.git
synced 2026-05-20 20:59:00 +00:00
fix rounding for NumberAbbreviator
This commit is contained in:
parent
039a8a9f3e
commit
0e2b558bdf
2 changed files with 7 additions and 0 deletions
|
|
@ -4,6 +4,7 @@ import android.content.Context;
|
|||
|
||||
import com.habitrpg.android.habitica.R;
|
||||
|
||||
import java.math.RoundingMode;
|
||||
import java.text.DecimalFormat;
|
||||
|
||||
public class NumberAbbreviator {
|
||||
|
|
@ -16,6 +17,7 @@ public class NumberAbbreviator {
|
|||
}
|
||||
|
||||
DecimalFormat formatter = new DecimalFormat("###.##"+abbreviationForCounter(context, counter));
|
||||
formatter.setRoundingMode(RoundingMode.FLOOR);
|
||||
return formatter.format(number);
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -52,4 +52,9 @@ public class NumberAbbreviatorTest {
|
|||
assertEquals("1.5k", NumberAbbreviator.abbreviate(context, 1500));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void voidtestThatitRoundsCorrectly() {
|
||||
assertEquals("9.99k", NumberAbbreviator.abbreviate(context, 9999));
|
||||
}
|
||||
|
||||
}
|
||||
Loading…
Reference in a new issue