Class TruncateNumber

java.lang.Object
etithespirit.orimod.util.TruncateNumber

public final class TruncateNumber extends Object
A class used to truncate numeric values to use SI endings.
Author:
Eti
  • Method Details

    • truncateNumber

      public static String truncateNumber(double number)
      Return a string representing the given number truncated with SI endings. For instance, 1000 will be returned as 1K, 1000000 will be returned as 1M, etc.
      Parameters:
      number - The value to truncate.
      Returns:
      A string representing this value truncated with SI endings, down to one decimal place of accuracy.
    • truncateNumber

      public static String truncateNumber(double number, int placeCount)
      Return a string representing the given number truncated with SI endings. For instance, 1000 will be returned as 1K, 1000000 will be returned as 1M, etc.
      This version supports a limited place count as well, so if given the number 54321, and if placeCount = 2, then this method will return "54.32K"
      Parameters:
      number - The number to truncate.
      Returns:
      A string representing this value truncated with SI endings, down to the given amount of decimal places of accuracy.