summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--luni/src/main/java/java/lang/StrictMath.java8
-rw-r--r--luni/src/main/native/java_lang_Math.c6
-rw-r--r--luni/src/main/native/java_lang_StrictMath.c12
3 files changed, 10 insertions, 16 deletions
diff --git a/luni/src/main/java/java/lang/StrictMath.java b/luni/src/main/java/java/lang/StrictMath.java
index cd3c9b5..5c6ebc7 100644
--- a/luni/src/main/java/java/lang/StrictMath.java
+++ b/luni/src/main/java/java/lang/StrictMath.java
@@ -1042,7 +1042,9 @@ public final class StrictMath {
* @since 1.6
* @hide
*/
- public static native double copySign(double magnitude, double sign);
+ public static double copySign(double magnitude, double sign) {
+ return Math.copySign(magnitude, sign);
+ }
/**
* Returns a float with the given magnitude and the sign of {@code sign}.
@@ -1050,7 +1052,9 @@ public final class StrictMath {
* @since 1.6
* @hide
*/
- public static native float copySign(float magnitude, float sign);
+ public static float copySign(float magnitude, float sign) {
+ return Math.copySign(magnitude, sign);
+ }
/**
* Answers the exponent of a float.
diff --git a/luni/src/main/native/java_lang_Math.c b/luni/src/main/native/java_lang_Math.c
index 35754cd..90cb9b5 100644
--- a/luni/src/main/native/java_lang_Math.c
+++ b/luni/src/main/native/java_lang_Math.c
@@ -160,11 +160,13 @@ static jfloat jnextafterf(JNIEnv* env, jclass clazz, jfloat a, jfloat b)
}
static jdouble copySign(JNIEnv* env, jclass clazz, jdouble a, jdouble b) {
- return copysign(a, b);
+ // Our StrictMath.copySign delegates to Math.copySign, so we need to treat NaN as positive.
+ return copysign(a, isnan(b) ? 1.0 : b);
}
static jfloat copySign_f(JNIEnv* env, jclass clazz, jfloat a, jfloat b) {
- return copysignf(a, b);
+ // Our StrictMath.copySign delegates to Math.copySign, so we need to treat NaN as positive.
+ return copysignf(a, isnan(b) ? 1.0 : b);
}
/*
diff --git a/luni/src/main/native/java_lang_StrictMath.c b/luni/src/main/native/java_lang_StrictMath.c
index 3839c21..cb0f87e 100644
--- a/luni/src/main/native/java_lang_StrictMath.c
+++ b/luni/src/main/native/java_lang_StrictMath.c
@@ -20,8 +20,6 @@
#include "../../external/fdlibm/fdlibm.h"
_LIB_VERSION_TYPE _LIB_VERSION = _IEEE_;
-#include <math.h>
-
/* native public static double sin(double a); */
static jdouble jsin(JNIEnv* env, jclass clazz, jdouble a)
{
@@ -186,14 +184,6 @@ static jfloat jnextafterf(JNIEnv* env, jclass clazz, jfloat arg1, jfloat arg2)
return arg1;
}
-static jdouble copySign(JNIEnv* env, jclass clazz, jdouble a, jdouble b) {
- return copysign(a, isnan(b) ? 1.0 : b);
-}
-
-static jfloat copySign_f(JNIEnv* env, jclass clazz, jfloat a, jfloat b) {
- return copysignf(a, isnan(b) ? 1.0f : b);
-}
-
/*
* JNI registration.
*/
@@ -206,8 +196,6 @@ static JNINativeMethod gMethods[] = {
{ "atan2", "(DD)D", jatan2 },
{ "cbrt", "(D)D", jcbrt },
{ "ceil", "(D)D", jceil },
- { "copySign", "(DD)D", copySign },
- { "copySign", "(FF)F", copySign_f },
{ "cos", "(D)D", jcos },
{ "cosh", "(D)D", jcosh },
{ "exp", "(D)D", jexp },