From 270e3381e7053c3b15aa8f508c9df9d98032cd62 Mon Sep 17 00:00:00 2001 From: Jeff Brown Date: Thu, 16 Aug 2012 01:30:22 -0700 Subject: Add FloatMath.hypot. Change-Id: I6a5a7ea2254300614dbbf540f40e39dbec2d2900 --- api/current.txt | 1 + core/java/android/util/FloatMath.java | 10 ++++++++++ core/jni/android_util_FloatMath.cpp | 5 +++++ 3 files changed, 16 insertions(+) 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(}{@code x}{@code 2}{@code +} + * {@code y}{@code 2}{@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) -- cgit v1.1