|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectch.javasoft.util.numeric.IntegerUtil
public class IntegerUtil
The IntegerUtil contains static utility methods concerning
integers (int and long).
| Method Summary | |
|---|---|
static int |
bitCount(int value)
count 1 bits in this int value |
static int |
bitCount(long value)
count 1 bits in this long value |
static int[] |
extendedEuclidean(int a,
int b)
The extended euclidean algorithm solves the equation a*x + b*y = gcd(a,b). |
static long[] |
extendedEuclidean(long a,
long b)
The extended euclidean algorithm solves the equation a*x + b*y = gcd(a,b). |
static int |
gcd(int... values)
Calculates the greatest common divisor of the specified integer numbers. |
static int |
gcd(Integer... values)
Calculates the greatest common divisor of the specified integer numbers. |
static int |
gcd(int iA,
int iB)
Returns the greatest common divisor of iA and iB using standard euclidian algorithm |
static long |
gcd(long... values)
Calculates the greatest common divisor of the specified long numbers. |
static long |
gcd(Long... values)
Calculates the greatest common divisor of the specified long numbers. |
static long |
gcd(long iA,
long iB)
Returns the greatest common divisor of iA and iB using standard euclidian algorithm |
static int |
modularReciprocal(int a,
int mod)
Computes the reciprocal or multiplicative inverse of a (modulo mod). |
static long |
modularReciprocal(long a,
long mod)
Computes the reciprocal or multiplicative inverse of a (modulo mod). |
static int |
modularReciprocal2pow32(int a)
Computes the reciprocal or multiplicative inverse of a (modulo 2^32). |
static long |
modularReciprocal2pow64(long a)
Computes the reciprocal or multiplicative inverse of a (modulo 2^64). |
static int |
signum(int value)
Returns the signum of the int value, i.e. |
static int |
signum(long value)
Returns the signum of the long value, i.e. |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Method Detail |
|---|
public static int signum(long value)
Math.signum(double)public static int signum(int value)
Math.signum(double)public static int gcd(Integer... values)
If all numbers are negative, the resulting gcd is also negative. If all numbers are zero, the result is zero. Otherwise, the result is positive.
values - values for which the gcd is to be computed
public static int gcd(int... values)
If all numbers are negative, the resulting gcd is also negative. If all numbers are zero, the result is zero. Otherwise, the result is positive.
values - values for which the gcd is to be computed
public static long gcd(Long... values)
If all numbers are negative, the resulting gcd is also negative. If all numbers are zero, the result is zero. Otherwise, the result is positive.
values - values for which the gcd is to be computed
public static long gcd(long... values)
If all numbers are negative, the resulting gcd is also negative. If all numbers are zero, the result is zero. Otherwise, the result is positive.
values - values for which the gcd is to be computed
public static int gcd(int iA,
int iB)
public static int[] extendedEuclidean(int a,
int b)
Returns an int array containing 3 elements {x, y, gcd(a, b)}.
public static int modularReciprocal(int a,
int mod)
ArithmeticException is thrown.
The returned value inv(a) meets the following equality: inv(a) * a = 1 (modulo mod).
ArithmeticException - if a is not invertible (modulo mod)
public static long gcd(long iA,
long iB)
public static long[] extendedEuclidean(long a,
long b)
Returns a long array containing 3 elements {x, y, gcd(a, b)}.
public static long modularReciprocal(long a,
long mod)
ArithmeticException is thrown.
The returned value inv(a) meets the following equality: inv(a) * a = 1 (modulo mod).
ArithmeticException - if a is not invertible (modulo mod)public static int modularReciprocal2pow32(int a)
ArithmeticException is
thrown.
The returned value inv(a) meets the following equality: inv(a) * a = 1 (modulo 2^32).
ArithmeticException - if a is not invertible (modulo 2^32), that
is, iv a is evenpublic static long modularReciprocal2pow64(long a)
ArithmeticException is
thrown.
The returned value inv(a) meets the following equality: inv(a) * a = 1 (modulo 2^64).
ArithmeticException - if a is not invertible (modulo 2^64), that
is, iv a is evenpublic static int bitCount(int value)
public static int bitCount(long value)
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||