summaryrefslogtreecommitdiffstats
path: root/core/java/android
diff options
context:
space:
mode:
authorNeil Fuller <nfuller@google.com>2014-10-20 10:10:34 +0000
committerAndroid Git Automerger <android-git-automerger@android.com>2014-10-20 10:10:34 +0000
commitdfcf065505a12aa358af5cd2607fd355eee964c4 (patch)
tree23b0f1e0e4913f33eced4b3d2148d6f497d31499 /core/java/android
parent84e6d466edc2aba711f90431a1cd209d11c0e70d (diff)
parent09fd5a1873fa1ab51f4e428b1b909fea35091a51 (diff)
downloadframeworks_base-dfcf065505a12aa358af5cd2607fd355eee964c4.zip
frameworks_base-dfcf065505a12aa358af5cd2607fd355eee964c4.tar.gz
frameworks_base-dfcf065505a12aa358af5cd2607fd355eee964c4.tar.bz2
am 09fd5a18: Merge "Replacing FloatMath native implementation with calls to Math"
* commit '09fd5a1873fa1ab51f4e428b1b909fea35091a51': Replacing FloatMath native implementation with calls to Math
Diffstat (limited to 'core/java/android')
-rw-r--r--core/java/android/util/FloatMath.java43
1 files changed, 31 insertions, 12 deletions
diff --git a/core/java/android/util/FloatMath.java b/core/java/android/util/FloatMath.java
index 0ffd5bd..90e0636 100644
--- a/core/java/android/util/FloatMath.java
+++ b/core/java/android/util/FloatMath.java
@@ -17,10 +17,13 @@
package android.util;
/**
- * Math routines similar to those found in {@link java.lang.Math}. On
- * versions of Android with a JIT, these are significantly slower than
- * the equivalent {@code Math} functions, which should be used in preference
- * to these.
+ * Math routines similar to those found in {@link java.lang.Math}.
+ *
+ * <p>Historically these methods were faster than the equivalent double-based
+ * {@link java.lang.Math} methods. On versions of Android with a JIT they
+ * became slower and have since been re-implemented to wrap calls to
+ * {@link java.lang.Math}. {@link java.lang.Math} should be used in
+ * preference.
*/
public class FloatMath {
@@ -34,7 +37,9 @@ public class FloatMath {
* @param value to be converted
* @return the floor of value
*/
- public static native float floor(float value);
+ public static float floor(float value) {
+ return (float) Math.floor(value);
+ }
/**
* Returns the float conversion of the most negative (i.e. closest to
@@ -43,7 +48,9 @@ public class FloatMath {
* @param value to be converted
* @return the ceiling of value
*/
- public static native float ceil(float value);
+ public static float ceil(float value) {
+ return (float) Math.ceil(value);
+ }
/**
* Returns the closest float approximation of the sine of the argument.
@@ -51,7 +58,9 @@ public class FloatMath {
* @param angle to compute the cosine of, in radians
* @return the sine of angle
*/
- public static native float sin(float angle);
+ public static float sin(float angle) {
+ return (float) Math.sin(angle);
+ }
/**
* Returns the closest float approximation of the cosine of the argument.
@@ -59,7 +68,9 @@ public class FloatMath {
* @param angle to compute the cosine of, in radians
* @return the cosine of angle
*/
- public static native float cos(float angle);
+ public static float cos(float angle) {
+ return (float) Math.cos(angle);
+ }
/**
* Returns the closest float approximation of the square root of the
@@ -68,7 +79,9 @@ public class FloatMath {
* @param value to compute sqrt of
* @return the square root of value
*/
- public static native float sqrt(float value);
+ public static float sqrt(float value) {
+ return (float) Math.sqrt(value);
+ }
/**
* Returns the closest float approximation of the raising "e" to the power
@@ -77,7 +90,9 @@ public class FloatMath {
* @param value to compute the exponential of
* @return the exponential of value
*/
- public static native float exp(float value);
+ public static float exp(float value) {
+ return (float) Math.exp(value);
+ }
/**
* Returns the closest float approximation of the result of raising {@code
@@ -87,7 +102,9 @@ public class FloatMath {
* @param y the exponent of the operation.
* @return {@code x} to the power of {@code y}.
*/
- public static native float pow(float x, float y);
+ public static float pow(float x, float y) {
+ return (float) Math.pow(x, y);
+ }
/**
* Returns {@code sqrt(}<i>{@code x}</i><sup>{@code 2}</sup>{@code +} <i>
@@ -97,5 +114,7 @@ public class FloatMath {
* @param y a float number
* @return the hypotenuse
*/
- public static native float hypot(float x, float y);
+ public static float hypot(float x, float y) {
+ return (float) Math.hypot(x, y);
+ }
}