Class MathExtra

java.lang.Object
com.github.ushiosan23.jvm.base.MathExtra

public final class MathExtra extends Object
Class that adds extra math utilities. They are methods that are not found in the Math class and seek to add functionality to java.
  • Method Details

    • clamp

      public static double clamp(double value, double min, double max)
      This method clamp a number within a range of numbers. If the value is greater than the range, it returns the highest number and not the overflow number. If the value is less than the range, it returns the smallest number and not the overflow number.
      Parameters:
      value - Value to analyze
      min - Minimum range value
      max - Maximum range value
      Returns:
      Returns a value within the given range
    • percentage

      public static double percentage(double value, double percentage)
      Find the percent of a number.
      Parameters:
      value - Base value
      percentage - Percentage to calculate
      Returns:
      Returns a percentage of a number