diff options
author | Jeff Brown <jeffbrown@google.com> | 2012-08-16 01:30:22 -0700 |
---|---|---|
committer | Jeff Brown <jeffbrown@google.com> | 2012-08-16 01:30:22 -0700 |
commit | 270e3381e7053c3b15aa8f508c9df9d98032cd62 (patch) | |
tree | 357795d55b79255c8b04cc328d2a079c439d208d | |
parent | 06565b64de1953fc9534f789b2e8b8fd70758979 (diff) | |
download | frameworks_base-270e3381e7053c3b15aa8f508c9df9d98032cd62.zip frameworks_base-270e3381e7053c3b15aa8f508c9df9d98032cd62.tar.gz frameworks_base-270e3381e7053c3b15aa8f508c9df9d98032cd62.tar.bz2 |
Add FloatMath.hypot.
Change-Id: I6a5a7ea2254300614dbbf540f40e39dbec2d2900
-rw-r--r-- | api/current.txt | 1 | ||||
-rw-r--r-- | core/java/android/util/FloatMath.java | 10 | ||||
-rw-r--r-- | core/jni/android_util_FloatMath.cpp | 5 |
3 files changed, 16 insertions, 0 deletions
diff --git a/api/current.txt b/api/current.txt index 9b54814..860ae09 100644 --- a/api/current.txt +++ b/api/current.txt @@ -22876,6 +22876,7 @@ package android.util { method public static float cos(float); method public static float exp(float); method public static float floor(float); + method public static float hypot(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 1d4eda4..e05169a 100644 --- a/core/java/android/util/FloatMath.java +++ b/core/java/android/util/FloatMath.java @@ -80,4 +80,14 @@ public class FloatMath { * @return the exponential of value */ public static native float exp(float value); + + /** + * Returns {@code sqrt(}<i>{@code x}</i><sup>{@code 2}</sup>{@code +} <i> + * {@code y}</i><sup>{@code 2}</sup>{@code )}. + * + * @param x a float number + * @param y a float number + * @return the hypotenuse + */ + public static native float hypot(float x, float y); } diff --git a/core/jni/android_util_FloatMath.cpp b/core/jni/android_util_FloatMath.cpp index e30756b..529fbe9 100644 --- a/core/jni/android_util_FloatMath.cpp +++ b/core/jni/android_util_FloatMath.cpp @@ -29,6 +29,10 @@ public: static float ExpF(JNIEnv* env, jobject clazz, float x) { return expf(x); } + + static float HypotF(JNIEnv* env, jobject clazz, float x, float y) { + return hypotf(x, y); + } }; static JNINativeMethod gMathUtilsMethods[] = { @@ -38,6 +42,7 @@ static JNINativeMethod gMathUtilsMethods[] = { {"cos", "(F)F", (void*) MathUtilsGlue::CosF}, {"sqrt", "(F)F", (void*) MathUtilsGlue::SqrtF}, {"exp", "(F)F", (void*) MathUtilsGlue::ExpF}, + {"hypot", "(FF)F", (void*) MathUtilsGlue::HypotF}, }; int register_android_util_FloatMath(JNIEnv* env) |