diff options
Diffstat (limited to 'src/Java/gtPlusPlus/core/util/math')
-rw-r--r-- | src/Java/gtPlusPlus/core/util/math/MathUtils.java | 11 |
1 files changed, 11 insertions, 0 deletions
diff --git a/src/Java/gtPlusPlus/core/util/math/MathUtils.java b/src/Java/gtPlusPlus/core/util/math/MathUtils.java index 40ac23a1b8..030099cff1 100644 --- a/src/Java/gtPlusPlus/core/util/math/MathUtils.java +++ b/src/Java/gtPlusPlus/core/util/math/MathUtils.java @@ -681,4 +681,15 @@ public class MathUtils { return i; } + /** + * Balances a number within a range. + * @param aInput - The number to balance + * @param aMin - The minimum bounds + * @param aMax - The maximum bounds + * @return - An Integer which will be between the bounds, or a boundary value. + */ + public static int balance(int aInput, int aMin, int aMax) { + return Math.max(Math.min(aInput, aMax), aMin); + } + } |