Java Utililty Methods Number Power

List of utility methods to do Number Power

Description

The list of methods to do Number Power are organized into topic(s).

Method

intpow(int number, int power)
pow
int result = 1;
for (int i = 0; i < power; ++i)
    result *= number;
return result;
intpow(int value, int exp)
pow
return value == 2 ? 1 << exp : (int) Math.pow(value, exp);
intpow(int x, int y)
Positive integer powers.
if ((x >= 0) && (x < 50) && (y < 50)) {
    return INTEGER_POWERS[x][y];
} else {
    switch (y) {
    case 0:
        return 1;
    case 1:
        return x;
...
voidpow(int[] arr, double p)
POW all elements of the specified primitive type array.
for (int i = 0, l = arr.length; i < l; i++) {
    arr[i] = (int) Math.pow(arr[i], p);
doublepow(Integer a, Integer b)
Pow.
return Math.pow(a.doubleValue(), b.doubleValue());
longpow(long base, long exp)
Convenience method to calculate the power.
return (long) Math.pow(base, exp);
longpow(long n, long pow)
pow
if (pow == 0) {
    return 1;
long retval = n;
for (long i = 2; i <= pow; i++) {
    retval *= n;
return retval;
...
longpow(long value, long pow)
pow
long tmpValue = 1;
for (int i = 0; i < pow; i++) {
    tmpValue *= value;
return tmpValue;
doublepow(Number x, Number exponent)
pow
return Math.pow(x.doubleValue(), exponent.doubleValue());
Stringpow(String str, int n)
Power-function in the free Monoid over Characters (AKA "Strings").
StringBuilder b = new StringBuilder();
for (int i = 0; i < n; i++) {
    b.append(str);
return b.toString();