Package jj2000.j2k.util
Class MathUtil
java.lang.Object
jj2000.j2k.util.MathUtil
This class contains a collection of utility methods fro mathematical
operations. All methods are static.
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic final intgcd(int[] x) Method that calculates the Greatest Common Divisor (GCD) of several positive integer numbers.static final intgcd(int x1, int x2) Method that calculates the Greatest Common Divisor (GCD) of two positive integer numbers.static final intlcm(int[] x) Method that calculates the Least Common Multiple (LCM) of several positive integer numbers.static final intlcm(int x1, int x2) Method that calculates the Least Common Multiple (LCM) of two strictly positive integer numbers.static intlog2(int x) Method that calculates the floor of the log, base 2, of 'x'.
-
Constructor Details
-
MathUtil
public MathUtil()
-
-
Method Details
-
log2
public static int log2(int x) Method that calculates the floor of the log, base 2, of 'x'. The calculation is performed in integer arithmetic, therefore, it is exact.- Parameters:
x- The value to calculate log2 on.- Returns:
- floor(log(x)/log(2)), calculated in an exact way.
-
lcm
public static final int lcm(int x1, int x2) Method that calculates the Least Common Multiple (LCM) of two strictly positive integer numbers.- Parameters:
x1- First numberx2- Second number
-
lcm
public static final int lcm(int[] x) Method that calculates the Least Common Multiple (LCM) of several positive integer numbers.- Parameters:
x- Array containing the numbers.
-
gcd
public static final int gcd(int x1, int x2) Method that calculates the Greatest Common Divisor (GCD) of two positive integer numbers. -
gcd
public static final int gcd(int[] x) Method that calculates the Greatest Common Divisor (GCD) of several positive integer numbers.- Parameters:
x- Array containing the numbers.
-