Java Number Power powerOfN(Double v, int n)

Here you can find the source of powerOfN(Double v, int n)

Description

power Of N

License

Open Source License

Declaration

public static Double powerOfN(Double v, int n) 

Method Source Code

//package com.java2s;

public class Main {

    public static Double powerOfN(Double v, int n) {
        Double value = 1d;/*from ww w. j  a v  a  2s .  c om*/
        if (n == 0) {
            return 1d;
        } else if (n > 0) {
            for (int i = 0; i < n; i++) {
                value = value * v;
            }
        } else if (n < 0) {
            for (int i = 0; i < (0 - n); i++) {
                value = value / v;
            }
        }
        return value;
    }
}

Related

  1. powerMod(long base, long exp, long mod)
  2. powerOf(final int value, final int powerOf)
  3. powerOf10(int number)
  4. powerOf2Log2(int n)
  5. powerOf31(int n)
  6. powerOfTen(int exp)
  7. powerOfTwo(final int i)
  8. powerOfTwo(int current, int desired)
  9. PowerOutageDistr()