|
Uncommons Maths API (Version 1.2.3) |
||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object org.uncommons.maths.Maths
public final class Maths
Maths operations not provided by java.lang.Math
.
Method Summary | |
---|---|
static boolean |
approxEquals(double value1,
double value2,
double tolerance)
Checks that two values are approximately equal (plus or minus a specified tolerance). |
static BigInteger |
bigFactorial(int n)
Calculates the factorial of n where n is a positive integer. |
static long |
factorial(int n)
Calculates the factorial of n where n is a number in the range 0 - 20. |
static long |
greatestCommonDivisor(long a,
long b)
Determines the greatest common divisor of a pair of natural numbers using the Euclidean algorithm. |
static double |
log(double base,
double arg)
Calculate logarithms for arbitrary bases. |
static long |
raiseToPower(int value,
int power)
Calculate the first argument raised to the power of the second. |
static double |
restrictRange(double value,
double min,
double max)
If the specified value is not greater than or equal to the specified minimum and less than or equal to the specified maximum, adjust it so that it is. |
static int |
restrictRange(int value,
int min,
int max)
If the specified value is not greater than or equal to the specified minimum and less than or equal to the specified maximum, adjust it so that it is. |
static long |
restrictRange(long value,
long min,
long max)
If the specified value is not greater than or equal to the specified minimum and less than or equal to the specified maximum, adjust it so that it is. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Method Detail |
---|
public static long factorial(int n)
bigFactorial(int)
.
n
- The factorial to calculate.
bigFactorial(int)
public static BigInteger bigFactorial(int n)
factorial(int)
instead since it uses a faster
implementation.
n
- The factorial to calculate.
factorial(int)
public static long raiseToPower(int value, int power)
value
- The number to be raised.power
- The exponent (must be positive).
value
raised to power
.public static double log(double base, double arg)
base
- The base for the logarithm.arg
- The value to calculate the logarithm for.
arg
in the specified base
.public static boolean approxEquals(double value1, double value2, double tolerance)
value1
- The first value to compare.value2
- The second value to compare.tolerance
- How much (in percentage terms, as a percentage of the first value)
the values are allowed to differ and still be considered equal. Expressed as a value
between 0 and 1.
public static int restrictRange(int value, int min, int max)
value
- The value to check.min
- The minimum permitted value.max
- The maximum permitted value.
value
if it is between the specified limits, min
if the value
is too low, or max
if the value is too high.public static long restrictRange(long value, long min, long max)
value
- The value to check.min
- The minimum permitted value.max
- The maximum permitted value.
value
if it is between the specified limits, min
if the value
is too low, or max
if the value is too high.public static double restrictRange(double value, double min, double max)
value
- The value to check.min
- The minimum permitted value.max
- The maximum permitted value.
value
if it is between the specified limits, min
if the value
is too low, or max
if the value is too high.public static long greatestCommonDivisor(long a, long b)
a
- The first value.b
- The second value.
|
Uncommons Maths API (Version 1.2.3) |
||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |