public class MathTools
extends java.lang.Object
| Modifier and Type | Method and Description |
|---|---|
static int |
gcd(java.util.Collection<java.lang.Integer> set)
Calculates the gcd of a given set of integers.
|
static int |
gcd(int... set)
Calculates the gcd of a given list of integers.
|
static int |
gcd(int a,
int b)
Calculates the gcd of two integers.
|
static java.math.BigInteger |
lcm(java.math.BigInteger a,
java.math.BigInteger b)
Calculates the lcm of two numbers.
|
static int |
lcm(int a,
int b)
Calculates the lcm of two integers.
|
static int |
meanTowardsMinusInfinity(int x,
int y)
Calculate the average of two numbers, rounding towards minus infinity.
|
static int |
mod(int a,
int b)
Calculates the mathematical modulo, so that it's given the positive value.
|
public static int gcd(java.util.Collection<java.lang.Integer> set)
set - - the integers to calculate the gcd from.public static int gcd(int... set)
set - the integers to calculate the gcd from.public static int gcd(int a,
int b)
a - - first integer for calculating the gcd.b - - second integer for calculating the gcd.public static java.math.BigInteger lcm(java.math.BigInteger a,
java.math.BigInteger b)
a - - first number for calculating the lcm.b - - second number for calculating the lcm.public static int lcm(int a,
int b)
a - - first integer for calculating the lcm.b - - second integer for calculating the lcm.public static int mod(int a,
int b)
a - - divisor.b - - dividend.public static int meanTowardsMinusInfinity(int x,
int y)
(x+y)>>1, but handles integer over- and underflow correctly.
x - First numbery - Second number