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

intpow2(int c)
pow
assert c > 0;
c--;
c |= c >> 1;
c |= c >> 2;
c |= c >> 4;
c |= c >> 8;
c |= c >> 16;
c++;
...
intpow2(int i)
2^i
if (i < 0)
    return 0;
int result = 1;
for (int k = 0; k < i; k++)
    result *= 2;
return result;
longpow2(long x)
Calculates 2 in power of integer value x
long result = 1;
for (long i = 1; i <= x; i++) {
    result *= 2;
return result;
voidPow2(Object in, double val)
Pow
if (in == null)
    return;
if (in instanceof double[]) {
    double[] inn = (double[]) in;
    for (int i = 0, s = inn.length; i < s; i++)
        inn[i] = (Sign(inn[i]) * Math.pow(inn[i], val));
} else {
    for (int i = 0, s = ((Object[]) in).length; i < s; i++)
...
bytepow2ByteIndex(final int x)
pow Byte Index
if (x < 0 || x > 7)
    throw new IllegalArgumentException(
            "Unsupported Value [" + x + "]. Only supported for values between 0 and 30 inclusive");
return BYTEPOW2[x];
floatpow3_strict(final float a)
Strict version.
return a * a * a;
doublepow4(double val)
Convenience function to compute the fourth power of a value
return val * val * val * val;
doublepow9(final double x)
pow
return x * x * x * x * x * x * x * x * x;
doublepowDecay(double x, double y)
pow Decay
int num, den = 1001, s = 0;
double n = x, z = Double.MAX_VALUE;
for (int i = 1; i < s; i++)
    n *= x;
while (z >= Double.MAX_VALUE) {
    den -= 1;
    num = (int) (y * den);
    s = (num / den) + 1;
...
doublepower(double d, int exp)
power
double r = 1;
for (int x = 0; x < exp; x++) {
    r *= d;
return r;