Class NumberUtils


  • public class NumberUtils
    extends Object
    • Method Detail

      • calculateNewMin

        public static <T extends Number & Comparable<T>> T calculateNewMin​(T curMin,
                                                                           T newMax,
                                                                           int percentage)
        Calculate a new minimum given the new maximum.

        If the new maximum is less than or equal to the current minimum, returns a new minimum value that is lower than the nex maximum by the specified percentage. Otherwise, returns the current minimum.

        Type Parameters:
        T - number type
        Parameters:
        curMin - current minimum
        newMax - new maximum
        percentage - to adjust by
        Returns:
        new minimum if current is greater than or equal to current maximum
      • calculateNewMax

        public static <T extends Number & Comparable<T>> T calculateNewMax​(T curMax,
                                                                           T newMin,
                                                                           int percentage)
        Calculate a new maximum given the new minimum.

        If the new minimum is greater than or equal to the current maximum, returns a new maximum value that is higher than the new minimum by the specified percentage. Otherwise, returns the current maximum.

        Type Parameters:
        T - number type
        Parameters:
        curMax - current maximum
        newMin - new minimum
        percentage - to adjust by
        Returns:
        new maximum if current is lower than or equal to current minimum