Here you can find the source of pow(float x, int y)
Parameter | Description |
---|---|
x | value to raise |
y | amount to raise to |
xy
public static float pow(float x, int y)
//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; } }