Skip to content

Commit 572a085

Browse files
Jeff BrownAndroid (Google) Code Review
authored andcommitted
Merge "Add FloatMath.pow." into jb-mr1-dev
2 parents f967807 + e2c279e commit 572a085

File tree

3 files changed

+16
-0
lines changed

3 files changed

+16
-0
lines changed

api/current.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22909,6 +22909,7 @@ package android.util {
2290922909
method public static float exp(float);
2291022910
method public static float floor(float);
2291122911
method public static float hypot(float, float);
22912+
method public static float pow(float, float);
2291222913
method public static float sin(float);
2291322914
method public static float sqrt(float);
2291422915
}

core/java/android/util/FloatMath.java

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -81,6 +81,16 @@ private FloatMath() {}
8181
*/
8282
public static native float exp(float value);
8383

84+
/**
85+
* Returns the closest float approximation of the result of raising {@code
86+
* x} to the power of {@code y}.
87+
*
88+
* @param x the base of the operation.
89+
* @param y the exponent of the operation.
90+
* @return {@code x} to the power of {@code y}.
91+
*/
92+
public static native float pow(float x, float y);
93+
8494
/**
8595
* Returns {@code sqrt(}<i>{@code x}</i><sup>{@code 2}</sup>{@code +} <i>
8696
* {@code y}</i><sup>{@code 2}</sup>{@code )}.

core/jni/android_util_FloatMath.cpp

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,10 @@ class MathUtilsGlue {
3030
return expf(x);
3131
}
3232

33+
static float PowF(JNIEnv* env, jobject clazz, float x, float y) {
34+
return powf(x, y);
35+
}
36+
3337
static float HypotF(JNIEnv* env, jobject clazz, float x, float y) {
3438
return hypotf(x, y);
3539
}
@@ -42,6 +46,7 @@ static JNINativeMethod gMathUtilsMethods[] = {
4246
{"cos", "(F)F", (void*) MathUtilsGlue::CosF},
4347
{"sqrt", "(F)F", (void*) MathUtilsGlue::SqrtF},
4448
{"exp", "(F)F", (void*) MathUtilsGlue::ExpF},
49+
{"pow", "(FF)F", (void*) MathUtilsGlue::PowF},
4550
{"hypot", "(FF)F", (void*) MathUtilsGlue::HypotF},
4651
};
4752

0 commit comments

Comments
 (0)