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

doublepow(double a, double b)
pow
double pow = 1;
for (int i = 0; i < b; i++) {
    pow *= a;
return pow;
doublepow(double a, double b)
Return a to the power of b, sometimes written as a ** b but not to be confused with the bitwise ^ operator.
return ieee754_pow(a, b);
doublepow(double a, double b)
Computes a relaxed power function.
if (a != 0) {
    return Math.pow(a, b);
return 0;
doublepow(double a, double b)
Returns the value of the first argument raised to the power of the second argument.
return Math.pow(a, b);
doublepow(double a, int b)
Computes a^b for integer exponents.
if (b < 0.0) {
    a = 1.0 / a;
    b *= -1;
double result = 1.0;
while (b != 0) {
    if ((b & 1) == 1) {
        result *= a;
...
doublepow(double base, double exp)
pow
return Math.pow(base, exp);
doublepow(double base, int exp)
pow
double result = 1.0;
while (exp > 0) {
    if ((exp & 1) == 1) {
        result = result * base;
        exp--;
    base = base * base;
    exp /= 2;
...
doublepow(double base, int exp)
pow
return exp == 0 ? 1 : sq(pow(base, exp / 2)) * (exp % 2 == 1 ? base : 1);
doublepow(double base, int exponent)
pow
if (exponent == 0)
    return 1;
if (exponent == 1)
    return base;
if (exponent == -1)
    return 1 / base;
boolean negative;
if (exponent < 0) {
...
intpow(double number)
pow
if (number < 2)
    return 2;
int i = 1;
int result = 0;
while (result < number) {
    result = (int) Math.pow(2, i++);
return result;
...