Java Number Power pow(final int a, final int b)

Here you can find the source of pow(final int a, final int b)

Description

Integer version of Math#pow(double,double) .

License

Open Source License

Parameter

Parameter Description
a a parameter
b a parameter

Declaration

final static public long pow(final int a, final int b) 

Method Source Code

//package com.java2s;
//License from project: Open Source License 

public class Main {
    /**/* w  ww.  ja v a  2s  .c om*/
     * Integer version of {@link Math#pow(double, double)}.
     *
     * @param a
     * @param b
     * @return
     */
    final static public long pow(final int a, final int b) {
        long c = 1;
        for (int i = 0; i < b; ++i)
            c *= a;
        return c;
    }

    /**
     * Float/Integer version of {@link Math#pow(double, double)}.
     *
     * @param a
     * @param b
     * @return
     */
    final static public float pow(final float a, final int b) {
        float c = 1;
        for (int i = 0; i < b; ++i)
            c *= a;
        return c;
    }

    /**
     * Double/Integer version of {@link Math#pow(double, double)}.
     *
     * @param a
     * @param b
     * @return
     */
    final static public double pow(final double a, final int b) {
        double c = 1;
        for (int i = 0; i < b; ++i)
            c *= a;
        return c;
    }
}

Related

  1. pow(double x, int n)
  2. pow(double[] array, double exp)
  3. pow(double[][] x, int p)
  4. pow(final double[] values, final double exp)
  5. pow(final float a, final float b)
  6. pow(final int a, final int b)
  7. pow(final int b, final int e)
  8. pow(final long base, final long exponent)
  9. pow(float a, float b)