Package jj2000.j2k.util
Class MathUtil
- java.lang.Object
-
- jj2000.j2k.util.MathUtil
-
-
Constructor Summary
Constructors Constructor Description MathUtil()
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static intgcd(int[] x)Method that calculates the Greatest Common Divisor (GCD) of several positive integer numbers.static intgcd(int x1, int x2)Method that calculates the Greatest Common Divisor (GCD) of two positive integer numbers.static intlcm(int[] x)Method that calculates the Least Common Multiple (LCM) of several positive integer numbers.static 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 Detail
-
MathUtil
public MathUtil()
-
-
Method Detail
-
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.
-
-