Java Number Power pow(float x, int y)

Here you can find the source of pow(float x, int y)

Description

Raises first argument to the power of the second argument.

License

BSD License

Parameter

Parameter Description
x value to raise
y amount to raise to

Return

xy

Declaration

public static float pow(float x, int y) 

Method Source Code

//package com.java2s;
//License from project: BSD License 

public class Main {
    /**/*from ww w.j av a2  s  . c o  m*/
     * Raises first argument to the power of the second argument.
     *
     * @param x value to raise
     * @param y amount to raise to
     * @return <code>x<sup>y</sup></code>
     */
    public static float pow(float x, int y) {
        float val = 1.0f;
        for (int i = 0; i < Math.abs(y); i++) {
            val *= x;
        }
        if (y < 0) {
            return 1.0f / val;
        }
        return val;
    }
}

Related

  1. pow(final int a, final int b)
  2. pow(final int b, final int e)
  3. pow(final long base, final long exponent)
  4. pow(float a, float b)
  5. Pow(float base, float exponent)
  6. pow(float[] inData, float rate)
  7. pow(float[][] in)
  8. pow(int a, int b)
  9. pow(int a, int b, int modulus)