Package ej.bon
Class XMath
- java.lang.Object
-
- ej.bon.XMath
-
public final class XMath extends Object
This class provides advanced mathematical functions.
-
-
Constructor Summary
Constructors Constructor Description XMath()
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static doublelimit(double value, double min, double max)Limits a value between two others: Ifvalueis lower thanmin, returnsmin. Ifvalueis greater thanmax, returnsmax. Otherwise, returnsvalue.static floatlimit(float value, float min, float max)Limits a value between two others: Ifvalueis lower thanmin, returnsmin. Ifvalueis greater thanmax, returnsmax. Otherwise, returnsvalue.static intlimit(int value, int min, int max)Limits a value between two others: Ifvalueis lower thanmin, returnsmin. Ifvalueis greater thanmax, returnsmax. Otherwise, returnsvalue.static longlimit(long value, long min, long max)Limits a value between two others: Ifvalueis lower thanmin, returnsmin. Ifvalueis greater thanmax, returnsmax. Otherwise, returnsvalue.
-
-
-
Method Detail
-
limit
public static int limit(int value, int min, int max)Limits a value between two others:- If
valueis lower thanmin, returnsmin. - If
valueis greater thanmax, returnsmax. - Otherwise, returns
value.
- Parameters:
value- the value to limitmin- the lower boundmax- the upper bound- Returns:
- the limited value
- Throws:
IllegalArgumentException- ifminis greater thanmax
- If
-
limit
public static float limit(float value, float min, float max)Limits a value between two others:- If
valueis lower thanmin, returnsmin. - If
valueis greater thanmax, returnsmax. - Otherwise, returns
value.
- Parameters:
value- the value to limitmin- the lower boundmax- the upper bound- Returns:
- the limited value
- Throws:
IllegalArgumentException- ifminis greater thanmax
- If
-
limit
public static long limit(long value, long min, long max)Limits a value between two others:- If
valueis lower thanmin, returnsmin. - If
valueis greater thanmax, returnsmax. - Otherwise, returns
value.
- Parameters:
value- the value to limitmin- the lower boundmax- the upper bound- Returns:
- the limited value
- Throws:
IllegalArgumentException- ifminis greater thanmax
- If
-
limit
public static double limit(double value, double min, double max)Limits a value between two others:- If
valueis lower thanmin, returnsmin. - If
valueis greater thanmax, returnsmax. - Otherwise, returns
value.
- Parameters:
value- the value to limitmin- the lower boundmax- the upper bound- Returns:
- the limited value
- Throws:
IllegalArgumentException- ifminis greater thanmax
- If
-
-