- java.lang.Object
-
- com.github.ushiosan23.jvm.base.MathExtra
-
public final class MathExtra extends Object
-
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static doubleclamp(double value, double min, double max)This method clamp a number within a range of numbers.static doublepercentage(double value, double percentage)Find the percent of a number.
-
-
-
Method Detail
-
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 analyzemin- Minimum range valuemax- 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 valuepercentage- Percentage to calculate- Returns:
- Returns a percentage of a number
-
-