Skip to content

Commit

Permalink
xp tracker: add format suffix to reduce string size
Browse files Browse the repository at this point in the history
  • Loading branch information
sethtroll authored and deathbeam committed Mar 9, 2018
1 parent 0ebcb9c commit a015db3
Showing 1 changed file with 12 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -141,6 +141,17 @@ private void updateTotal()

static String formatLine(double number, String description)
{
return NUMBER_FORMATTER.format(number) + " " + description;
String numberStr;
if (number < 100000)
{
numberStr = NUMBER_FORMATTER.format(number);
}
else
{
int num = (int) (Math.log(number) / Math.log(1000));
numberStr = String.format("%.1f%c", number / Math.pow(1000, num), "KMB".charAt(num - 1));
}

return numberStr + " " + description;
}
}

0 comments on commit a015db3

Please sign in to comment.