Fix LP64 libm for 128-bit long doubles
* reworked amd64/_fpmath.h and arm64/_fpmath.h to support 128-bit long
doubles.
* improved tests to cover long double cases
* made modfl an alias for LP32
Tests pass on x86, x86_64, arm, arm64 and mips.
Bug: 12921273
Change-Id: Ibe39acde57972447a8950fa45b1e702acc68ebeb
diff --git a/tests/math_test.cpp b/tests/math_test.cpp
index fc561bc..0bb072a 100644
--- a/tests/math_test.cpp
+++ b/tests/math_test.cpp
@@ -72,62 +72,97 @@
return u.d;
}
+long double ldouble_subnormal() {
+ union {
+ long double e;
+ unsigned char c[sizeof(long double)];
+ } u;
+
+ // Subnormals must have a zero exponent and non zero significand.
+ // On all supported representation the 17 bit (counting from either sides)
+ // is part of the significand so it should be enough to set that.
+ // It also applies for the case sizeof(double) = sizeof(long double)
+ for (unsigned int i = 0; i < sizeof(long double); i++) {
+ u.c[i] = 0x00;
+ }
+ u.c[sizeof(long double) - 3] = 0x80;
+ u.c[2] = 0x80;
+
+ return u.e;
+}
+
TEST(math, fpclassify) {
ASSERT_EQ(FP_INFINITE, fpclassify(INFINITY));
ASSERT_EQ(FP_INFINITE, fpclassify(HUGE_VALF));
ASSERT_EQ(FP_INFINITE, fpclassify(HUGE_VAL));
+ ASSERT_EQ(FP_INFINITE, fpclassify(HUGE_VALL));
ASSERT_EQ(FP_NAN, fpclassify(nanf("")));
ASSERT_EQ(FP_NAN, fpclassify(nan("")));
+ ASSERT_EQ(FP_NAN, fpclassify(nanl("")));
ASSERT_EQ(FP_NORMAL, fpclassify(1.0f));
ASSERT_EQ(FP_NORMAL, fpclassify(1.0));
+ ASSERT_EQ(FP_NORMAL, fpclassify(1.0l));
ASSERT_EQ(FP_SUBNORMAL, fpclassify(float_subnormal()));
ASSERT_EQ(FP_SUBNORMAL, fpclassify(double_subnormal()));
+ ASSERT_EQ(FP_SUBNORMAL, fpclassify(ldouble_subnormal()));
ASSERT_EQ(FP_ZERO, fpclassify(0.0f));
ASSERT_EQ(FP_ZERO, fpclassify(0.0));
+ ASSERT_EQ(FP_ZERO, fpclassify(0.0l));
}
TEST(math, isfinite) {
ASSERT_TRUE(test_capture_isfinite(123.0f));
ASSERT_TRUE(test_capture_isfinite(123.0));
+ ASSERT_TRUE(test_capture_isfinite(123.0l));
ASSERT_FALSE(test_capture_isfinite(HUGE_VALF));
ASSERT_FALSE(test_capture_isfinite(HUGE_VAL));
+ ASSERT_FALSE(test_capture_isfinite(HUGE_VALL));
}
TEST(math, isinf) {
ASSERT_FALSE(test_capture_isinf(123.0f));
ASSERT_FALSE(test_capture_isinf(123.0));
+ ASSERT_FALSE(test_capture_isinf(123.0l));
ASSERT_TRUE(test_capture_isinf(HUGE_VALF));
ASSERT_TRUE(test_capture_isinf(HUGE_VAL));
+ ASSERT_TRUE(test_capture_isinf(HUGE_VALL));
}
TEST(math, isnan) {
ASSERT_FALSE(test_capture_isnan(123.0f));
ASSERT_FALSE(test_capture_isnan(123.0));
+ ASSERT_FALSE(test_capture_isnan(123.0l));
ASSERT_TRUE(test_capture_isnan(nanf("")));
ASSERT_TRUE(test_capture_isnan(nan("")));
+ ASSERT_TRUE(test_capture_isnan(nanl("")));
}
TEST(math, isnormal) {
ASSERT_TRUE(isnormal(123.0f));
ASSERT_TRUE(isnormal(123.0));
+ ASSERT_TRUE(isnormal(123.0l));
ASSERT_FALSE(isnormal(float_subnormal()));
ASSERT_FALSE(isnormal(double_subnormal()));
+ ASSERT_FALSE(isnormal(ldouble_subnormal()));
}
// TODO: isgreater, isgreaterequals, isless, islessequal, islessgreater, isunordered
TEST(math, signbit) {
ASSERT_EQ(0, test_capture_signbit(0.0f));
ASSERT_EQ(0, test_capture_signbit(0.0));
+ ASSERT_EQ(0, test_capture_signbit(0.0l));
ASSERT_EQ(0, test_capture_signbit(1.0f));
ASSERT_EQ(0, test_capture_signbit(1.0));
+ ASSERT_EQ(0, test_capture_signbit(1.0l));
ASSERT_NE(0, test_capture_signbit(-1.0f));
ASSERT_NE(0, test_capture_signbit(-1.0));
+ ASSERT_NE(0, test_capture_signbit(-1.0l));
}
TEST(math, __fpclassifyd) {
@@ -158,9 +193,9 @@
#if defined(__BIONIC__)
EXPECT_EQ(FP_INFINITE, __fpclassifyl(HUGE_VALL));
EXPECT_EQ(FP_NAN, __fpclassifyl(nanl("")));
- EXPECT_EQ(FP_NORMAL, __fpclassifyl(1.0));
- EXPECT_EQ(FP_SUBNORMAL, __fpclassifyl(double_subnormal()));
- EXPECT_EQ(FP_ZERO, __fpclassifyl(0.0));
+ EXPECT_EQ(FP_NORMAL, __fpclassifyl(1.0l));
+ EXPECT_EQ(FP_SUBNORMAL, __fpclassifyl(ldouble_subnormal()));
+ EXPECT_EQ(FP_ZERO, __fpclassifyl(0.0l));
#else // __BIONIC__
GTEST_LOG_(INFO) << "This test does nothing.\n";
#endif // __BIONIC__
@@ -191,7 +226,7 @@
TEST(math, __isfinitel) {
#if defined(__BIONIC__)
- ASSERT_TRUE(__isfinitel(123.0f));
+ ASSERT_TRUE(__isfinitel(123.0l));
ASSERT_FALSE(__isfinitel(HUGE_VALL));
#else // __BIONIC__
GTEST_LOG_(INFO) << "This test does nothing.\n";
@@ -209,7 +244,7 @@
}
TEST(math, __isinfl) {
- ASSERT_FALSE(__isinfl(123.0));
+ ASSERT_FALSE(__isinfl(123.0l));
ASSERT_TRUE(__isinfl(HUGE_VALL));
}
@@ -219,7 +254,7 @@
}
TEST(math, __isnanl) {
- ASSERT_FALSE(__isnanl(123.0));
+ ASSERT_FALSE(__isnanl(123.0l));
ASSERT_TRUE(__isnanl(nanl("")));
}
@@ -248,8 +283,8 @@
TEST(math, __isnormall) {
#if defined(__BIONIC__)
- ASSERT_TRUE(__isnormall(123.0));
- ASSERT_FALSE(__isnormall(double_subnormal()));
+ ASSERT_TRUE(__isnormall(123.0l));
+ ASSERT_FALSE(__isnormall(ldouble_subnormal()));
#else // __BIONIC__
GTEST_LOG_(INFO) << "This test does nothing.\n";
#endif // __BIONIC__
@@ -268,13 +303,13 @@
}
TEST(math, __signbitl) {
- ASSERT_EQ(0, __signbitl(0.0));
- ASSERT_EQ(0, __signbitl(1.0));
- ASSERT_NE(0, __signbitl(-1.0));
+ ASSERT_EQ(0l, __signbitl(0.0l));
+ ASSERT_EQ(0l, __signbitl(1.0l));
+ ASSERT_NE(0l, __signbitl(-1.0l));
}
TEST(math, acos) {
- ASSERT_FLOAT_EQ(M_PI/2.0, acos(0.0));
+ ASSERT_DOUBLE_EQ(M_PI/2.0, acos(0.0));
}
TEST(math, acosf) {
@@ -282,11 +317,11 @@
}
TEST(math, acosl) {
- ASSERT_FLOAT_EQ(M_PI/2.0, acosl(0.0));
+ ASSERT_DOUBLE_EQ(M_PI/2.0l, acosl(0.0l));
}
TEST(math, asin) {
- ASSERT_FLOAT_EQ(0.0, asin(0.0));
+ ASSERT_DOUBLE_EQ(0.0, asin(0.0));
}
TEST(math, asinf) {
@@ -294,11 +329,11 @@
}
TEST(math, asinl) {
- ASSERT_FLOAT_EQ(0.0, asinl(0.0));
+ ASSERT_DOUBLE_EQ(0.0l, asinl(0.0l));
}
TEST(math, atan) {
- ASSERT_FLOAT_EQ(0.0, atan(0.0));
+ ASSERT_DOUBLE_EQ(0.0, atan(0.0));
}
TEST(math, atanf) {
@@ -306,11 +341,11 @@
}
TEST(math, atanl) {
- ASSERT_FLOAT_EQ(0.0, atanl(0.0));
+ ASSERT_DOUBLE_EQ(0.0l, atanl(0.0l));
}
TEST(math, atan2) {
- ASSERT_FLOAT_EQ(0.0, atan2(0.0, 0.0));
+ ASSERT_DOUBLE_EQ(0.0, atan2(0.0, 0.0));
}
TEST(math, atan2f) {
@@ -318,11 +353,11 @@
}
TEST(math, atan2l) {
- ASSERT_FLOAT_EQ(0.0, atan2l(0.0, 0.0));
+ ASSERT_DOUBLE_EQ(0.0l, atan2l(0.0l, 0.0l));
}
TEST(math, cos) {
- ASSERT_FLOAT_EQ(1.0, cos(0.0));
+ ASSERT_DOUBLE_EQ(1.0, cos(0.0));
}
TEST(math, cosf) {
@@ -330,7 +365,7 @@
}
TEST(math, cosl) {
- ASSERT_FLOAT_EQ(1.0, cosl(0.0));
+ ASSERT_DOUBLE_EQ(1.0l, cosl(0.0l));
}
TEST(math, sin) {
@@ -342,11 +377,11 @@
}
TEST(math, sinl) {
- ASSERT_FLOAT_EQ(0.0, sinl(0.0));
+ ASSERT_DOUBLE_EQ(0.0l, sinl(0.0l));
}
TEST(math, tan) {
- ASSERT_FLOAT_EQ(0.0, tan(0.0));
+ ASSERT_DOUBLE_EQ(0.0, tan(0.0));
}
TEST(math, tanf) {
@@ -354,11 +389,11 @@
}
TEST(math, tanl) {
- ASSERT_FLOAT_EQ(0.0, tanl(0.0));
+ ASSERT_DOUBLE_EQ(0.0l, tanl(0.0l));
}
TEST(math, acosh) {
- ASSERT_FLOAT_EQ(0.0, acosh(1.0));
+ ASSERT_DOUBLE_EQ(0.0, acosh(1.0));
}
TEST(math, acoshf) {
@@ -366,11 +401,11 @@
}
TEST(math, acoshl) {
- ASSERT_FLOAT_EQ(0.0, acoshl(1.0));
+ ASSERT_DOUBLE_EQ(0.0l, acoshl(1.0l));
}
TEST(math, asinh) {
- ASSERT_FLOAT_EQ(0.0, asinh(0.0));
+ ASSERT_DOUBLE_EQ(0.0, asinh(0.0));
}
TEST(math, asinhf) {
@@ -378,11 +413,11 @@
}
TEST(math, asinhl) {
- ASSERT_FLOAT_EQ(0.0, asinhl(0.0));
+ ASSERT_DOUBLE_EQ(0.0l, asinhl(0.0l));
}
TEST(math, atanh) {
- ASSERT_FLOAT_EQ(0.0, atanh(0.0));
+ ASSERT_DOUBLE_EQ(0.0, atanh(0.0));
}
TEST(math, atanhf) {
@@ -390,11 +425,11 @@
}
TEST(math, atanhl) {
- ASSERT_FLOAT_EQ(0.0, atanhl(0.0));
+ ASSERT_DOUBLE_EQ(0.0l, atanhl(0.0l));
}
TEST(math, cosh) {
- ASSERT_FLOAT_EQ(1.0, cosh(0.0));
+ ASSERT_DOUBLE_EQ(1.0, cosh(0.0));
}
TEST(math, coshf) {
@@ -402,11 +437,11 @@
}
TEST(math, coshl) {
- ASSERT_FLOAT_EQ(1.0, coshl(0.0));
+ ASSERT_DOUBLE_EQ(1.0l, coshl(0.0l));
}
TEST(math, sinh) {
- ASSERT_FLOAT_EQ(0.0, sinh(0.0));
+ ASSERT_DOUBLE_EQ(0.0, sinh(0.0));
}
TEST(math, sinhf) {
@@ -414,11 +449,11 @@
}
TEST(math, sinhl) {
- ASSERT_FLOAT_EQ(0.0, sinhl(0.0));
+ ASSERT_DOUBLE_EQ(0.0l, sinhl(0.0l));
}
TEST(math, tanh) {
- ASSERT_FLOAT_EQ(0.0, tanh(0.0));
+ ASSERT_DOUBLE_EQ(0.0, tanh(0.0));
}
TEST(math, tanhf) {
@@ -426,11 +461,11 @@
}
TEST(math, tanhl) {
- ASSERT_FLOAT_EQ(0.0, tanhl(0.0));
+ ASSERT_DOUBLE_EQ(0.0l, tanhl(0.0l));
}
TEST(math, log) {
- ASSERT_FLOAT_EQ(1.0, log(M_E));
+ ASSERT_DOUBLE_EQ(1.0, log(M_E));
}
TEST(math, logf) {
@@ -438,11 +473,11 @@
}
TEST(math, logl) {
- ASSERT_FLOAT_EQ(1.0, logl(M_E));
+ ASSERT_DOUBLE_EQ(1.0l, logl(M_E));
}
TEST(math, log2) {
- ASSERT_FLOAT_EQ(12.0, log2(4096.0));
+ ASSERT_DOUBLE_EQ(12.0, log2(4096.0));
}
TEST(math, log2f) {
@@ -450,11 +485,11 @@
}
TEST(math, log2l) {
- ASSERT_FLOAT_EQ(12.0, log2l(4096.0));
+ ASSERT_DOUBLE_EQ(12.0l, log2l(4096.0l));
}
TEST(math, log10) {
- ASSERT_FLOAT_EQ(3.0, log10(1000.0));
+ ASSERT_DOUBLE_EQ(3.0, log10(1000.0));
}
TEST(math, log10f) {
@@ -462,11 +497,11 @@
}
TEST(math, log10l) {
- ASSERT_FLOAT_EQ(3.0, log10l(1000.0));
+ ASSERT_DOUBLE_EQ(3.0l, log10l(1000.0l));
}
TEST(math, cbrt) {
- ASSERT_FLOAT_EQ(3.0, cbrt(27.0));
+ ASSERT_DOUBLE_EQ(3.0, cbrt(27.0));
}
TEST(math, cbrtf) {
@@ -474,11 +509,11 @@
}
TEST(math, cbrtl) {
- ASSERT_FLOAT_EQ(3.0, cbrtl(27.0));
+ ASSERT_DOUBLE_EQ(3.0l, cbrtl(27.0l));
}
TEST(math, sqrt) {
- ASSERT_FLOAT_EQ(2.0, sqrt(4.0));
+ ASSERT_DOUBLE_EQ(2.0, sqrt(4.0));
}
TEST(math, sqrtf) {
@@ -486,12 +521,12 @@
}
TEST(math, sqrtl) {
- ASSERT_FLOAT_EQ(2.0, sqrtl(4.0));
+ ASSERT_DOUBLE_EQ(2.0l, sqrtl(4.0l));
}
TEST(math, exp) {
- ASSERT_FLOAT_EQ(1.0, exp(0.0));
- ASSERT_FLOAT_EQ(M_E, exp(1.0));
+ ASSERT_DOUBLE_EQ(1.0, exp(0.0));
+ ASSERT_DOUBLE_EQ(M_E, exp(1.0));
}
TEST(math, expf) {
@@ -500,12 +535,12 @@
}
TEST(math, expl) {
- ASSERT_FLOAT_EQ(1.0, expl(0.0));
- ASSERT_FLOAT_EQ(M_E, expl(1.0));
+ ASSERT_DOUBLE_EQ(1.0l, expl(0.0l));
+ ASSERT_DOUBLE_EQ(M_E, expl(1.0l));
}
TEST(math, exp2) {
- ASSERT_FLOAT_EQ(8.0, exp2(3.0));
+ ASSERT_DOUBLE_EQ(8.0, exp2(3.0));
}
TEST(math, exp2f) {
@@ -513,11 +548,11 @@
}
TEST(math, exp2l) {
- ASSERT_FLOAT_EQ(8.0, exp2l(3.0));
+ ASSERT_DOUBLE_EQ(8.0l, exp2l(3.0l));
}
TEST(math, expm1) {
- ASSERT_FLOAT_EQ(M_E - 1.0, expm1(1.0));
+ ASSERT_DOUBLE_EQ(M_E - 1.0, expm1(1.0));
}
TEST(math, expm1f) {
@@ -525,14 +560,14 @@
}
TEST(math, expm1l) {
- ASSERT_FLOAT_EQ(M_E - 1.0, expm1l(1.0));
+ ASSERT_DOUBLE_EQ(M_E - 1.0l, expm1l(1.0l));
}
TEST(math, pow) {
ASSERT_TRUE(isnan(pow(nan(""), 3.0)));
- ASSERT_FLOAT_EQ(1.0, (pow(1.0, nan(""))));
+ ASSERT_DOUBLE_EQ(1.0, (pow(1.0, nan(""))));
ASSERT_TRUE(isnan(pow(2.0, nan(""))));
- ASSERT_FLOAT_EQ(8.0, pow(2.0, 3.0));
+ ASSERT_DOUBLE_EQ(8.0, pow(2.0, 3.0));
}
TEST(math, powf) {
@@ -543,14 +578,14 @@
}
TEST(math, powl) {
- ASSERT_TRUE(__isnanl(powl(nanl(""), 3.0)));
- ASSERT_FLOAT_EQ(1.0, (powl(1.0, nanl(""))));
- ASSERT_TRUE(__isnanl(powl(2.0, nanl(""))));
- ASSERT_FLOAT_EQ(8.0, powl(2.0, 3.0));
+ ASSERT_TRUE(__isnanl(powl(nanl(""), 3.0l)));
+ ASSERT_DOUBLE_EQ(1.0l, (powl(1.0l, nanl(""))));
+ ASSERT_TRUE(__isnanl(powl(2.0l, nanl(""))));
+ ASSERT_DOUBLE_EQ(8.0l, powl(2.0l, 3.0l));
}
TEST(math, ceil) {
- ASSERT_FLOAT_EQ(1.0, ceil(0.9));
+ ASSERT_DOUBLE_EQ(1.0, ceil(0.9));
}
TEST(math, ceilf) {
@@ -558,11 +593,11 @@
}
TEST(math, ceill) {
- ASSERT_FLOAT_EQ(1.0, ceill(0.9));
+ ASSERT_DOUBLE_EQ(1.0, ceill(0.9l));
}
TEST(math, floor) {
- ASSERT_FLOAT_EQ(1.0, floor(1.1));
+ ASSERT_DOUBLE_EQ(1.0, floor(1.1));
}
TEST(math, floorf) {
@@ -570,11 +605,11 @@
}
TEST(math, floorl) {
- ASSERT_FLOAT_EQ(1.0, floorl(1.1));
+ ASSERT_DOUBLE_EQ(1.0l, floorl(1.1l));
}
TEST(math, fabs) {
- ASSERT_FLOAT_EQ(1.0, fabs(-1.0));
+ ASSERT_DOUBLE_EQ(1.0, fabs(-1.0));
}
TEST(math, fabsf) {
@@ -582,11 +617,11 @@
}
TEST(math, fabsl) {
- ASSERT_FLOAT_EQ(1.0, fabsl(-1.0));
+ ASSERT_DOUBLE_EQ(1.0l, fabsl(-1.0l));
}
TEST(math, ldexp) {
- ASSERT_FLOAT_EQ(16.0, ldexp(2.0, 3.0));
+ ASSERT_DOUBLE_EQ(16.0, ldexp(2.0, 3.0));
}
TEST(math, ldexpf) {
@@ -594,11 +629,11 @@
}
TEST(math, ldexpl) {
- ASSERT_FLOAT_EQ(16.0, ldexpl(2.0, 3.0));
+ ASSERT_DOUBLE_EQ(16.0l, ldexpl(2.0l, 3.0));
}
TEST(math, fmod) {
- ASSERT_FLOAT_EQ(2.0, fmod(12.0, 10.0));
+ ASSERT_DOUBLE_EQ(2.0, fmod(12.0, 10.0));
}
TEST(math, fmodf) {
@@ -606,11 +641,11 @@
}
TEST(math, fmodl) {
- ASSERT_FLOAT_EQ(2.0, fmodl(12.0, 10.0));
+ ASSERT_DOUBLE_EQ(2.0l, fmodl(12.0l, 10.0l));
}
TEST(math, remainder) {
- ASSERT_FLOAT_EQ(2.0, remainder(12.0, 10.0));
+ ASSERT_DOUBLE_EQ(2.0, remainder(12.0, 10.0));
}
TEST(math, remainderf) {
@@ -618,11 +653,11 @@
}
TEST(math, remainderl) {
- ASSERT_FLOAT_EQ(2.0, remainderl(12.0, 10.0));
+ ASSERT_DOUBLE_EQ(2.0l, remainderl(12.0l, 10.0l));
}
TEST(math, drem) {
- ASSERT_FLOAT_EQ(2.0, drem(12.0, 10.0));
+ ASSERT_DOUBLE_EQ(2.0, drem(12.0, 10.0));
}
TEST(math, dremf) {
@@ -630,9 +665,9 @@
}
TEST(math, fmax) {
- ASSERT_FLOAT_EQ(12.0, fmax(12.0, 10.0));
- ASSERT_FLOAT_EQ(12.0, fmax(12.0, nan("")));
- ASSERT_FLOAT_EQ(12.0, fmax(nan(""), 12.0));
+ ASSERT_DOUBLE_EQ(12.0, fmax(12.0, 10.0));
+ ASSERT_DOUBLE_EQ(12.0, fmax(12.0, nan("")));
+ ASSERT_DOUBLE_EQ(12.0, fmax(nan(""), 12.0));
}
TEST(math, fmaxf) {
@@ -642,15 +677,15 @@
}
TEST(math, fmaxl) {
- ASSERT_FLOAT_EQ(12.0, fmaxl(12.0, 10.0));
- ASSERT_FLOAT_EQ(12.0, fmaxl(12.0, nanl("")));
- ASSERT_FLOAT_EQ(12.0, fmaxl(nanl(""), 12.0));
+ ASSERT_DOUBLE_EQ(12.0l, fmaxl(12.0l, 10.0l));
+ ASSERT_DOUBLE_EQ(12.0l, fmaxl(12.0l, nanl("")));
+ ASSERT_DOUBLE_EQ(12.0l, fmaxl(nanl(""), 12.0l));
}
TEST(math, fmin) {
- ASSERT_FLOAT_EQ(10.0, fmin(12.0, 10.0));
- ASSERT_FLOAT_EQ(12.0, fmin(12.0, nan("")));
- ASSERT_FLOAT_EQ(12.0, fmin(nan(""), 12.0));
+ ASSERT_DOUBLE_EQ(10.0, fmin(12.0, 10.0));
+ ASSERT_DOUBLE_EQ(12.0, fmin(12.0, nan("")));
+ ASSERT_DOUBLE_EQ(12.0, fmin(nan(""), 12.0));
}
TEST(math, fminf) {
@@ -660,13 +695,13 @@
}
TEST(math, fminl) {
- ASSERT_FLOAT_EQ(10.0, fminl(12.0, 10.0));
- ASSERT_FLOAT_EQ(12.0, fminl(12.0, nan("")));
- ASSERT_FLOAT_EQ(12.0, fminl(nan(""), 12.0));
+ ASSERT_DOUBLE_EQ(10.0l, fminl(12.0l, 10.0l));
+ ASSERT_DOUBLE_EQ(12.0l, fminl(12.0l, nanl("")));
+ ASSERT_DOUBLE_EQ(12.0l, fminl(nanl(""), 12.0l));
}
TEST(math, fma) {
- ASSERT_FLOAT_EQ(10.0, fma(2.0, 3.0, 4.0));
+ ASSERT_DOUBLE_EQ(10.0, fma(2.0, 3.0, 4.0));
}
TEST(math, fmaf) {
@@ -674,11 +709,11 @@
}
TEST(math, fmal) {
- ASSERT_FLOAT_EQ(10.0, fmal(2.0, 3.0, 4.0));
+ ASSERT_DOUBLE_EQ(10.0l, fmal(2.0l, 3.0l, 4.0l));
}
TEST(math, hypot) {
- ASSERT_FLOAT_EQ(5.0, hypot(3.0, 4.0));
+ ASSERT_DOUBLE_EQ(5.0, hypot(3.0, 4.0));
}
TEST(math, hypotf) {
@@ -686,11 +721,11 @@
}
TEST(math, hypotl) {
- ASSERT_FLOAT_EQ(5.0, hypotl(3.0, 4.0));
+ ASSERT_DOUBLE_EQ(5.0l, hypotl(3.0l, 4.0l));
}
TEST(math, erf) {
- ASSERT_FLOAT_EQ(0.84270078, erf(1.0));
+ ASSERT_DOUBLE_EQ(0.84270079294971489, erf(1.0));
}
TEST(math, erff) {
@@ -698,11 +733,11 @@
}
TEST(math, erfl) {
- ASSERT_FLOAT_EQ(0.84270078, erfl(1.0));
+ ASSERT_DOUBLE_EQ(0.84270079294971489l, erfl(1.0l));
}
TEST(math, erfc) {
- ASSERT_FLOAT_EQ(0.15729921, erfc(1.0));
+ ASSERT_DOUBLE_EQ(0.15729920705028513, erfc(1.0));
}
TEST(math, erfcf) {
@@ -710,27 +745,27 @@
}
TEST(math, erfcl) {
- ASSERT_FLOAT_EQ(0.15729921, erfcl(1.0));
+ ASSERT_DOUBLE_EQ(0.15729920705028513l, erfcl(1.0l));
}
TEST(math, lrint) {
fesetround(FE_UPWARD); // lrint/lrintf/lrintl obey the rounding mode.
ASSERT_EQ(1235, lrint(1234.01));
ASSERT_EQ(1235, lrintf(1234.01f));
- ASSERT_EQ(1235, lrintl(1234.01));
+ ASSERT_EQ(1235, lrintl(1234.01l));
fesetround(FE_TOWARDZERO); // lrint/lrintf/lrintl obey the rounding mode.
ASSERT_EQ(1234, lrint(1234.01));
ASSERT_EQ(1234, lrintf(1234.01f));
- ASSERT_EQ(1234, lrintl(1234.01));
+ ASSERT_EQ(1234, lrintl(1234.01l));
fesetround(FE_UPWARD); // llrint/llrintf/llrintl obey the rounding mode.
ASSERT_EQ(1235L, llrint(1234.01));
ASSERT_EQ(1235L, llrintf(1234.01f));
- ASSERT_EQ(1235L, llrintl(1234.01));
+ ASSERT_EQ(1235L, llrintl(1234.01l));
fesetround(FE_TOWARDZERO); // llrint/llrintf/llrintl obey the rounding mode.
ASSERT_EQ(1234L, llrint(1234.01));
ASSERT_EQ(1234L, llrintf(1234.01f));
- ASSERT_EQ(1234L, llrintl(1234.01));
+ ASSERT_EQ(1234L, llrintl(1234.01l));
}
TEST(math, rint) {
@@ -748,15 +783,15 @@
ASSERT_TRUE((fetestexcept(FE_ALL_EXCEPT) & FE_INEXACT) != 0);
feclearexcept(FE_ALL_EXCEPT); // rint/rintf/rintl do set the FE_INEXACT flag.
- ASSERT_EQ(1234.0, rintl(1234.0));
+ ASSERT_EQ(1234.0, rintl(1234.0l));
ASSERT_TRUE((fetestexcept(FE_ALL_EXCEPT) & FE_INEXACT) == 0);
- ASSERT_EQ(1235.0, rintl(1234.01));
+ ASSERT_EQ(1235.0, rintl(1234.01l));
ASSERT_TRUE((fetestexcept(FE_ALL_EXCEPT) & FE_INEXACT) != 0);
fesetround(FE_TOWARDZERO); // rint/rintf obey the rounding mode.
ASSERT_EQ(1234.0, rint(1234.01));
ASSERT_EQ(1234.0f, rintf(1234.01f));
- ASSERT_EQ(1234.0, rintl(1234.01));
+ ASSERT_EQ(1234.0, rintl(1234.01l));
}
TEST(math, nearbyint) {
@@ -774,29 +809,29 @@
ASSERT_TRUE((fetestexcept(FE_ALL_EXCEPT) & FE_INEXACT) == 0);
feclearexcept(FE_ALL_EXCEPT); // nearbyint/nearbyintf/nearbyintl don't set the FE_INEXACT flag.
- ASSERT_EQ(1234.0, nearbyintl(1234.0));
+ ASSERT_EQ(1234.0, nearbyintl(1234.0l));
ASSERT_TRUE((fetestexcept(FE_ALL_EXCEPT) & FE_INEXACT) == 0);
- ASSERT_EQ(1235.0, nearbyintl(1234.01));
+ ASSERT_EQ(1235.0, nearbyintl(1234.01l));
ASSERT_TRUE((fetestexcept(FE_ALL_EXCEPT) & FE_INEXACT) == 0);
fesetround(FE_TOWARDZERO); // nearbyint/nearbyintf/nearbyintl obey the rounding mode.
ASSERT_EQ(1234.0, nearbyint(1234.01));
ASSERT_EQ(1234.0f, nearbyintf(1234.01f));
- ASSERT_EQ(1234.0, nearbyintl(1234.01));
+ ASSERT_EQ(1234.0, nearbyintl(1234.01l));
}
TEST(math, lround) {
fesetround(FE_UPWARD); // lround ignores the rounding mode.
ASSERT_EQ(1234, lround(1234.01));
ASSERT_EQ(1234, lroundf(1234.01f));
- ASSERT_EQ(1234, lroundl(1234.01));
+ ASSERT_EQ(1234, lroundl(1234.01l));
}
TEST(math, llround) {
fesetround(FE_UPWARD); // llround ignores the rounding mode.
ASSERT_EQ(1234L, llround(1234.01));
ASSERT_EQ(1234L, llroundf(1234.01f));
- ASSERT_EQ(1234L, llroundl(1234.01));
+ ASSERT_EQ(1234L, llroundl(1234.01l));
}
TEST(math, ilogb) {
@@ -816,11 +851,11 @@
}
TEST(math, ilogbl) {
- ASSERT_EQ(FP_ILOGB0, ilogbl(0.0));
+ ASSERT_EQ(FP_ILOGB0, ilogbl(0.0l));
ASSERT_EQ(FP_ILOGBNAN, ilogbl(nanl("")));
ASSERT_EQ(INT_MAX, ilogbl(HUGE_VALL));
- ASSERT_EQ(0, ilogbl(1.0));
- ASSERT_EQ(3, ilogbl(10.0));
+ ASSERT_EQ(0l, ilogbl(1.0l));
+ ASSERT_EQ(3l, ilogbl(10.0l));
}
TEST(math, logb) {
@@ -840,18 +875,18 @@
}
TEST(math, logbl) {
- ASSERT_EQ(-HUGE_VAL, logbl(0.0));
+ ASSERT_EQ(-HUGE_VAL, logbl(0.0l));
ASSERT_TRUE(isnan(logbl(nanl(""))));
ASSERT_TRUE(isinf(logbl(HUGE_VALL)));
- ASSERT_EQ(0.0, logbl(1.0));
- ASSERT_EQ(3.0, logbl(10.0));
+ ASSERT_EQ(0.0l, logbl(1.0l));
+ ASSERT_EQ(3.0l, logbl(10.0l));
}
TEST(math, log1p) {
ASSERT_EQ(-HUGE_VAL, log1p(-1.0));
ASSERT_TRUE(isnan(log1p(nan(""))));
ASSERT_TRUE(isinf(log1p(HUGE_VAL)));
- ASSERT_FLOAT_EQ(1.0, log1p(M_E - 1.0));
+ ASSERT_DOUBLE_EQ(1.0, log1p(M_E - 1.0));
}
TEST(math, log1pf) {
@@ -862,16 +897,16 @@
}
TEST(math, log1pl) {
- ASSERT_EQ(-HUGE_VALL, log1pl(-1.0));
+ ASSERT_EQ(-HUGE_VALL, log1pl(-1.0l));
ASSERT_TRUE(isnan(log1pl(nanl(""))));
ASSERT_TRUE(isinf(log1pl(HUGE_VALL)));
- ASSERT_FLOAT_EQ(1.0, log1pl(M_E - 1.0));
+ ASSERT_DOUBLE_EQ(1.0l, log1pl(M_E - 1.0l));
}
TEST(math, fdim) {
- ASSERT_FLOAT_EQ(0.0, fdim(1.0, 1.0));
- ASSERT_FLOAT_EQ(1.0, fdim(2.0, 1.0));
- ASSERT_FLOAT_EQ(0.0, fdim(1.0, 2.0));
+ ASSERT_DOUBLE_EQ(0.0, fdim(1.0, 1.0));
+ ASSERT_DOUBLE_EQ(1.0, fdim(2.0, 1.0));
+ ASSERT_DOUBLE_EQ(0.0, fdim(1.0, 2.0));
}
TEST(math, fdimf) {
@@ -881,19 +916,19 @@
}
TEST(math, fdiml) {
- ASSERT_FLOAT_EQ(0.0, fdiml(1.0, 1.0));
- ASSERT_FLOAT_EQ(1.0, fdiml(2.0, 1.0));
- ASSERT_FLOAT_EQ(0.0, fdiml(1.0, 2.0));
+ ASSERT_DOUBLE_EQ(0.0l, fdiml(1.0l, 1.0l));
+ ASSERT_DOUBLE_EQ(1.0l, fdiml(2.0l, 1.0l));
+ ASSERT_DOUBLE_EQ(0.0l, fdiml(1.0l, 2.0l));
}
TEST(math, round) {
fesetround(FE_TOWARDZERO); // round ignores the rounding mode and always rounds away from zero.
- ASSERT_FLOAT_EQ(1.0, round(0.5));
- ASSERT_FLOAT_EQ(-1.0, round(-0.5));
- ASSERT_FLOAT_EQ(0.0, round(0.0));
- ASSERT_FLOAT_EQ(-0.0, round(-0.0));
+ ASSERT_DOUBLE_EQ(1.0, round(0.5));
+ ASSERT_DOUBLE_EQ(-1.0, round(-0.5));
+ ASSERT_DOUBLE_EQ(0.0, round(0.0));
+ ASSERT_DOUBLE_EQ(-0.0, round(-0.0));
ASSERT_TRUE(isnan(round(nan(""))));
- ASSERT_FLOAT_EQ(HUGE_VAL, round(HUGE_VAL));
+ ASSERT_DOUBLE_EQ(HUGE_VAL, round(HUGE_VAL));
}
TEST(math, roundf) {
@@ -908,22 +943,22 @@
TEST(math, roundl) {
fesetround(FE_TOWARDZERO); // roundl ignores the rounding mode and always rounds away from zero.
- ASSERT_FLOAT_EQ(1.0, roundl(0.5));
- ASSERT_FLOAT_EQ(-1.0, roundl(-0.5));
- ASSERT_FLOAT_EQ(0.0, roundl(0.0));
- ASSERT_FLOAT_EQ(-0.0, roundl(-0.0));
+ ASSERT_DOUBLE_EQ(1.0l, roundl(0.5l));
+ ASSERT_DOUBLE_EQ(-1.0l, roundl(-0.5l));
+ ASSERT_DOUBLE_EQ(0.0l, roundl(0.0l));
+ ASSERT_DOUBLE_EQ(-0.0l, roundl(-0.0l));
ASSERT_TRUE(isnan(roundl(nanl(""))));
- ASSERT_FLOAT_EQ(HUGE_VALL, roundl(HUGE_VALL));
+ ASSERT_DOUBLE_EQ(HUGE_VALL, roundl(HUGE_VALL));
}
TEST(math, trunc) {
fesetround(FE_UPWARD); // trunc ignores the rounding mode and always rounds toward zero.
- ASSERT_FLOAT_EQ(1.0, trunc(1.5));
- ASSERT_FLOAT_EQ(-1.0, trunc(-1.5));
- ASSERT_FLOAT_EQ(0.0, trunc(0.0));
- ASSERT_FLOAT_EQ(-0.0, trunc(-0.0));
+ ASSERT_DOUBLE_EQ(1.0, trunc(1.5));
+ ASSERT_DOUBLE_EQ(-1.0, trunc(-1.5));
+ ASSERT_DOUBLE_EQ(0.0, trunc(0.0));
+ ASSERT_DOUBLE_EQ(-0.0, trunc(-0.0));
ASSERT_TRUE(isnan(trunc(nan(""))));
- ASSERT_FLOAT_EQ(HUGE_VAL, trunc(HUGE_VAL));
+ ASSERT_DOUBLE_EQ(HUGE_VAL, trunc(HUGE_VAL));
}
TEST(math, truncf) {
@@ -938,18 +973,18 @@
TEST(math, truncl) {
fesetround(FE_UPWARD); // truncl ignores the rounding mode and always rounds toward zero.
- ASSERT_FLOAT_EQ(1.0, truncl(1.5));
- ASSERT_FLOAT_EQ(-1.0, truncl(-1.5));
- ASSERT_FLOAT_EQ(0.0, truncl(0.0));
- ASSERT_FLOAT_EQ(-0.0, truncl(-0.0));
+ ASSERT_DOUBLE_EQ(1.0l, truncl(1.5l));
+ ASSERT_DOUBLE_EQ(-1.0l, truncl(-1.5l));
+ ASSERT_DOUBLE_EQ(0.0l, truncl(0.0l));
+ ASSERT_DOUBLE_EQ(-0.0l, truncl(-0.0l));
ASSERT_TRUE(isnan(truncl(nan(""))));
- ASSERT_FLOAT_EQ(HUGE_VALL, truncl(HUGE_VALL));
+ ASSERT_DOUBLE_EQ(HUGE_VALL, truncl(HUGE_VALL));
}
TEST(math, nextafter) {
- ASSERT_FLOAT_EQ(0.0, nextafter(0.0, 0.0));
- ASSERT_FLOAT_EQ(1.4012985e-45, nextafter(0.0, 1.0));
- ASSERT_FLOAT_EQ(0.0, nextafter(0.0, -1.0));
+ 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));
}
TEST(math, nextafterf) {
@@ -959,9 +994,12 @@
}
TEST(math, nextafterl) {
- ASSERT_FLOAT_EQ(0.0, nextafterl(0.0, 0.0));
- ASSERT_FLOAT_EQ(1.4012985e-45, nextafterl(0.0, 1.0));
- ASSERT_FLOAT_EQ(0.0, nextafterl(0.0, -1.0));
+ ASSERT_DOUBLE_EQ(0.0l, nextafterl(0.0l, 0.0l));
+ // Use a runtime value to accomodate the case when
+ // 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));
}
// TODO: nexttoward
@@ -969,10 +1007,10 @@
// TODO: nexttowardl
TEST(math, copysign) {
- ASSERT_FLOAT_EQ(0.0, copysign(0.0, 1.0));
- ASSERT_FLOAT_EQ(-0.0, copysign(0.0, -1.0));
- ASSERT_FLOAT_EQ(2.0, copysign(2.0, 1.0));
- ASSERT_FLOAT_EQ(-2.0, copysign(2.0, -1.0));
+ ASSERT_DOUBLE_EQ(0.0, copysign(0.0, 1.0));
+ ASSERT_DOUBLE_EQ(-0.0, copysign(0.0, -1.0));
+ ASSERT_DOUBLE_EQ(2.0, copysign(2.0, 1.0));
+ ASSERT_DOUBLE_EQ(-2.0, copysign(2.0, -1.0));
}
TEST(math, copysignf) {
@@ -983,16 +1021,16 @@
}
TEST(math, copysignl) {
- ASSERT_FLOAT_EQ(0.0f, copysignl(0.0, 1.0));
- ASSERT_FLOAT_EQ(-0.0f, copysignl(0.0, -1.0));
- ASSERT_FLOAT_EQ(2.0f, copysignl(2.0, 1.0));
- ASSERT_FLOAT_EQ(-2.0f, copysignl(2.0, -1.0));
+ ASSERT_DOUBLE_EQ(0.0l, copysignl(0.0l, 1.0l));
+ ASSERT_DOUBLE_EQ(-0.0l, copysignl(0.0l, -1.0l));
+ ASSERT_DOUBLE_EQ(2.0l, copysignl(2.0l, 1.0l));
+ ASSERT_DOUBLE_EQ(-2.0l, copysignl(2.0l, -1.0l));
}
TEST(math, significand) {
- ASSERT_FLOAT_EQ(0.0, significand(0.0));
- ASSERT_FLOAT_EQ(1.2, significand(1.2));
- ASSERT_FLOAT_EQ(1.5375, significand(12.3));
+ ASSERT_DOUBLE_EQ(0.0, significand(0.0));
+ ASSERT_DOUBLE_EQ(1.2, significand(1.2));
+ ASSERT_DOUBLE_EQ(1.5375, significand(12.3));
}
TEST(math, significandf) {
@@ -1004,13 +1042,13 @@
extern "C" long double significandl(long double); // BSD's <math.h> doesn't declare this.
TEST(math, significandl) {
- ASSERT_FLOAT_EQ(0.0, significandl(0.0));
- ASSERT_FLOAT_EQ(1.2, significandl(1.2));
- ASSERT_FLOAT_EQ(1.5375, significandl(12.3));
+ ASSERT_DOUBLE_EQ(0.0l, significandl(0.0l));
+ ASSERT_DOUBLE_EQ(1.2l, significandl(1.2l));
+ ASSERT_DOUBLE_EQ(1.5375l, significandl(12.3l));
}
TEST(math, scalb) {
- ASSERT_FLOAT_EQ(12.0, scalb(3.0, 2.0));
+ ASSERT_DOUBLE_EQ(12.0, scalb(3.0, 2.0));
}
TEST(math, scalbf) {
@@ -1018,7 +1056,7 @@
}
TEST(math, scalbln) {
- ASSERT_FLOAT_EQ(12.0, scalbln(3.0, 2L));
+ ASSERT_DOUBLE_EQ(12.0, scalbln(3.0, 2L));
}
TEST(math, scalblnf) {
@@ -1026,11 +1064,11 @@
}
TEST(math, scalblnl) {
- ASSERT_FLOAT_EQ(12.0, scalblnl(3.0, 2L));
+ ASSERT_DOUBLE_EQ(12.0l, scalblnl(3.0l, 2L));
}
TEST(math, scalbn) {
- ASSERT_FLOAT_EQ(12.0, scalbn(3.0, 2));
+ ASSERT_DOUBLE_EQ(12.0, scalbn(3.0, 2));
}
TEST(math, scalbnf) {
@@ -1038,11 +1076,11 @@
}
TEST(math, scalbnl) {
- ASSERT_FLOAT_EQ(12.0, scalbnl(3.0, 2));
+ ASSERT_DOUBLE_EQ(12.0l, scalbnl(3.0l, 2));
}
TEST(math, gamma) {
- ASSERT_FLOAT_EQ(log(24.0), gamma(5.0));
+ ASSERT_DOUBLE_EQ(log(24.0), gamma(5.0));
}
TEST(math, gammaf) {
@@ -1052,7 +1090,7 @@
TEST(math, gamma_r) {
#if defined(__BIONIC__)
int sign;
- ASSERT_FLOAT_EQ(log(24.0), gamma_r(5.0, &sign));
+ ASSERT_DOUBLE_EQ(log(24.0), gamma_r(5.0, &sign));
ASSERT_EQ(1, sign);
#else // __BIONIC__
GTEST_LOG_(INFO) << "This test does nothing.\n";
@@ -1070,7 +1108,7 @@
}
TEST(math, lgamma) {
- ASSERT_FLOAT_EQ(log(24.0), lgamma(5.0));
+ ASSERT_DOUBLE_EQ(log(24.0), lgamma(5.0));
}
TEST(math, lgammaf) {
@@ -1078,12 +1116,12 @@
}
TEST(math, lgammal) {
- ASSERT_FLOAT_EQ(logl(24.0), lgammal(5.0));
+ ASSERT_DOUBLE_EQ(logl(24.0l), lgammal(5.0l));
}
TEST(math, lgamma_r) {
int sign;
- ASSERT_FLOAT_EQ(log(24.0), lgamma_r(5.0, &sign));
+ ASSERT_DOUBLE_EQ(log(24.0), lgamma_r(5.0, &sign));
ASSERT_EQ(1, sign);
}
@@ -1094,7 +1132,7 @@
}
TEST(math, tgamma) {
- ASSERT_FLOAT_EQ(24.0, tgamma(5.0));
+ ASSERT_DOUBLE_EQ(24.0, tgamma(5.0));
}
TEST(math, tgammaf) {
@@ -1102,12 +1140,12 @@
}
TEST(math, tgammal) {
- ASSERT_FLOAT_EQ(24.0, tgammal(5.0));
+ ASSERT_DOUBLE_EQ(24.0l, tgammal(5.0l));
}
TEST(math, j0) {
- ASSERT_FLOAT_EQ(1.0, j0(0.0));
- ASSERT_FLOAT_EQ(0.76519769, j0(1.0));
+ ASSERT_DOUBLE_EQ(1.0, j0(0.0));
+ ASSERT_DOUBLE_EQ(0.76519768655796661, j0(1.0));
}
TEST(math, j0f) {
@@ -1116,8 +1154,8 @@
}
TEST(math, j1) {
- ASSERT_FLOAT_EQ(0.0, j1(0.0));
- ASSERT_FLOAT_EQ(0.44005057, j1(1.0));
+ ASSERT_DOUBLE_EQ(0.0, j1(0.0));
+ ASSERT_DOUBLE_EQ(0.44005058574493355, j1(1.0));
}
TEST(math, j1f) {
@@ -1126,8 +1164,8 @@
}
TEST(math, jn) {
- ASSERT_FLOAT_EQ(0.0, jn(4, 0.0));
- ASSERT_FLOAT_EQ(0.0024766389, jn(4, 1.0));
+ ASSERT_DOUBLE_EQ(0.0, jn(4, 0.0));
+ ASSERT_DOUBLE_EQ(0.0024766389641099553, jn(4, 1.0));
}
TEST(math, jnf) {
@@ -1136,8 +1174,8 @@
}
TEST(math, y0) {
- ASSERT_FLOAT_EQ(-HUGE_VAL, y0(0.0));
- ASSERT_FLOAT_EQ(0.088256963, y0(1.0));
+ ASSERT_DOUBLE_EQ(-HUGE_VAL, y0(0.0));
+ ASSERT_DOUBLE_EQ(0.08825696421567697, y0(1.0));
}
TEST(math, y0f) {
@@ -1146,8 +1184,8 @@
}
TEST(math, y1) {
- ASSERT_FLOAT_EQ(-HUGE_VAL, y1(0.0));
- ASSERT_FLOAT_EQ(-0.78121281, y1(1.0));
+ ASSERT_DOUBLE_EQ(-HUGE_VAL, y1(0.0));
+ ASSERT_DOUBLE_EQ(-0.78121282130028868, y1(1.0));
}
TEST(math, y1f) {
@@ -1156,8 +1194,8 @@
}
TEST(math, yn) {
- ASSERT_FLOAT_EQ(-HUGE_VAL, yn(4, 0.0));
- ASSERT_FLOAT_EQ(-33.278423, yn(4, 1.0));
+ ASSERT_DOUBLE_EQ(-HUGE_VAL, yn(4, 0.0));
+ ASSERT_DOUBLE_EQ(-33.278423028972114, yn(4, 1.0));
}
TEST(math, ynf) {
@@ -1168,7 +1206,7 @@
TEST(math, frexp) {
int exp;
double dr = frexp(1024.0, &exp);
- ASSERT_FLOAT_EQ(1024.0, scalbn(dr, exp));
+ ASSERT_DOUBLE_EQ(1024.0, scalbn(dr, exp));
}
TEST(math, frexpf) {
@@ -1179,15 +1217,15 @@
TEST(math, frexpl) {
int exp;
- long double ldr = frexpl(1024.0, &exp);
- ASSERT_FLOAT_EQ(1024.0, scalbnl(ldr, exp));
+ long double ldr = frexpl(1024.0l, &exp);
+ ASSERT_DOUBLE_EQ(1024.0l, scalbnl(ldr, exp));
}
TEST(math, modf) {
double di;
double df = modf(123.456, &di);
- ASSERT_FLOAT_EQ(123.0, di);
- ASSERT_FLOAT_EQ(0.456, df);
+ ASSERT_DOUBLE_EQ(123.0, di);
+ ASSERT_DOUBLE_EQ(0.45600000000000307, df);
}
TEST(math, modff) {
@@ -1199,16 +1237,16 @@
TEST(math, modfl) {
long double ldi;
- long double ldf = modfl(123.456, &ldi);
- ASSERT_FLOAT_EQ(123.0, ldi);
- ASSERT_FLOAT_EQ(0.456, ldf);
+ long double ldf = modfl(123.456l, &ldi);
+ ASSERT_DOUBLE_EQ(123.0l, ldi);
+ ASSERT_DOUBLE_EQ(0.45600000000000002l, ldf);
}
TEST(math, remquo) {
int q;
double d = remquo(13.0, 4.0, &q);
ASSERT_EQ(3, q);
- ASSERT_FLOAT_EQ(1.0, d);
+ ASSERT_DOUBLE_EQ(1.0, d);
}
TEST(math, remquof) {
@@ -1220,9 +1258,9 @@
TEST(math, remquol) {
int q;
- long double ld = remquol(13.0, 4.0, &q);
- ASSERT_EQ(3, q);
- ASSERT_FLOAT_EQ(1.0, ld);
+ long double ld = remquol(13.0l, 4.0l, &q);
+ ASSERT_DOUBLE_EQ(3l, q);
+ ASSERT_DOUBLE_EQ(1.0l, ld);
}
// https://code.google.com/p/android/issues/detail?id=6697