int. Where possible, methods are defined and
named analogously to their BigInteger counterparts.
The implementations of many methods in this class are based on material from Henry S. Warren, Jr.'s Hacker's Delight, (Addison Wesley, 2002).
Similar functionality for long and for BigInteger can be found in LongMath and BigIntegerMath respectively. For other common operations on int
values, see com..
| Modifier and Type | Field and Description |
|---|---|
| pack-priv static int[] | |
| private static final int[] | |
| pack-priv static final int | |
| pack-priv static final int[] | |
| pack-priv static final int | MAX_POWER_OF_SQRT2_UNSIGNED
The biggest half power of two that can fit in an unsigned int. |
| pack-priv static final int | |
| pack-priv static final byte[] | |
| pack-priv static final int[] |
| Access | Constructor and Description |
|---|---|
| private |
| Modifier and Type | Method and Description |
|---|---|
| public static int | binomial(int n, int k)
Returns |
| public static int | |
| public static int | |
| public static int | |
| public static int | |
| public static int | |
| public static int | divide(int p, int q, RoundingMode mode)
Returns the result of dividing |
| public static int | |
| public static int | |
| public static int | |
| public static boolean | |
| public static boolean | isPrime(int n)
Returns |
| pack-priv static int | |
| public static int | log10(int x, RoundingMode mode)
Returns the base-10 logarithm of |
| private static int | |
| public static int | log2(int x, RoundingMode mode)
Returns the base-2 logarithm of |
| public static int | |
| public static int | |
| public static int | |
| public static int | saturatedAdd(int a, int b)
Returns the sum of |
| public static int | saturatedMultiply(int a, int b)
Returns the product of |
| public static int | saturatedPow(int b, int k)
Returns the |
| public static int | saturatedSubtract(int a, int b)
Returns the difference of |
| public static int | sqrt(int x, RoundingMode mode)
Returns the square root of |
| private static int |
| biggestBinomials | back to summary |
|---|---|
| pack-priv static int[] biggestBinomials
| |
| factorials | back to summary |
|---|---|
| private static final int[] factorials | |
| FLOOR_SQRT_MAX_INT | back to summary |
|---|---|
| pack-priv static final int FLOOR_SQRT_MAX_INT
| |
| halfPowersOf10 | back to summary |
|---|---|
| pack-priv static final int[] halfPowersOf10
| |
| MAX_POWER_OF_SQRT2_UNSIGNED | back to summary |
|---|---|
| pack-priv static final int MAX_POWER_OF_SQRT2_UNSIGNED The biggest half power of two that can fit in an unsigned int. | |
| MAX_SIGNED_POWER_OF_TWO | back to summary |
|---|---|
| pack-priv static final int MAX_SIGNED_POWER_OF_TWO
| |
| maxLog10ForLeadingZeros | back to summary |
|---|---|
| pack-priv static final byte[] maxLog10ForLeadingZeros
| |
| powersOf10 | back to summary |
|---|---|
| pack-priv static final int[] powersOf10
| |
| IntMath | back to summary |
|---|---|
| private IntMath() | |
| binomial | back to summary |
|---|---|
| public static int binomial(int n, int k) Returns
| |
| ceilingPowerOfTwo | back to summary |
|---|---|
| public static int ceilingPowerOfTwo(int x) Returns the smallest power of two greater than or equal to
| |
| checkedAdd | back to summary |
|---|---|
| public static int checkedAdd(int a, int b) Returns the sum of
| |
| checkedMultiply | back to summary |
|---|---|
| public static int checkedMultiply(int a, int b) Returns the product of
| |
| checkedPow | back to summary |
|---|---|
| public static int checkedPow(int b, int k) Returns the
| |
| checkedSubtract | back to summary |
|---|---|
| public static int checkedSubtract(int a, int b) Returns the difference of
| |
| divide | back to summary |
|---|---|
| public static int divide(int p, int q, RoundingMode mode) Returns the result of dividing
| |
| factorial | back to summary |
|---|---|
| public static int factorial(int n) Returns
| |
| floorPowerOfTwo | back to summary |
|---|---|
| public static int floorPowerOfTwo(int x) Returns the largest power of two less than or equal to
| |
| gcd | back to summary |
|---|---|
| public static int gcd(int a, int b) Returns the greatest common divisor of
| |
| isPowerOfTwo | back to summary |
|---|---|
| public static boolean isPowerOfTwo(int x) Returns This differs from | |
| isPrime | back to summary |
|---|---|
| public static boolean isPrime(int n) Returns To test larger numbers, use
| |
| lessThanBranchFree | back to summary |
|---|---|
| pack-priv static int lessThanBranchFree(int x, int y) Returns 1 if
| |
| log10 | back to summary |
|---|---|
| public static int log10(int x, RoundingMode mode) Returns the base-10 logarithm of
| |
| log10Floor | back to summary |
|---|---|
| private static int log10Floor(int x) | |
| log2 | back to summary |
|---|---|
| public static int log2(int x, RoundingMode mode) Returns the base-2 logarithm of
| |
| mean | back to summary |
|---|---|
| public static int mean(int x, int y) Returns the arithmetic mean of
| |
| mod | back to summary |
|---|---|
| public static int mod(int x, int m) Returns For example:
| |
| pow | back to summary |
|---|---|
| public static int pow(int b, int k) Returns Compare
| |
| saturatedAdd | back to summary |
|---|---|
| public static int saturatedAdd(int a, int b) Returns the sum of
| |
| saturatedMultiply | back to summary |
|---|---|
| public static int saturatedMultiply(int a, int b) Returns the product of
| |
| saturatedPow | back to summary |
|---|---|
| public static int saturatedPow(int b, int k) Returns the
| |
| saturatedSubtract | back to summary |
|---|---|
| public static int saturatedSubtract(int a, int b) Returns the difference of
| |
| sqrt | back to summary |
|---|---|
| public static int sqrt(int x, RoundingMode mode) Returns the square root of
| |
| sqrtFloor | back to summary |
|---|---|
| private static int sqrtFloor(int x) | |