2 * Copyright (C) 2013 The Android Open Source Project
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
8 * http://www.apache.org/licenses/LICENSE-2.0
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
17 // This include (and the associated definition of __test_capture_signbit)
18 // must be placed before any files that include <cmath> (gtest.h in this case).
20 // <math.h> is required to define generic macros signbit, isfinite and
21 // several other such functions.
23 // <cmath> is required to undef declarations of these macros in the global
24 // namespace and make equivalent functions available in namespace std. Our
25 // stlport implementation does this only for signbit, isfinite, isinf and
28 // NOTE: We don't write our test using std::signbit because we want to be
29 // sure that we're testing the bionic version of signbit. The C++ libraries
30 // are free to reimplement signbit or delegate to compiler builtins if they
35 template<typename T> inline int test_capture_signbit(const T in) {
38 template<typename T> inline int test_capture_isfinite(const T in) {
41 template<typename T> inline int test_capture_isnan(const T in) {
44 template<typename T> inline int test_capture_isinf(const T in) {
49 #include <gtest/gtest.h>
56 #include <private/ScopeGuard.h>
58 float float_subnormal() {
67 double double_subnormal() {
72 u.i = 0x000fffffffffffffLL;
76 long double ldouble_subnormal() {
79 unsigned char c[sizeof(long double)];
82 // Subnormals must have a zero exponent and non zero significand.
83 // On all supported representation the 17 bit (counting from either sides)
84 // is part of the significand so it should be enough to set that.
85 // It also applies for the case sizeof(double) = sizeof(long double)
86 for (unsigned int i = 0; i < sizeof(long double); i++) {
89 u.c[sizeof(long double) - 3] = 0x80;
95 TEST(math, fpclassify) {
96 ASSERT_EQ(FP_INFINITE, fpclassify(INFINITY));
97 ASSERT_EQ(FP_INFINITE, fpclassify(HUGE_VALF));
98 ASSERT_EQ(FP_INFINITE, fpclassify(HUGE_VAL));
99 ASSERT_EQ(FP_INFINITE, fpclassify(HUGE_VALL));
101 ASSERT_EQ(FP_NAN, fpclassify(nanf("")));
102 ASSERT_EQ(FP_NAN, fpclassify(nan("")));
103 ASSERT_EQ(FP_NAN, fpclassify(nanl("")));
105 ASSERT_EQ(FP_NORMAL, fpclassify(1.0f));
106 ASSERT_EQ(FP_NORMAL, fpclassify(1.0));
107 ASSERT_EQ(FP_NORMAL, fpclassify(1.0L));
109 ASSERT_EQ(FP_SUBNORMAL, fpclassify(float_subnormal()));
110 ASSERT_EQ(FP_SUBNORMAL, fpclassify(double_subnormal()));
111 ASSERT_EQ(FP_SUBNORMAL, fpclassify(ldouble_subnormal()));
113 ASSERT_EQ(FP_ZERO, fpclassify(0.0f));
114 ASSERT_EQ(FP_ZERO, fpclassify(0.0));
115 ASSERT_EQ(FP_ZERO, fpclassify(0.0L));
118 TEST(math, isfinite) {
119 ASSERT_TRUE(test_capture_isfinite(123.0f));
120 ASSERT_TRUE(test_capture_isfinite(123.0));
121 ASSERT_TRUE(test_capture_isfinite(123.0L));
122 ASSERT_FALSE(test_capture_isfinite(HUGE_VALF));
123 ASSERT_FALSE(test_capture_isfinite(HUGE_VAL));
124 ASSERT_FALSE(test_capture_isfinite(HUGE_VALL));
128 ASSERT_FALSE(test_capture_isinf(123.0f));
129 ASSERT_FALSE(test_capture_isinf(123.0));
130 ASSERT_FALSE(test_capture_isinf(123.0L));
131 ASSERT_TRUE(test_capture_isinf(HUGE_VALF));
132 ASSERT_TRUE(test_capture_isinf(HUGE_VAL));
133 ASSERT_TRUE(test_capture_isinf(HUGE_VALL));
137 ASSERT_FALSE(test_capture_isnan(123.0f));
138 ASSERT_FALSE(test_capture_isnan(123.0));
139 ASSERT_FALSE(test_capture_isnan(123.0L));
140 ASSERT_TRUE(test_capture_isnan(nanf("")));
141 ASSERT_TRUE(test_capture_isnan(nan("")));
142 ASSERT_TRUE(test_capture_isnan(nanl("")));
145 TEST(math, isnormal) {
146 ASSERT_TRUE(isnormal(123.0f));
147 ASSERT_TRUE(isnormal(123.0));
148 ASSERT_TRUE(isnormal(123.0L));
149 ASSERT_FALSE(isnormal(float_subnormal()));
150 ASSERT_FALSE(isnormal(double_subnormal()));
151 ASSERT_FALSE(isnormal(ldouble_subnormal()));
154 // TODO: isgreater, isgreaterequals, isless, islessequal, islessgreater, isunordered
155 TEST(math, signbit) {
156 ASSERT_EQ(0, test_capture_signbit(0.0f));
157 ASSERT_EQ(0, test_capture_signbit(0.0));
158 ASSERT_EQ(0, test_capture_signbit(0.0L));
160 ASSERT_EQ(0, test_capture_signbit(1.0f));
161 ASSERT_EQ(0, test_capture_signbit(1.0));
162 ASSERT_EQ(0, test_capture_signbit(1.0L));
164 ASSERT_NE(0, test_capture_signbit(-1.0f));
165 ASSERT_NE(0, test_capture_signbit(-1.0));
166 ASSERT_NE(0, test_capture_signbit(-1.0L));
169 TEST(math, __fpclassifyd) {
170 #if defined(__BIONIC__)
171 ASSERT_EQ(FP_INFINITE, __fpclassifyd(HUGE_VAL));
172 ASSERT_EQ(FP_NAN, __fpclassifyd(nan("")));
173 ASSERT_EQ(FP_NORMAL, __fpclassifyd(1.0));
174 ASSERT_EQ(FP_SUBNORMAL, __fpclassifyd(double_subnormal()));
175 ASSERT_EQ(FP_ZERO, __fpclassifyd(0.0));
177 GTEST_LOG_(INFO) << "This test does nothing.\n";
181 TEST(math, __fpclassifyf) {
182 #if defined(__BIONIC__)
183 ASSERT_EQ(FP_INFINITE, __fpclassifyf(HUGE_VALF));
184 ASSERT_EQ(FP_NAN, __fpclassifyf(nanf("")));
185 ASSERT_EQ(FP_NORMAL, __fpclassifyf(1.0f));
186 ASSERT_EQ(FP_SUBNORMAL, __fpclassifyf(float_subnormal()));
187 ASSERT_EQ(FP_ZERO, __fpclassifyf(0.0f));
189 GTEST_LOG_(INFO) << "This test does nothing.\n";
193 TEST(math, __fpclassifyl) {
194 #if defined(__BIONIC__)
195 EXPECT_EQ(FP_INFINITE, __fpclassifyl(HUGE_VALL));
196 EXPECT_EQ(FP_NAN, __fpclassifyl(nanl("")));
197 EXPECT_EQ(FP_NORMAL, __fpclassifyl(1.0L));
198 EXPECT_EQ(FP_SUBNORMAL, __fpclassifyl(ldouble_subnormal()));
199 EXPECT_EQ(FP_ZERO, __fpclassifyl(0.0L));
201 GTEST_LOG_(INFO) << "This test does nothing.\n";
205 TEST(math, finitef) {
206 ASSERT_TRUE(finitef(123.0f));
207 ASSERT_FALSE(finitef(HUGE_VALF));
210 TEST(math, __isfinite) {
211 #if defined(__BIONIC__)
212 ASSERT_TRUE(__isfinite(123.0));
213 ASSERT_FALSE(__isfinite(HUGE_VAL));
215 GTEST_LOG_(INFO) << "This test does nothing.\n";
219 TEST(math, __isfinitef) {
220 #if defined(__BIONIC__)
221 ASSERT_TRUE(__isfinitef(123.0f));
222 ASSERT_FALSE(__isfinitef(HUGE_VALF));
224 GTEST_LOG_(INFO) << "This test does nothing.\n";
228 TEST(math, __isfinitel) {
229 #if defined(__BIONIC__)
230 ASSERT_TRUE(__isfinitel(123.0L));
231 ASSERT_FALSE(__isfinitel(HUGE_VALL));
233 GTEST_LOG_(INFO) << "This test does nothing.\n";
238 ASSERT_TRUE(finite(123.0));
239 ASSERT_FALSE(finite(HUGE_VAL));
242 TEST(math, isinf_function) {
243 // The isinf macro deals with all three types; the isinf function is for doubles.
244 ASSERT_FALSE((isinf)(123.0));
245 ASSERT_TRUE((isinf)(HUGE_VAL));
248 TEST(math, __isinff) {
249 ASSERT_FALSE(__isinff(123.0f));
250 ASSERT_TRUE(__isinff(HUGE_VALF));
253 TEST(math, __isinfl) {
254 ASSERT_FALSE(__isinfl(123.0L));
255 ASSERT_TRUE(__isinfl(HUGE_VALL));
258 TEST(math, isnan_function) {
259 // The isnan macro deals with all three types; the isnan function is for doubles.
260 ASSERT_FALSE((isnan)(123.0));
261 ASSERT_TRUE((isnan)(nan("")));
264 TEST(math, __isnanf) {
265 ASSERT_FALSE(__isnanf(123.0f));
266 ASSERT_TRUE(__isnanf(nanf("")));
269 TEST(math, __isnanl) {
270 ASSERT_FALSE(__isnanl(123.0L));
271 ASSERT_TRUE(__isnanl(nanl("")));
275 ASSERT_FALSE(isnanf(123.0f));
276 ASSERT_TRUE(isnanf(nanf("")));
279 TEST(math, __isnormal) {
280 #if defined(__BIONIC__)
281 ASSERT_TRUE(__isnormal(123.0));
282 ASSERT_FALSE(__isnormal(double_subnormal()));
284 GTEST_LOG_(INFO) << "This test does nothing.\n";
288 TEST(math, __isnormalf) {
289 #if defined(__BIONIC__)
290 ASSERT_TRUE(__isnormalf(123.0f));
291 ASSERT_FALSE(__isnormalf(float_subnormal()));
293 GTEST_LOG_(INFO) << "This test does nothing.\n";
297 TEST(math, __isnormall) {
298 #if defined(__BIONIC__)
299 ASSERT_TRUE(__isnormall(123.0L));
300 ASSERT_FALSE(__isnormall(ldouble_subnormal()));
302 GTEST_LOG_(INFO) << "This test does nothing.\n";
306 TEST(math, __signbit) {
307 ASSERT_EQ(0, __signbit(0.0));
308 ASSERT_EQ(0, __signbit(1.0));
309 ASSERT_NE(0, __signbit(-1.0));
312 TEST(math, __signbitf) {
313 ASSERT_EQ(0, __signbitf(0.0f));
314 ASSERT_EQ(0, __signbitf(1.0f));
315 ASSERT_NE(0, __signbitf(-1.0f));
318 TEST(math, __signbitl) {
319 ASSERT_EQ(0L, __signbitl(0.0L));
320 ASSERT_EQ(0L, __signbitl(1.0L));
321 ASSERT_NE(0L, __signbitl(-1.0L));
325 ASSERT_DOUBLE_EQ(M_PI/2.0, acos(0.0));
329 ASSERT_FLOAT_EQ(static_cast<float>(M_PI)/2.0f, acosf(0.0f));
333 ASSERT_DOUBLE_EQ(M_PI/2.0L, acosl(0.0L));
337 ASSERT_DOUBLE_EQ(0.0, asin(0.0));
341 ASSERT_FLOAT_EQ(0.0f, asinf(0.0f));
345 ASSERT_DOUBLE_EQ(0.0L, asinl(0.0L));
349 ASSERT_DOUBLE_EQ(0.0, atan(0.0));
353 ASSERT_FLOAT_EQ(0.0f, atanf(0.0f));
357 ASSERT_DOUBLE_EQ(0.0L, atanl(0.0L));
361 ASSERT_DOUBLE_EQ(0.0, atan2(0.0, 0.0));
365 ASSERT_FLOAT_EQ(0.0f, atan2f(0.0f, 0.0f));
369 ASSERT_DOUBLE_EQ(0.0L, atan2l(0.0L, 0.0L));
373 ASSERT_DOUBLE_EQ(1.0, cos(0.0));
377 ASSERT_FLOAT_EQ(1.0f, cosf(0.0f));
381 ASSERT_DOUBLE_EQ(1.0L, cosl(0.0L));
385 ASSERT_DOUBLE_EQ(0.0, sin(0.0));
389 ASSERT_FLOAT_EQ(0.0f, sinf(0.0f));
393 ASSERT_DOUBLE_EQ(0.0L, sinl(0.0L));
397 ASSERT_DOUBLE_EQ(0.0, tan(0.0));
401 ASSERT_FLOAT_EQ(0.0f, tanf(0.0f));
405 ASSERT_DOUBLE_EQ(0.0L, tanl(0.0L));
409 ASSERT_DOUBLE_EQ(0.0, acosh(1.0));
413 ASSERT_FLOAT_EQ(0.0f, acoshf(1.0f));
417 ASSERT_DOUBLE_EQ(0.0L, acoshl(1.0L));
421 ASSERT_DOUBLE_EQ(0.0, asinh(0.0));
425 ASSERT_FLOAT_EQ(0.0f, asinhf(0.0f));
429 ASSERT_DOUBLE_EQ(0.0L, asinhl(0.0L));
433 ASSERT_DOUBLE_EQ(0.0, atanh(0.0));
437 ASSERT_FLOAT_EQ(0.0f, atanhf(0.0f));
441 ASSERT_DOUBLE_EQ(0.0L, atanhl(0.0L));
445 ASSERT_DOUBLE_EQ(1.0, cosh(0.0));
449 ASSERT_FLOAT_EQ(1.0f, coshf(0.0f));
453 ASSERT_DOUBLE_EQ(1.0L, coshl(0.0L));
457 ASSERT_DOUBLE_EQ(0.0, sinh(0.0));
461 ASSERT_FLOAT_EQ(0.0f, sinhf(0.0f));
465 ASSERT_DOUBLE_EQ(0.0L, sinhl(0.0L));
469 ASSERT_DOUBLE_EQ(0.0, tanh(0.0));
473 ASSERT_FLOAT_EQ(0.0f, tanhf(0.0f));
477 ASSERT_DOUBLE_EQ(0.0L, tanhl(0.0L));
481 ASSERT_DOUBLE_EQ(1.0, log(M_E));
485 ASSERT_FLOAT_EQ(1.0f, logf(static_cast<float>(M_E)));
489 ASSERT_DOUBLE_EQ(1.0L, logl(M_E));
493 ASSERT_DOUBLE_EQ(12.0, log2(4096.0));
497 ASSERT_FLOAT_EQ(12.0f, log2f(4096.0f));
501 ASSERT_DOUBLE_EQ(12.0L, log2l(4096.0L));
505 ASSERT_DOUBLE_EQ(3.0, log10(1000.0));
509 ASSERT_FLOAT_EQ(3.0f, log10f(1000.0f));
513 ASSERT_DOUBLE_EQ(3.0L, log10l(1000.0L));
517 ASSERT_DOUBLE_EQ(3.0, cbrt(27.0));
521 ASSERT_FLOAT_EQ(3.0f, cbrtf(27.0f));
525 ASSERT_DOUBLE_EQ(3.0L, cbrtl(27.0L));
529 ASSERT_DOUBLE_EQ(2.0, sqrt(4.0));
533 ASSERT_FLOAT_EQ(2.0f, sqrtf(4.0f));
537 ASSERT_DOUBLE_EQ(2.0L, sqrtl(4.0L));
541 ASSERT_DOUBLE_EQ(1.0, exp(0.0));
542 ASSERT_DOUBLE_EQ(M_E, exp(1.0));
546 ASSERT_FLOAT_EQ(1.0f, expf(0.0f));
547 ASSERT_FLOAT_EQ(static_cast<float>(M_E), expf(1.0f));
551 ASSERT_DOUBLE_EQ(1.0L, expl(0.0L));
552 ASSERT_DOUBLE_EQ(M_E, expl(1.0L));
556 ASSERT_DOUBLE_EQ(8.0, exp2(3.0));
560 ASSERT_FLOAT_EQ(8.0f, exp2f(3.0f));
564 ASSERT_DOUBLE_EQ(8.0L, exp2l(3.0L));
568 ASSERT_DOUBLE_EQ(M_E - 1.0, expm1(1.0));
572 ASSERT_FLOAT_EQ(static_cast<float>(M_E) - 1.0f, expm1f(1.0f));
576 ASSERT_DOUBLE_EQ(M_E - 1.0L, expm1l(1.0L));
580 ASSERT_TRUE(isnan(pow(nan(""), 3.0)));
581 ASSERT_DOUBLE_EQ(1.0, (pow(1.0, nan(""))));
582 ASSERT_TRUE(isnan(pow(2.0, nan(""))));
583 ASSERT_DOUBLE_EQ(8.0, pow(2.0, 3.0));
587 ASSERT_TRUE(isnanf(powf(nanf(""), 3.0f)));
588 ASSERT_FLOAT_EQ(1.0f, (powf(1.0f, nanf(""))));
589 ASSERT_TRUE(isnanf(powf(2.0f, nanf(""))));
590 ASSERT_FLOAT_EQ(8.0f, powf(2.0f, 3.0f));
594 ASSERT_TRUE(__isnanl(powl(nanl(""), 3.0L)));
595 ASSERT_DOUBLE_EQ(1.0L, (powl(1.0L, nanl(""))));
596 ASSERT_TRUE(__isnanl(powl(2.0L, nanl(""))));
597 ASSERT_DOUBLE_EQ(8.0L, powl(2.0L, 3.0L));
601 ASSERT_DOUBLE_EQ(1.0, ceil(0.9));
605 ASSERT_FLOAT_EQ(1.0f, ceilf(0.9f));
609 ASSERT_DOUBLE_EQ(1.0L, ceill(0.9L));
613 ASSERT_DOUBLE_EQ(1.0, floor(1.1));
617 ASSERT_FLOAT_EQ(1.0f, floorf(1.1f));
621 ASSERT_DOUBLE_EQ(1.0L, floorl(1.1L));
625 ASSERT_DOUBLE_EQ(1.0, fabs(-1.0));
629 ASSERT_FLOAT_EQ(1.0f, fabsf(-1.0f));
633 ASSERT_DOUBLE_EQ(1.0L, fabsl(-1.0L));
637 ASSERT_DOUBLE_EQ(16.0, ldexp(2.0, 3.0));
641 ASSERT_FLOAT_EQ(16.0f, ldexpf(2.0f, 3.0f));
645 ASSERT_DOUBLE_EQ(16.0L, ldexpl(2.0L, 3.0));
649 ASSERT_DOUBLE_EQ(2.0, fmod(12.0, 10.0));
653 ASSERT_FLOAT_EQ(2.0f, fmodf(12.0f, 10.0f));
657 ASSERT_DOUBLE_EQ(2.0L, fmodl(12.0L, 10.0L));
660 TEST(math, remainder) {
661 ASSERT_DOUBLE_EQ(2.0, remainder(12.0, 10.0));
664 TEST(math, remainderf) {
665 ASSERT_FLOAT_EQ(2.0f, remainderf(12.0f, 10.0f));
668 TEST(math, remainderl) {
669 ASSERT_DOUBLE_EQ(2.0L, remainderl(12.0L, 10.0L));
673 ASSERT_DOUBLE_EQ(2.0, drem(12.0, 10.0));
677 ASSERT_FLOAT_EQ(2.0f, dremf(12.0f, 10.0f));
681 ASSERT_DOUBLE_EQ(12.0, fmax(12.0, 10.0));
682 ASSERT_DOUBLE_EQ(12.0, fmax(12.0, nan("")));
683 ASSERT_DOUBLE_EQ(12.0, fmax(nan(""), 12.0));
687 ASSERT_FLOAT_EQ(12.0f, fmaxf(12.0f, 10.0f));
688 ASSERT_FLOAT_EQ(12.0f, fmaxf(12.0f, nanf("")));
689 ASSERT_FLOAT_EQ(12.0f, fmaxf(nanf(""), 12.0f));
693 ASSERT_DOUBLE_EQ(12.0L, fmaxl(12.0L, 10.0L));
694 ASSERT_DOUBLE_EQ(12.0L, fmaxl(12.0L, nanl("")));
695 ASSERT_DOUBLE_EQ(12.0L, fmaxl(nanl(""), 12.0L));
699 ASSERT_DOUBLE_EQ(10.0, fmin(12.0, 10.0));
700 ASSERT_DOUBLE_EQ(12.0, fmin(12.0, nan("")));
701 ASSERT_DOUBLE_EQ(12.0, fmin(nan(""), 12.0));
705 ASSERT_FLOAT_EQ(10.0f, fminf(12.0f, 10.0f));
706 ASSERT_FLOAT_EQ(12.0f, fminf(12.0f, nanf("")));
707 ASSERT_FLOAT_EQ(12.0f, fminf(nanf(""), 12.0f));
711 ASSERT_DOUBLE_EQ(10.0L, fminl(12.0L, 10.0L));
712 ASSERT_DOUBLE_EQ(12.0L, fminl(12.0L, nanl("")));
713 ASSERT_DOUBLE_EQ(12.0L, fminl(nanl(""), 12.0L));
717 ASSERT_DOUBLE_EQ(10.0, fma(2.0, 3.0, 4.0));
721 ASSERT_FLOAT_EQ(10.0f, fmaf(2.0f, 3.0f, 4.0f));
725 ASSERT_DOUBLE_EQ(10.0L, fmal(2.0L, 3.0L, 4.0L));
729 ASSERT_DOUBLE_EQ(5.0, hypot(3.0, 4.0));
733 ASSERT_FLOAT_EQ(5.0f, hypotf(3.0f, 4.0f));
737 ASSERT_DOUBLE_EQ(5.0L, hypotl(3.0L, 4.0L));
741 ASSERT_DOUBLE_EQ(0.84270079294971489, erf(1.0));
745 ASSERT_FLOAT_EQ(0.84270078f, erff(1.0f));
749 ASSERT_DOUBLE_EQ(0.84270079294971489L, erfl(1.0L));
753 ASSERT_DOUBLE_EQ(0.15729920705028513, erfc(1.0));
757 ASSERT_FLOAT_EQ(0.15729921f, erfcf(1.0f));
761 ASSERT_DOUBLE_EQ(0.15729920705028513l, erfcl(1.0L));
765 auto guard = make_scope_guard([]() {
766 fesetenv(FE_DFL_ENV);
769 fesetround(FE_UPWARD); // lrint/lrintf/lrintl obey the rounding mode.
770 ASSERT_EQ(1235, lrint(1234.01));
771 ASSERT_EQ(1235, lrintf(1234.01f));
772 ASSERT_EQ(1235, lrintl(1234.01L));
773 fesetround(FE_TOWARDZERO); // lrint/lrintf/lrintl obey the rounding mode.
774 ASSERT_EQ(1234, lrint(1234.01));
775 ASSERT_EQ(1234, lrintf(1234.01f));
776 ASSERT_EQ(1234, lrintl(1234.01L));
778 fesetround(FE_UPWARD); // llrint/llrintf/llrintl obey the rounding mode.
779 ASSERT_EQ(1235L, llrint(1234.01));
780 ASSERT_EQ(1235L, llrintf(1234.01f));
781 ASSERT_EQ(1235L, llrintl(1234.01L));
782 fesetround(FE_TOWARDZERO); // llrint/llrintf/llrintl obey the rounding mode.
783 ASSERT_EQ(1234L, llrint(1234.01));
784 ASSERT_EQ(1234L, llrintf(1234.01f));
785 ASSERT_EQ(1234L, llrintl(1234.01L));
789 auto guard = make_scope_guard([]() {
790 fesetenv(FE_DFL_ENV);
793 fesetround(FE_UPWARD); // rint/rintf/rintl obey the rounding mode.
794 feclearexcept(FE_ALL_EXCEPT); // rint/rintf/rintl do set the FE_INEXACT flag.
795 ASSERT_EQ(1234.0, rint(1234.0));
796 ASSERT_TRUE((fetestexcept(FE_ALL_EXCEPT) & FE_INEXACT) == 0);
797 ASSERT_EQ(1235.0, rint(1234.01));
798 ASSERT_TRUE((fetestexcept(FE_ALL_EXCEPT) & FE_INEXACT) != 0);
800 feclearexcept(FE_ALL_EXCEPT); // rint/rintf/rintl do set the FE_INEXACT flag.
801 ASSERT_EQ(1234.0f, rintf(1234.0f));
802 ASSERT_TRUE((fetestexcept(FE_ALL_EXCEPT) & FE_INEXACT) == 0);
803 ASSERT_EQ(1235.0f, rintf(1234.01f));
804 ASSERT_TRUE((fetestexcept(FE_ALL_EXCEPT) & FE_INEXACT) != 0);
806 feclearexcept(FE_ALL_EXCEPT); // rint/rintf/rintl do set the FE_INEXACT flag.
807 ASSERT_EQ(1234.0, rintl(1234.0L));
808 ASSERT_TRUE((fetestexcept(FE_ALL_EXCEPT) & FE_INEXACT) == 0);
809 ASSERT_EQ(1235.0, rintl(1234.01L));
810 ASSERT_TRUE((fetestexcept(FE_ALL_EXCEPT) & FE_INEXACT) != 0);
812 fesetround(FE_TOWARDZERO); // rint/rintf obey the rounding mode.
813 ASSERT_EQ(1234.0, rint(1234.01));
814 ASSERT_EQ(1234.0f, rintf(1234.01f));
815 ASSERT_EQ(1234.0, rintl(1234.01L));
818 TEST(math, nearbyint) {
819 auto guard = make_scope_guard([]() {
820 fesetenv(FE_DFL_ENV);
822 fesetround(FE_UPWARD); // nearbyint/nearbyintf/nearbyintl obey the rounding mode.
823 feclearexcept(FE_ALL_EXCEPT); // nearbyint/nearbyintf/nearbyintl don't set the FE_INEXACT flag.
824 ASSERT_EQ(1234.0, nearbyint(1234.0));
825 ASSERT_TRUE((fetestexcept(FE_ALL_EXCEPT) & FE_INEXACT) == 0);
826 ASSERT_EQ(1235.0, nearbyint(1234.01));
827 ASSERT_TRUE((fetestexcept(FE_ALL_EXCEPT) & FE_INEXACT) == 0);
829 feclearexcept(FE_ALL_EXCEPT);
830 ASSERT_EQ(1234.0f, nearbyintf(1234.0f));
831 ASSERT_TRUE((fetestexcept(FE_ALL_EXCEPT) & FE_INEXACT) == 0);
832 ASSERT_EQ(1235.0f, nearbyintf(1234.01f));
833 ASSERT_TRUE((fetestexcept(FE_ALL_EXCEPT) & FE_INEXACT) == 0);
835 feclearexcept(FE_ALL_EXCEPT); // nearbyint/nearbyintf/nearbyintl don't set the FE_INEXACT flag.
836 ASSERT_EQ(1234.0, nearbyintl(1234.0L));
837 ASSERT_TRUE((fetestexcept(FE_ALL_EXCEPT) & FE_INEXACT) == 0);
838 ASSERT_EQ(1235.0, nearbyintl(1234.01L));
839 ASSERT_TRUE((fetestexcept(FE_ALL_EXCEPT) & FE_INEXACT) == 0);
841 fesetround(FE_TOWARDZERO); // nearbyint/nearbyintf/nearbyintl obey the rounding mode.
842 ASSERT_EQ(1234.0, nearbyint(1234.01));
843 ASSERT_EQ(1234.0f, nearbyintf(1234.01f));
844 ASSERT_EQ(1234.0, nearbyintl(1234.01L));
848 auto guard = make_scope_guard([]() {
849 fesetenv(FE_DFL_ENV);
851 fesetround(FE_UPWARD); // lround ignores the rounding mode.
852 ASSERT_EQ(1234, lround(1234.01));
853 ASSERT_EQ(1234, lroundf(1234.01f));
854 ASSERT_EQ(1234, lroundl(1234.01L));
857 TEST(math, llround) {
858 auto guard = make_scope_guard([]() {
859 fesetenv(FE_DFL_ENV);
861 fesetround(FE_UPWARD); // llround ignores the rounding mode.
862 ASSERT_EQ(1234L, llround(1234.01));
863 ASSERT_EQ(1234L, llroundf(1234.01f));
864 ASSERT_EQ(1234L, llroundl(1234.01L));
868 ASSERT_EQ(FP_ILOGB0, ilogb(0.0));
869 ASSERT_EQ(FP_ILOGBNAN, ilogb(nan("")));
870 ASSERT_EQ(INT_MAX, ilogb(HUGE_VAL));
871 ASSERT_EQ(0, ilogb(1.0));
872 ASSERT_EQ(3, ilogb(10.0));
876 ASSERT_EQ(FP_ILOGB0, ilogbf(0.0f));
877 ASSERT_EQ(FP_ILOGBNAN, ilogbf(nanf("")));
878 ASSERT_EQ(INT_MAX, ilogbf(HUGE_VALF));
879 ASSERT_EQ(0, ilogbf(1.0f));
880 ASSERT_EQ(3, ilogbf(10.0f));
884 ASSERT_EQ(FP_ILOGB0, ilogbl(0.0L));
885 ASSERT_EQ(FP_ILOGBNAN, ilogbl(nanl("")));
886 ASSERT_EQ(INT_MAX, ilogbl(HUGE_VALL));
887 ASSERT_EQ(0L, ilogbl(1.0L));
888 ASSERT_EQ(3L, ilogbl(10.0L));
892 ASSERT_EQ(-HUGE_VAL, logb(0.0));
893 ASSERT_TRUE(isnan(logb(nan(""))));
894 ASSERT_TRUE(isinf(logb(HUGE_VAL)));
895 ASSERT_EQ(0.0, logb(1.0));
896 ASSERT_EQ(3.0, logb(10.0));
900 ASSERT_EQ(-HUGE_VALF, logbf(0.0f));
901 ASSERT_TRUE(isnanf(logbf(nanf(""))));
902 ASSERT_TRUE(__isinff(logbf(HUGE_VALF)));
903 ASSERT_EQ(0.0f, logbf(1.0f));
904 ASSERT_EQ(3.0f, logbf(10.0f));
908 ASSERT_EQ(-HUGE_VAL, logbl(0.0L));
909 ASSERT_TRUE(isnan(logbl(nanl(""))));
910 ASSERT_TRUE(isinf(logbl(HUGE_VALL)));
911 ASSERT_EQ(0.0L, logbl(1.0L));
912 ASSERT_EQ(3.0L, logbl(10.0L));
916 ASSERT_EQ(-HUGE_VAL, log1p(-1.0));
917 ASSERT_TRUE(isnan(log1p(nan(""))));
918 ASSERT_TRUE(isinf(log1p(HUGE_VAL)));
919 ASSERT_DOUBLE_EQ(1.0, log1p(M_E - 1.0));
923 ASSERT_EQ(-HUGE_VALF, log1pf(-1.0f));
924 ASSERT_TRUE(isnanf(log1pf(nanf(""))));
925 ASSERT_TRUE(__isinff(log1pf(HUGE_VALF)));
926 ASSERT_FLOAT_EQ(1.0f, log1pf(static_cast<float>(M_E) - 1.0f));
930 ASSERT_EQ(-HUGE_VALL, log1pl(-1.0L));
931 ASSERT_TRUE(isnan(log1pl(nanl(""))));
932 ASSERT_TRUE(isinf(log1pl(HUGE_VALL)));
933 ASSERT_DOUBLE_EQ(1.0L, log1pl(M_E - 1.0L));
937 ASSERT_DOUBLE_EQ(0.0, fdim(1.0, 1.0));
938 ASSERT_DOUBLE_EQ(1.0, fdim(2.0, 1.0));
939 ASSERT_DOUBLE_EQ(0.0, fdim(1.0, 2.0));
943 ASSERT_FLOAT_EQ(0.0f, fdimf(1.0f, 1.0f));
944 ASSERT_FLOAT_EQ(1.0f, fdimf(2.0f, 1.0f));
945 ASSERT_FLOAT_EQ(0.0f, fdimf(1.0f, 2.0f));
949 ASSERT_DOUBLE_EQ(0.0L, fdiml(1.0L, 1.0L));
950 ASSERT_DOUBLE_EQ(1.0L, fdiml(2.0L, 1.0L));
951 ASSERT_DOUBLE_EQ(0.0L, fdiml(1.0L, 2.0L));
955 auto guard = make_scope_guard([]() {
956 fesetenv(FE_DFL_ENV);
958 fesetround(FE_TOWARDZERO); // round ignores the rounding mode and always rounds away from zero.
959 ASSERT_DOUBLE_EQ(1.0, round(0.5));
960 ASSERT_DOUBLE_EQ(-1.0, round(-0.5));
961 ASSERT_DOUBLE_EQ(0.0, round(0.0));
962 ASSERT_DOUBLE_EQ(-0.0, round(-0.0));
963 ASSERT_TRUE(isnan(round(nan(""))));
964 ASSERT_DOUBLE_EQ(HUGE_VAL, round(HUGE_VAL));
968 auto guard = make_scope_guard([]() {
969 fesetenv(FE_DFL_ENV);
971 fesetround(FE_TOWARDZERO); // roundf ignores the rounding mode and always rounds away from zero.
972 ASSERT_FLOAT_EQ(1.0f, roundf(0.5f));
973 ASSERT_FLOAT_EQ(-1.0f, roundf(-0.5f));
974 ASSERT_FLOAT_EQ(0.0f, roundf(0.0f));
975 ASSERT_FLOAT_EQ(-0.0f, roundf(-0.0f));
976 ASSERT_TRUE(isnanf(roundf(nanf(""))));
977 ASSERT_FLOAT_EQ(HUGE_VALF, roundf(HUGE_VALF));
981 auto guard = make_scope_guard([]() {
982 fesetenv(FE_DFL_ENV);
984 fesetround(FE_TOWARDZERO); // roundl ignores the rounding mode and always rounds away from zero.
985 ASSERT_DOUBLE_EQ(1.0L, roundl(0.5L));
986 ASSERT_DOUBLE_EQ(-1.0L, roundl(-0.5L));
987 ASSERT_DOUBLE_EQ(0.0L, roundl(0.0L));
988 ASSERT_DOUBLE_EQ(-0.0L, roundl(-0.0L));
989 ASSERT_TRUE(isnan(roundl(nanl(""))));
990 ASSERT_DOUBLE_EQ(HUGE_VALL, roundl(HUGE_VALL));
994 auto guard = make_scope_guard([]() {
995 fesetenv(FE_DFL_ENV);
997 fesetround(FE_UPWARD); // trunc ignores the rounding mode and always rounds toward zero.
998 ASSERT_DOUBLE_EQ(1.0, trunc(1.5));
999 ASSERT_DOUBLE_EQ(-1.0, trunc(-1.5));
1000 ASSERT_DOUBLE_EQ(0.0, trunc(0.0));
1001 ASSERT_DOUBLE_EQ(-0.0, trunc(-0.0));
1002 ASSERT_TRUE(isnan(trunc(nan(""))));
1003 ASSERT_DOUBLE_EQ(HUGE_VAL, trunc(HUGE_VAL));
1006 TEST(math, truncf) {
1007 auto guard = make_scope_guard([]() {
1008 fesetenv(FE_DFL_ENV);
1010 fesetround(FE_UPWARD); // truncf ignores the rounding mode and always rounds toward zero.
1011 ASSERT_FLOAT_EQ(1.0f, truncf(1.5f));
1012 ASSERT_FLOAT_EQ(-1.0f, truncf(-1.5f));
1013 ASSERT_FLOAT_EQ(0.0f, truncf(0.0f));
1014 ASSERT_FLOAT_EQ(-0.0f, truncf(-0.0f));
1015 ASSERT_TRUE(isnan(truncf(nanf(""))));
1016 ASSERT_FLOAT_EQ(HUGE_VALF, truncf(HUGE_VALF));
1019 TEST(math, truncl) {
1020 auto guard = make_scope_guard([]() {
1021 fesetenv(FE_DFL_ENV);
1023 fesetround(FE_UPWARD); // truncl ignores the rounding mode and always rounds toward zero.
1024 ASSERT_DOUBLE_EQ(1.0L, truncl(1.5L));
1025 ASSERT_DOUBLE_EQ(-1.0L, truncl(-1.5L));
1026 ASSERT_DOUBLE_EQ(0.0L, truncl(0.0L));
1027 ASSERT_DOUBLE_EQ(-0.0L, truncl(-0.0L));
1028 ASSERT_TRUE(isnan(truncl(nan(""))));
1029 ASSERT_DOUBLE_EQ(HUGE_VALL, truncl(HUGE_VALL));
1032 TEST(math, nextafter) {
1033 ASSERT_DOUBLE_EQ(0.0, nextafter(0.0, 0.0));
1034 ASSERT_DOUBLE_EQ(4.9406564584124654e-324, nextafter(0.0, 1.0));
1035 ASSERT_DOUBLE_EQ(0.0, nextafter(0.0, -1.0));
1038 TEST(math, nextafterf) {
1039 ASSERT_FLOAT_EQ(0.0f, nextafterf(0.0f, 0.0f));
1040 ASSERT_FLOAT_EQ(1.4012985e-45f, nextafterf(0.0f, 1.0f));
1041 ASSERT_FLOAT_EQ(0.0f, nextafterf(0.0f, -1.0f));
1044 TEST(math, nextafterl) {
1045 ASSERT_DOUBLE_EQ(0.0L, nextafterl(0.0L, 0.0L));
1046 // Use a runtime value to accomodate the case when
1047 // sizeof(double) == sizeof(long double)
1048 long double smallest_positive = ldexpl(1.0L, LDBL_MIN_EXP - LDBL_MANT_DIG);
1049 ASSERT_DOUBLE_EQ(smallest_positive, nextafterl(0.0L, 1.0L));
1050 ASSERT_DOUBLE_EQ(0.0L, nextafterl(0.0L, -1.0L));
1053 TEST(math, nexttoward) {
1054 ASSERT_DOUBLE_EQ(0.0, nexttoward(0.0, 0.0L));
1055 ASSERT_DOUBLE_EQ(4.9406564584124654e-324, nexttoward(0.0, 1.0L));
1056 ASSERT_DOUBLE_EQ(0.0, nexttoward(0.0, -1.0L));
1059 TEST(math, nexttowardf) {
1060 ASSERT_FLOAT_EQ(0.0f, nexttowardf(0.0f, 0.0L));
1061 ASSERT_FLOAT_EQ(1.4012985e-45f, nexttowardf(0.0f, 1.0L));
1062 ASSERT_FLOAT_EQ(0.0f, nexttowardf(0.0f, -1.0L));
1065 TEST(math, nexttowardl) {
1066 ASSERT_DOUBLE_EQ(0.0L, nexttowardl(0.0L, 0.0L));
1067 // Use a runtime value to accomodate the case when
1068 // sizeof(double) == sizeof(long double)
1069 long double smallest_positive = ldexpl(1.0L, LDBL_MIN_EXP - LDBL_MANT_DIG);
1070 ASSERT_DOUBLE_EQ(smallest_positive, nexttowardl(0.0L, 1.0L));
1071 ASSERT_DOUBLE_EQ(0.0L, nexttowardl(0.0L, -1.0L));
1074 TEST(math, copysign) {
1075 ASSERT_DOUBLE_EQ(0.0, copysign(0.0, 1.0));
1076 ASSERT_DOUBLE_EQ(-0.0, copysign(0.0, -1.0));
1077 ASSERT_DOUBLE_EQ(2.0, copysign(2.0, 1.0));
1078 ASSERT_DOUBLE_EQ(-2.0, copysign(2.0, -1.0));
1081 TEST(math, copysignf) {
1082 ASSERT_FLOAT_EQ(0.0f, copysignf(0.0f, 1.0f));
1083 ASSERT_FLOAT_EQ(-0.0f, copysignf(0.0f, -1.0f));
1084 ASSERT_FLOAT_EQ(2.0f, copysignf(2.0f, 1.0f));
1085 ASSERT_FLOAT_EQ(-2.0f, copysignf(2.0f, -1.0f));
1088 TEST(math, copysignl) {
1089 ASSERT_DOUBLE_EQ(0.0L, copysignl(0.0L, 1.0L));
1090 ASSERT_DOUBLE_EQ(-0.0L, copysignl(0.0L, -1.0L));
1091 ASSERT_DOUBLE_EQ(2.0L, copysignl(2.0L, 1.0L));
1092 ASSERT_DOUBLE_EQ(-2.0L, copysignl(2.0L, -1.0L));
1095 TEST(math, significand) {
1096 ASSERT_DOUBLE_EQ(0.0, significand(0.0));
1097 ASSERT_DOUBLE_EQ(1.2, significand(1.2));
1098 ASSERT_DOUBLE_EQ(1.5375, significand(12.3));
1101 TEST(math, significandf) {
1102 ASSERT_FLOAT_EQ(0.0f, significandf(0.0f));
1103 ASSERT_FLOAT_EQ(1.2f, significandf(1.2f));
1104 ASSERT_FLOAT_EQ(1.5375f, significandf(12.3f));
1107 TEST(math, significandl) {
1108 ASSERT_DOUBLE_EQ(0.0L, significandl(0.0L));
1109 ASSERT_DOUBLE_EQ(1.2L, significandl(1.2L));
1110 ASSERT_DOUBLE_EQ(1.5375L, significandl(12.3L));
1114 ASSERT_DOUBLE_EQ(12.0, scalb(3.0, 2.0));
1117 TEST(math, scalbf) {
1118 ASSERT_FLOAT_EQ(12.0f, scalbf(3.0f, 2.0f));
1121 TEST(math, scalbln) {
1122 ASSERT_DOUBLE_EQ(12.0, scalbln(3.0, 2L));
1125 TEST(math, scalblnf) {
1126 ASSERT_FLOAT_EQ(12.0f, scalblnf(3.0f, 2L));
1129 TEST(math, scalblnl) {
1130 ASSERT_DOUBLE_EQ(12.0L, scalblnl(3.0L, 2L));
1133 TEST(math, scalbn) {
1134 ASSERT_DOUBLE_EQ(12.0, scalbn(3.0, 2));
1137 TEST(math, scalbnf) {
1138 ASSERT_FLOAT_EQ(12.0f, scalbnf(3.0f, 2));
1141 TEST(math, scalbnl) {
1142 ASSERT_DOUBLE_EQ(12.0L, scalbnl(3.0L, 2));
1146 ASSERT_DOUBLE_EQ(log(24.0), gamma(5.0));
1149 TEST(math, gammaf) {
1150 ASSERT_FLOAT_EQ(logf(24.0f), gammaf(5.0f));
1153 TEST(math, gamma_r) {
1154 #if defined(__BIONIC__)
1156 ASSERT_DOUBLE_EQ(log(24.0), gamma_r(5.0, &sign));
1159 GTEST_LOG_(INFO) << "This test does nothing.\n";
1160 #endif // __BIONIC__
1163 TEST(math, gammaf_r) {
1164 #if defined(__BIONIC__)
1166 ASSERT_FLOAT_EQ(logf(24.0f), gammaf_r(5.0f, &sign));
1169 GTEST_LOG_(INFO) << "This test does nothing.\n";
1170 #endif // __BIONIC__
1173 TEST(math, lgamma) {
1174 ASSERT_DOUBLE_EQ(log(24.0), lgamma(5.0));
1177 TEST(math, lgammaf) {
1178 ASSERT_FLOAT_EQ(logf(24.0f), lgammaf(5.0f));
1181 TEST(math, lgammal) {
1182 ASSERT_DOUBLE_EQ(logl(24.0L), lgammal(5.0L));
1185 TEST(math, lgamma_r) {
1187 ASSERT_DOUBLE_EQ(log(24.0), lgamma_r(5.0, &sign));
1191 TEST(math, lgammaf_r) {
1193 ASSERT_FLOAT_EQ(logf(24.0f), lgammaf_r(5.0f, &sign));
1197 TEST(math, tgamma) {
1198 ASSERT_DOUBLE_EQ(24.0, tgamma(5.0));
1201 TEST(math, tgammaf) {
1202 ASSERT_FLOAT_EQ(24.0f, tgammaf(5.0f));
1205 TEST(math, tgammal) {
1206 ASSERT_DOUBLE_EQ(24.0L, tgammal(5.0L));
1210 ASSERT_DOUBLE_EQ(1.0, j0(0.0));
1211 ASSERT_DOUBLE_EQ(0.76519768655796661, j0(1.0));
1215 ASSERT_FLOAT_EQ(1.0f, j0f(0.0f));
1216 ASSERT_FLOAT_EQ(0.76519769f, j0f(1.0f));
1220 ASSERT_DOUBLE_EQ(0.0, j1(0.0));
1221 ASSERT_DOUBLE_EQ(0.44005058574493355, j1(1.0));
1225 ASSERT_FLOAT_EQ(0.0f, j1f(0.0f));
1226 ASSERT_FLOAT_EQ(0.44005057f, j1f(1.0f));
1230 ASSERT_DOUBLE_EQ(0.0, jn(4, 0.0));
1231 ASSERT_DOUBLE_EQ(0.0024766389641099553, jn(4, 1.0));
1235 ASSERT_FLOAT_EQ(0.0f, jnf(4, 0.0f));
1236 ASSERT_FLOAT_EQ(0.0024766389f, jnf(4, 1.0f));
1240 ASSERT_DOUBLE_EQ(-HUGE_VAL, y0(0.0));
1241 ASSERT_DOUBLE_EQ(0.08825696421567697, y0(1.0));
1245 ASSERT_FLOAT_EQ(-HUGE_VALF, y0f(0.0f));
1246 ASSERT_FLOAT_EQ(0.088256963f, y0f(1.0f));
1250 ASSERT_DOUBLE_EQ(-HUGE_VAL, y1(0.0));
1251 ASSERT_DOUBLE_EQ(-0.78121282130028868, y1(1.0));
1255 ASSERT_FLOAT_EQ(-HUGE_VALF, y1f(0.0f));
1256 ASSERT_FLOAT_EQ(-0.78121281f, y1f(1.0f));
1260 ASSERT_DOUBLE_EQ(-HUGE_VAL, yn(4, 0.0));
1261 ASSERT_DOUBLE_EQ(-33.278423028972114, yn(4, 1.0));
1265 ASSERT_FLOAT_EQ(-HUGE_VALF, ynf(4, 0.0f));
1266 ASSERT_FLOAT_EQ(-33.278423f, ynf(4, 1.0f));
1271 double dr = frexp(1024.0, &exp);
1272 ASSERT_DOUBLE_EQ(1024.0, scalbn(dr, exp));
1275 TEST(math, frexpf) {
1277 float fr = frexpf(1024.0f, &exp);
1278 ASSERT_FLOAT_EQ(1024.0f, scalbnf(fr, exp));
1281 TEST(math, frexpl) {
1283 long double ldr = frexpl(1024.0L, &exp);
1284 ASSERT_DOUBLE_EQ(1024.0L, scalbnl(ldr, exp));
1289 double df = modf(123.75, &di);
1290 ASSERT_DOUBLE_EQ(123.0, di);
1291 ASSERT_DOUBLE_EQ(0.75, df);
1296 float ff = modff(123.75f, &fi);
1297 ASSERT_FLOAT_EQ(123.0f, fi);
1298 ASSERT_FLOAT_EQ(0.75f, ff);
1303 long double ldf = modfl(123.75L, &ldi);
1304 ASSERT_DOUBLE_EQ(123.0L, ldi);
1305 ASSERT_DOUBLE_EQ(0.75L, ldf);
1308 TEST(math, remquo) {
1310 double d = remquo(13.0, 4.0, &q);
1312 ASSERT_DOUBLE_EQ(1.0, d);
1315 TEST(math, remquof) {
1317 float f = remquof(13.0f, 4.0f, &q);
1319 ASSERT_FLOAT_EQ(1.0, f);
1322 TEST(math, remquol) {
1324 long double ld = remquol(13.0L, 4.0L, &q);
1325 ASSERT_DOUBLE_EQ(3L, q);
1326 ASSERT_DOUBLE_EQ(1.0L, ld);
1329 // https://code.google.com/p/android/issues/detail?id=6697
1330 TEST(math, frexpf_public_bug_6697) {
1332 float fr = frexpf(14.1f, &exp);
1333 ASSERT_FLOAT_EQ(14.1f, scalbnf(fr, exp));
1336 TEST(math, exp2_STRICT_ALIGN_OpenBSD_bug) {
1337 // OpenBSD/x86's libm had a bug here, but it was already fixed in FreeBSD:
1338 // http://svnweb.FreeBSD.org/base/head/lib/msun/src/math_private.h?revision=240827&view=markup
1339 ASSERT_DOUBLE_EQ(5.0, exp2(log2(5)));
1340 ASSERT_FLOAT_EQ(5.0f, exp2f(log2f(5)));
1341 ASSERT_DOUBLE_EQ(5.0L, exp2l(log2l(5)));
1344 TEST(math, nextafterl_OpenBSD_bug) {
1345 // OpenBSD/x86's libm had a bug here.
1346 ASSERT_TRUE(nextafter(1.0, 0.0) - 1.0 < 0.0);
1347 ASSERT_TRUE(nextafterf(1.0f, 0.0f) - 1.0f < 0.0f);
1348 ASSERT_TRUE(nextafterl(1.0L, 0.0L) - 1.0L < 0.0L);