Math.
| Access | Constructor and Description |
|---|---|
| private |
| Modifier and Type | Method and Description |
|---|---|
| public static int | Returns: the sumx+yan addend x, int an addend y)Add two integers, checking for overflow. |
| public static long | Returns: the suma+ban addend a, long an addend b)Add two long integers, checking for overflow. |
| private static long | Returns: the suma + b.Addend. a, long Addend. b, Localizable Pattern to use for any thrown exception. pattern)Add two long integers, checking for overflow. |
| public static long | Returns: n choose kthe size of the set n, final int the size of the subsets to be counted k)
Deprecated
use
CombinatoricsUtils#binomialCoefficient(int, int)
Returns an exact representation of the Binomial
Coefficient, " |
| public static double | Returns: n choose kthe size of the set n, final int the size of the subsets to be counted k)
Deprecated
use
CombinatoricsUtils#binomialCoefficientDouble(int, int)
Returns a |
| public static double | Returns: n choose kthe size of the set n, final int the size of the subsets to be counted k)
Deprecated
use
CombinatoricsUtils#binomialCoefficientLog(int, int)
Returns the natural |
| public static long | Returns: n!argument n)
Deprecated
use
CombinatoricsUtils#factorial(int)
Returns n!. |
| public static double | Returns: n!Argument. n)
Deprecated
use
CombinatoricsUtils#factorialDouble(int)
Compute n!, the
factorial of |
| public static double | Returns: n!Argument. n)
Deprecated
use
CombinatoricsUtils#factorialLog(int)
Compute the natural logarithm of the factorial of |
| public static int | Returns: the greatest common divisor (never negative).Number. p, int Number. q)Computes the greatest common divisor of the absolute value of two numbers, using a modified version of the "binary gcd" method. |
| public static long | Returns: the greatest common divisor, never negative.Number. p, final long Number. q)Gets the greatest common divisor of the absolute value of two numbers, using the "binary gcd" method which avoids division and modulo operations. |
| private static int | Returns: the greatest common divisor.Positive number. a, int Positive number. b)Computes the greatest common divisor of two positive numbers (this precondition is not checked and the result is undefined if not fulfilled) using the "binary gcd" method which avoids division and modulo operations. |
| public static boolean | Returns: true if the argument is a power of twothe number to test n)Returns true if the argument is a power of two. |
| public static int | Returns: the least common multiple, never negative.Number. a, int Number. b)
Returns the least common multiple of the absolute value of two numbers,
using the formula |
| public static long | Returns: the least common multiple, never negative.Number. a, long Number. b)
Returns the least common multiple of the absolute value of two numbers,
using the formula |
| public static int | Returns: the productx * y.Factor. x, int Factor. y)Multiply two integers, checking for overflow. |
| public static long | Returns: the producta * b.Factor. a, long Factor. b)Multiply two long integers, checking for overflow. |
| public static int | Returns: \( k^e \)Number to raise. k, final int Exponent (must be positive or zero). e)Raise an int to an int power. |
| public static int | Returns: keNumber to raise. k, long Exponent (must be positive or zero). e)
Deprecated
As of 3.3. Please use
pow(int, int) instead.
Raise an int to a long power. |
| public static long | Returns: \( k^e \)Number to raise. k, final int Exponent (must be positive or zero). e)Raise a long to an int power. |
| public static long | Returns: keNumber to raise. k, long Exponent (must be positive or zero). e)
Deprecated
As of 3.3. Please use
pow(long, int) instead.
Raise a long to a long power. |
| public static BigInteger | Returns: keNumber to raise. k, int Exponent (must be positive or zero). e)Raise a BigInteger to an int power. |
| public static BigInteger | Returns: keNumber to raise. k, long Exponent (must be positive or zero). e)Raise a BigInteger to a long power. |
| public static BigInteger | Returns: keNumber to raise. k, BigInteger Exponent (must be positive or zero). e)Raise a BigInteger to a BigInteger power. |
| public static long | Returns: S(n,k)the size of the set n, final int the number of non-empty subsets k)
Deprecated
use
CombinatoricsUtils#stirlingS2(int, int)
Returns the
Stirling number of the second kind, " |
| public static int | Returns: the differencex - y.Minuend. x, int Subtrahend. y)Subtract two integers, checking for overflow. |
| public static long | Returns: the differencea - b.Value. a, long Value. b)Subtract two long integers, checking for overflow. |
| ArithmeticUtils | back to summary |
|---|---|
| private ArithmeticUtils() Private constructor. | |
| addAndCheck | back to summary |
|---|---|
| public static int addAndCheck(int x, int y) throws MathArithmeticException Add two integers, checking for overflow.
| |
| addAndCheck | back to summary |
|---|---|
| public static long addAndCheck(long a, long b) throws MathArithmeticException Add two long integers, checking for overflow.
| |
| addAndCheck | back to summary |
|---|---|
| private static long addAndCheck(long a, long b, Localizable pattern) throws MathArithmeticException Add two long integers, checking for overflow.
| |
| binomialCoefficient | back to summary |
|---|---|
| public static long binomialCoefficient(final int n, final int k) throws NotPositiveException, NumberIsTooLargeException, MathArithmeticException
Deprecated Returns an exact representation of the Binomial
Coefficient, " Preconditions:
| |
| binomialCoefficientDouble | back to summary |
|---|---|
| public static double binomialCoefficientDouble(final int n, final int k) throws NotPositiveException, NumberIsTooLargeException, MathArithmeticException
Deprecated Returns a Preconditions:
| |
| binomialCoefficientLog | back to summary |
|---|---|
| public static double binomialCoefficientLog(final int n, final int k) throws NotPositiveException, NumberIsTooLargeException, MathArithmeticException
Deprecated Returns the natural Preconditions:
| |
| factorial | back to summary |
|---|---|
| public static long factorial(final int n) throws NotPositiveException, MathArithmeticException
Deprecated Returns n!. Shorthand for Preconditions:
| |
| factorialDouble | back to summary |
|---|---|
| public static double factorialDouble(final int n) throws NotPositiveException
Deprecated Compute n!, the
factorial of
| |
| factorialLog | back to summary |
|---|---|
| public static double factorialLog(final int n) throws NotPositiveException
Deprecated Compute the natural logarithm of the factorial of
| |
| gcd | back to summary |
|---|---|
| public static int gcd(int p, int q) throws MathArithmeticException Computes the greatest common divisor of the absolute value of two
numbers, using a modified version of the "binary gcd" method.
See Knuth 4.5.2 algorithm B.
The algorithm is due to Josef Stein (1961).
| |
| gcd | back to summary |
|---|---|
| public static long gcd(final long p, final long q) throws MathArithmeticException Gets the greatest common divisor of the absolute value of two numbers, using the "binary gcd" method which avoids division and modulo operations. See Knuth 4.5.2 algorithm B. This algorithm is due to Josef Stein (1961). Special cases:
| |
| gcdPositive | back to summary |
|---|---|
| private static int gcdPositive(int a, int b) Computes the greatest common divisor of two positive numbers
(this precondition is not checked and the result is undefined
if not fulfilled) using the "binary gcd" method which avoids division
and modulo operations.
See Knuth 4.5.2 algorithm B.
The algorithm is due to Josef Stein (1961).
| |
| isPowerOfTwo | back to summary |
|---|---|
| public static boolean isPowerOfTwo(long n) Returns true if the argument is a power of two.
| |
| lcm | back to summary |
|---|---|
| public static int lcm(int a, int b) throws MathArithmeticException
Returns the least common multiple of the absolute value of two numbers,
using the formula
| |
| lcm | back to summary |
|---|---|
| public static long lcm(long a, long b) throws MathArithmeticException
Returns the least common multiple of the absolute value of two numbers,
using the formula
| |
| mulAndCheck | back to summary |
|---|---|
| public static int mulAndCheck(int x, int y) throws MathArithmeticException Multiply two integers, checking for overflow.
| |
| mulAndCheck | back to summary |
|---|---|
| public static long mulAndCheck(long a, long b) throws MathArithmeticException Multiply two long integers, checking for overflow.
| |
| pow | back to summary |
|---|---|
| public static int pow(final int k, final int e) throws NotPositiveException, MathArithmeticException Raise an int to an int power.
| |
| pow | back to summary |
|---|---|
| public static int pow(final int k, long e) throws NotPositiveException
Deprecated As of 3.3. Please use Raise an int to a long power.
| |
| pow | back to summary |
|---|---|
| public static long pow(final long k, final int e) throws NotPositiveException, MathArithmeticException Raise a long to an int power.
| |
| pow | back to summary |
|---|---|
| public static long pow(final long k, long e) throws NotPositiveException
Deprecated As of 3.3. Please use Raise a long to a long power.
| |
| pow | back to summary |
|---|---|
| public static BigInteger pow(final BigInteger k, int e) throws NotPositiveException Raise a BigInteger to an int power.
| |
| pow | back to summary |
|---|---|
| public static BigInteger pow(final BigInteger k, long e) throws NotPositiveException Raise a BigInteger to a long power.
| |
| pow | back to summary |
|---|---|
| public static BigInteger pow(final BigInteger k, BigInteger e) throws NotPositiveException Raise a BigInteger to a BigInteger power.
| |
| stirlingS2 | back to summary |
|---|---|
| public static long stirlingS2(final int n, final int k) throws NotPositiveException, NumberIsTooLargeException, MathArithmeticException
Deprecated Returns the
Stirling number of the second kind, "
The preconditions are
| |
| subAndCheck | back to summary |
|---|---|
| public static int subAndCheck(int x, int y) throws MathArithmeticException Subtract two integers, checking for overflow.
| |
| subAndCheck | back to summary |
|---|---|
| public static long subAndCheck(long a, long b) throws MathArithmeticException Subtract two long integers, checking for overflow.
| |