aboutsummaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
authorJingwei Zhang <jingwei.zhang@intel.com>2014-09-19 00:50:00 +0800
committerMingwei Shi <mingwei.shi@intel.com>2014-09-19 00:50:00 +0800
commit90be6c5fc541fb83699b949e26e6eb9044a2d096 (patch)
treefe4d9d01f395bc4525ee5fd23d77ff5944978794 /tests
parent0bd28a43dae87c808f6af61ad3dba042b35be7e7 (diff)
downloadandroid_bionic-90be6c5fc541fb83699b949e26e6eb9044a2d096.tar.gz
android_bionic-90be6c5fc541fb83699b949e26e6eb9044a2d096.tar.bz2
android_bionic-90be6c5fc541fb83699b949e26e6eb9044a2d096.zip
The nextafter functions use the wrong next representable value
From C99 standard: “The nextafter functions determine the next representable value, in the type of the function, after x in the direction of y, where x and y are first converted to the type of the function”. The next representable value of 0.0 in direction of -1.0 is -4.9406564584124654e-324, not 0.0. Similar thing holds for nextafterf, nextafterl, nexttowardf, nexttoward, and nexttowardl. The tests pass either way, since the error is within the tolerance, but how it is written is wrong. Change-Id: I1338eeffe3de8031a48f46e1b07146bc07dc2f0a Signed-off-by: Jingwei Zhang <jingwei.zhang@intel.com> Signed-off-by: Mingwei Shi <mingwei.shi@intel.com>
Diffstat (limited to 'tests')
-rw-r--r--tests/math_test.cpp18
1 files changed, 9 insertions, 9 deletions
diff --git a/tests/math_test.cpp b/tests/math_test.cpp
index 2203db9f4..b4604f832 100644
--- a/tests/math_test.cpp
+++ b/tests/math_test.cpp
@@ -1032,13 +1032,13 @@ TEST(math, truncl) {
TEST(math, nextafter) {
ASSERT_DOUBLE_EQ(0.0, nextafter(0.0, 0.0));
ASSERT_DOUBLE_EQ(4.9406564584124654e-324, nextafter(0.0, 1.0));
- ASSERT_DOUBLE_EQ(0.0, nextafter(0.0, -1.0));
+ ASSERT_DOUBLE_EQ(-4.9406564584124654e-324, nextafter(0.0, -1.0));
}
TEST(math, nextafterf) {
ASSERT_FLOAT_EQ(0.0f, nextafterf(0.0f, 0.0f));
ASSERT_FLOAT_EQ(1.4012985e-45f, nextafterf(0.0f, 1.0f));
- ASSERT_FLOAT_EQ(0.0f, nextafterf(0.0f, -1.0f));
+ ASSERT_FLOAT_EQ(-1.4012985e-45f, nextafterf(0.0f, -1.0f));
}
TEST(math, nextafterl) {
@@ -1047,19 +1047,19 @@ TEST(math, nextafterl) {
// sizeof(double) == sizeof(long double)
long double smallest_positive = ldexpl(1.0L, LDBL_MIN_EXP - LDBL_MANT_DIG);
ASSERT_DOUBLE_EQ(smallest_positive, nextafterl(0.0L, 1.0L));
- ASSERT_DOUBLE_EQ(0.0L, nextafterl(0.0L, -1.0L));
+ ASSERT_DOUBLE_EQ(-smallest_positive, nextafterl(0.0L, -1.0L));
}
TEST(math, nexttoward) {
ASSERT_DOUBLE_EQ(0.0, nexttoward(0.0, 0.0L));
ASSERT_DOUBLE_EQ(4.9406564584124654e-324, nexttoward(0.0, 1.0L));
- ASSERT_DOUBLE_EQ(0.0, nexttoward(0.0, -1.0L));
+ ASSERT_DOUBLE_EQ(-4.9406564584124654e-324, nexttoward(0.0, -1.0L));
}
TEST(math, nexttowardf) {
ASSERT_FLOAT_EQ(0.0f, nexttowardf(0.0f, 0.0L));
ASSERT_FLOAT_EQ(1.4012985e-45f, nexttowardf(0.0f, 1.0L));
- ASSERT_FLOAT_EQ(0.0f, nexttowardf(0.0f, -1.0L));
+ ASSERT_FLOAT_EQ(-1.4012985e-45f, nexttowardf(0.0f, -1.0L));
}
TEST(math, nexttowardl) {
@@ -1068,7 +1068,7 @@ TEST(math, nexttowardl) {
// sizeof(double) == sizeof(long double)
long double smallest_positive = ldexpl(1.0L, LDBL_MIN_EXP - LDBL_MANT_DIG);
ASSERT_DOUBLE_EQ(smallest_positive, nexttowardl(0.0L, 1.0L));
- ASSERT_DOUBLE_EQ(0.0L, nexttowardl(0.0L, -1.0L));
+ ASSERT_DOUBLE_EQ(-smallest_positive, nexttowardl(0.0L, -1.0L));
}
TEST(math, copysign) {
@@ -1095,19 +1095,19 @@ TEST(math, copysignl) {
TEST(math, significand) {
ASSERT_DOUBLE_EQ(0.0, significand(0.0));
ASSERT_DOUBLE_EQ(1.2, significand(1.2));
- ASSERT_DOUBLE_EQ(1.5375, significand(12.3));
+ ASSERT_DOUBLE_EQ(1.53125, significand(12.25));
}
TEST(math, significandf) {
ASSERT_FLOAT_EQ(0.0f, significandf(0.0f));
ASSERT_FLOAT_EQ(1.2f, significandf(1.2f));
- ASSERT_FLOAT_EQ(1.5375f, significandf(12.3f));
+ ASSERT_FLOAT_EQ(1.53125f, significandf(12.25f));
}
TEST(math, significandl) {
ASSERT_DOUBLE_EQ(0.0L, significandl(0.0L));
ASSERT_DOUBLE_EQ(1.2L, significandl(1.2L));
- ASSERT_DOUBLE_EQ(1.5375L, significandl(12.3L));
+ ASSERT_DOUBLE_EQ(1.53125L, significandl(12.25L));
}
TEST(math, scalb) {