diff --git a/api/current.txt b/api/current.txt index aa50e50499a61..5cc5e95992da3 100644 --- a/api/current.txt +++ b/api/current.txt @@ -22909,6 +22909,7 @@ package android.util { method public static float exp(float); method public static float floor(float); method public static float hypot(float, float); + method public static float pow(float, float); method public static float sin(float); method public static float sqrt(float); } diff --git a/core/java/android/util/FloatMath.java b/core/java/android/util/FloatMath.java index e05169ad6ddfb..955622396aac3 100644 --- a/core/java/android/util/FloatMath.java +++ b/core/java/android/util/FloatMath.java @@ -81,6 +81,16 @@ public class FloatMath { */ public static native float exp(float value); + /** + * Returns the closest float approximation of the result of raising {@code + * x} to the power of {@code y}. + * + * @param x the base of the operation. + * @param y the exponent of the operation. + * @return {@code x} to the power of {@code y}. + */ + public static native float pow(float x, float y); + /** * Returns {@code sqrt(}{@code x}{@code 2}{@code +} * {@code y}{@code 2}{@code )}. diff --git a/core/jni/android_util_FloatMath.cpp b/core/jni/android_util_FloatMath.cpp index 529fbe9b64a88..73b7a6fc310c1 100644 --- a/core/jni/android_util_FloatMath.cpp +++ b/core/jni/android_util_FloatMath.cpp @@ -30,6 +30,10 @@ public: return expf(x); } + static float PowF(JNIEnv* env, jobject clazz, float x, float y) { + return powf(x, y); + } + static float HypotF(JNIEnv* env, jobject clazz, float x, float y) { return hypotf(x, y); } @@ -42,6 +46,7 @@ static JNINativeMethod gMathUtilsMethods[] = { {"cos", "(F)F", (void*) MathUtilsGlue::CosF}, {"sqrt", "(F)F", (void*) MathUtilsGlue::SqrtF}, {"exp", "(F)F", (void*) MathUtilsGlue::ExpF}, + {"pow", "(FF)F", (void*) MathUtilsGlue::PowF}, {"hypot", "(FF)F", (void*) MathUtilsGlue::HypotF}, };