Package jj2000.j2k.util
Class MathUtil
- java.lang.Object
-
- jj2000.j2k.util.MathUtil
-
public class MathUtil extends Object
This class contains a collection of utility methods fro mathematical operations. All methods are static.
-
-
Constructor Summary
Constructors Constructor Description MathUtil()
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static int
gcd(int[] x)
Method that calculates the Greatest Common Divisor (GCD) of several positive integer numbers.static int
gcd(int x1, int x2)
Method that calculates the Greatest Common Divisor (GCD) of two positive integer numbers.static int
lcm(int[] x)
Method that calculates the Least Common Multiple (LCM) of several positive integer numbers.static int
lcm(int x1, int x2)
Method that calculates the Least Common Multiple (LCM) of two strictly positive integer numbers.static int
log2(int x)
Method that calculates the floor of the log, base 2, of 'x'.
-
-
-
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.
-
-