Class NumberUtil
java.lang.Object
de.tomatengames.util.NumberUtil
-
Method Summary
Modifier and TypeMethodDescriptionstatic doublelimit(double value, double min, double max) Limits the specified value to the range[min, max].static intlimit(int value, int min, int max) Limits the specified value to the range[min, max].static longlimit(long value, long min, long max) Limits the specified value to the range[min, max].
-
Method Details
-
limit
public static int limit(int value, int min, int max) Limits the specified value to the range[min, max].If
min <= value <= max,valueis returned. Ifvalue < min,minis returned. Ifvalue > max,maxis returned. Ifmin > max, the returned value is undefined.- Parameters:
value- The value.min- The minimum of the range. Must be less than or equalmax.max- The maximum of the range. Must be greater than or equalmin.- Returns:
- The value in the range
[min, max].
-
limit
public static long limit(long value, long min, long max) Limits the specified value to the range[min, max].If
min <= value <= max,valueis returned. Ifvalue < min,minis returned. Ifvalue > max,maxis returned. Ifmin > max, the returned value is undefined.- Parameters:
value- The value.min- The minimum of the range. Must be less than or equalmax.max- The maximum of the range. Must be greater than or equalmin.- Returns:
- The value in the range
[min, max].
-
limit
public static double limit(double value, double min, double max) Limits the specified value to the range[min, max].If
min <= value <= max,valueis returned. Ifvalue < min,minis returned. Ifvalue > max,maxis returned. Ifmin > max, the returned value is undefined.- Parameters:
value- The value.min- The minimum of the range. Must be less than or equalmax.max- The maximum of the range. Must be greater than or equalmin.- Returns:
- The value in the range
[min, max].
-