Skip to content

Commit 270e338

Browse files
author
Jeff Brown
committed
Add FloatMath.hypot.
Change-Id: I6a5a7ea2254300614dbbf540f40e39dbec2d2900
1 parent 06565b6 commit 270e338

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
@@ -22876,6 +22876,7 @@ package android.util {
2287622876
method public static float cos(float);
2287722877
method public static float exp(float);
2287822878
method public static float floor(float);
22879+
method public static float hypot(float, float);
2287922880
method public static float sin(float);
2288022881
method public static float sqrt(float);
2288122882
}

core/java/android/util/FloatMath.java

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -80,4 +80,14 @@ private FloatMath() {}
8080
* @return the exponential of value
8181
*/
8282
public static native float exp(float value);
83+
84+
/**
85+
* Returns {@code sqrt(}<i>{@code x}</i><sup>{@code 2}</sup>{@code +} <i>
86+
* {@code y}</i><sup>{@code 2}</sup>{@code )}.
87+
*
88+
* @param x a float number
89+
* @param y a float number
90+
* @return the hypotenuse
91+
*/
92+
public static native float hypot(float x, float y);
8393
}

core/jni/android_util_FloatMath.cpp

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,10 @@ class MathUtilsGlue {
2929
static float ExpF(JNIEnv* env, jobject clazz, float x) {
3030
return expf(x);
3131
}
32+
33+
static float HypotF(JNIEnv* env, jobject clazz, float x, float y) {
34+
return hypotf(x, y);
35+
}
3236
};
3337

3438
static JNINativeMethod gMathUtilsMethods[] = {
@@ -38,6 +42,7 @@ static JNINativeMethod gMathUtilsMethods[] = {
3842
{"cos", "(F)F", (void*) MathUtilsGlue::CosF},
3943
{"sqrt", "(F)F", (void*) MathUtilsGlue::SqrtF},
4044
{"exp", "(F)F", (void*) MathUtilsGlue::ExpF},
45+
{"hypot", "(FF)F", (void*) MathUtilsGlue::HypotF},
4146
};
4247

4348
int register_android_util_FloatMath(JNIEnv* env)

0 commit comments

Comments
 (0)