From 452e499467878f596d9de399a3d280f671f7e79f Mon Sep 17 00:00:00 2001 From: Auxilor Date: Sun, 26 Dec 2021 16:10:33 +0000 Subject: [PATCH] Added NumberUtils#logBase --- .../java/com/willfp/eco/util/NumberUtils.java | 18 +++++++++++++++--- 1 file changed, 15 insertions(+), 3 deletions(-) diff --git a/eco-api/src/main/java/com/willfp/eco/util/NumberUtils.java b/eco-api/src/main/java/com/willfp/eco/util/NumberUtils.java index 0b1879b0..b93cb000 100644 --- a/eco-api/src/main/java/com/willfp/eco/util/NumberUtils.java +++ b/eco-api/src/main/java/com/willfp/eco/util/NumberUtils.java @@ -185,11 +185,23 @@ public final class NumberUtils { /** * Get Log base 2 of a number. * - * @param toLog The number. + * @param a The number. * @return The result. */ - public static int log2(final int toLog) { - return (int) (Math.log(toLog) / Math.log(2)); + public static int log2(final int a) { + return (int) logBase(a, 2); + } + + /** + * Log with a base. + * + * @param a The number. + * @param base The base. + * @return The logarithm. + */ + public static double logBase(final double a, + final double base) { + return Math.log(a) / Math.log(base); } /**