Here you can find the source of pow(final float a, final float b)
Math.pow(a, b)
.
Parameter | Description |
---|---|
a | a positive number |
b | a number |
public static final float pow(final float a, final float b)
//package com.java2s; public class Main { /**//from ww w . jav a 2 s . c o m * Computes a fast approximation to <code>Math.pow(a, b)</code>. Adapted * from <url>http://www.dctsystems.co.uk/Software/power.html</url>. * * @param a * a positive number * @param b * a number * @return a^b */ // UNTESTED public static final float pow(final float a, final float b) { return (float) Math.pow(a, b); // TODO(pruggia) reenable fast pow ? // JBOX2DCODE: // // adapted from: http://www.dctsystems.co.uk/Software/power.html // if (Settings.FAST_MATH) { // float x = Float.floatToRawIntBits(a); // x *= 1.0f / (1 << 23); // x = x - 127; // float y = x - MathUtils.floor(x); // b *= x + (y - y * y) * 0.346607f; // y = b - MathUtils.floor(b); // y = (y - y * y) * 0.33971f; // return Float.intBitsToFloat((int) ((b + 127 - y) * (1 << 23))); // } // else { // return (float) Math.pow(a, b); // } } }