diff options
Diffstat (limited to 'src/Java/gtPlusPlus/core/util/math')
-rw-r--r-- | src/Java/gtPlusPlus/core/util/math/MathUtils.java | 17 |
1 files changed, 14 insertions, 3 deletions
diff --git a/src/Java/gtPlusPlus/core/util/math/MathUtils.java b/src/Java/gtPlusPlus/core/util/math/MathUtils.java index 40ac23a1b8..f9a4d8f548 100644 --- a/src/Java/gtPlusPlus/core/util/math/MathUtils.java +++ b/src/Java/gtPlusPlus/core/util/math/MathUtils.java @@ -463,14 +463,14 @@ public class MathUtils { return 0; } int divisor = aDataSet.length; - Logger.INFO("Calculating Average Short. Divisor: "+divisor); + Logger.WARNING("Calculating Average Short. Divisor: "+divisor); short total = 0; for (short i : aDataSet) { - Logger.INFO("Adding "+i); + Logger.WARNING("Adding "+i); total += i; } short result = safeShort((total/divisor)); - Logger.INFO("Average: "+result); + Logger.WARNING("Average: "+result); return result; } public static int getIntAverage(int[] aDataSet) { @@ -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); + } + } |