Skip to content

Commit e2c279e

Browse files
author
Jeff Brown
committed
Add FloatMath.pow.
Change-Id: I5c584f4894caba47fccfa22ba95f8665990d516c
1 parent 5356c7d commit e2c279e

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
@@ -22896,6 +22896,7 @@ package android.util {
2289622896
method public static float exp(float);
2289722897
method public static float floor(float);
2289822898
method public static float hypot(float, float);
22899+
method public static float pow(float, float);
2289922900
method public static float sin(float);
2290022901
method public static float sqrt(float);
2290122902
}

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)