1 /* Copyright (C) 1997, 1998, 1999 Free Software Foundation, Inc.
2 This file is part of the GNU C Library.
3 Contributed by Andreas Jaeger <aj@arthur.rhein-neckar.de>, 1997.
5 The GNU C Library is free software; you can redistribute it and/or
6 modify it under the terms of the GNU Library General Public License as
7 published by the Free Software Foundation; either version 2 of the
8 License, or (at your option) any later version.
10 The GNU C Library is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 Library General Public License for more details.
15 You should have received a copy of the GNU Library General Public
16 License along with the GNU C Library; see the file COPYING.LIB. If not,
17 write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
18 Boston, MA 02111-1307, USA. */
20 /* Part of testsuite for libm.
22 This file has to be included by a master file that defines:
25 FUNC(function): converts general function name (like cos) to
26 name with correct suffix (e.g. cosl or cosf)
27 MATHCONST(x): like FUNC but for constants (e.g convert 0.0 to 0.0L)
28 MATHTYPE: floating point type to test
29 TEST_MSG: informal message to be displayed
30 CHOOSE(Clongdouble,Cdouble,Cfloat):
31 chooses one of the parameters as epsilon for testing
33 PRINTF_EXPR Floating point conversion specification to print a variable
34 of type MATHTYPE with printf. PRINTF_EXPR just contains
35 the specifier, not the percent and width arguments,
37 PRINTF_XEXPR Like PRINTF_EXPR, but print in hexadecimal format.
40 /* This program isn't finished yet.
42 acos, acosh, asin, asinh, atan, atan2, atanh,
43 cbrt, ceil, copysign, cos, cosh, erf, erfc, exp, exp10, exp2, expm1,
44 fabs, fdim, floor, fma, fmax, fmin, fmod, fpclassify,
46 ilogb, isfinite, isinf, isnan, isnormal,
47 isless, islessequal, isgreater, isgreaterequal, islessgreater, isunordered,
49 ldexp, lgamma, log, log10, log1p, log2, logb,
50 modf, nearbyint, nextafter,
51 pow, remainder, remquo, rint, lrint, llrint,
52 round, lround, llround,
53 scalb, scalbn, signbit, sin, sincos, sinh, sqrt, tan, tanh, tgamma, trunc,
56 and for the following complex math functions:
57 cabs, cacos, cacosh, carg, casin, casinh, catan, catanh,
58 ccos, ccosh, cexp, clog, cpow, csin, csinh, csqrt, ctan, ctanh.
60 At the moment the following functions aren't tested:
61 conj, cproj, cimag, creal, drem,
65 The routines using random variables are still under construction. I don't
66 like it the way it's working now and will change it.
68 Parameter handling is primitive in the moment:
69 --verbose=[0..4] for different levels of output:
71 1: basic report on failed tests (default)
72 2: full report on failed tests
73 3: full report on failed and passed tests
74 4: additional report on exceptions
75 -v for full output (equals --verbose=4)
76 -s,--silent outputs only the error count (equals --verbose=0)
81 This suite tests some aspects of the correct implementation of
82 mathematical functions in libm. Some simple, specific parameters
83 are tested for correctness but there's no exhaustive
84 testing. Handling of specific inputs (e.g. infinity, not-a-number)
85 is also tested. Correct handling of exceptions is checked
86 against. These implemented tests should check all cases that are
87 specified in ISO C 9X.
89 Exception testing: At the moment only divide-by-zero and invalid
90 exceptions are tested. Overflow/underflow and inexact exceptions
91 aren't checked at the moment.
93 NaN values: There exist signalling and quiet NaNs. This implementation
94 only uses signalling NaN as parameter but does not differenciate
95 between the two kinds of NaNs as result.
97 Inline functions: Inlining functions should give an improvement in
98 speed - but not in precission. The inlined functions return
99 reasonable values for a reasonable range of input values. The
100 result is not necessarily correct for all values and exceptions are
101 not correctly raised in all cases. Problematic input and return
102 values are infinity, not-a-number and minus zero. This suite
103 therefore does not check these specific inputs and the exception
104 handling for inlined mathematical functions - just the "reasonable"
107 Beware: The tests might fail for any of the following reasons:
109 - Functions are wrong
110 - Floating Point Unit not working properly
111 - Compiler has errors
113 With e.g. gcc 2.7.2.2 the test for cexp fails because of a compiler error.
130 /* Possible exceptions */
131 #define NO_EXCEPTION 0x0
132 #define INVALID_EXCEPTION 0x1
133 #define DIVIDE_BY_ZERO_EXCEPTION 0x2
138 /* Various constants (we must supply them precalculated for accuracy). */
139 #define M_PI_6l .52359877559829887308L
140 #define M_E2l 7.389056098930650227230L
141 #define M_E3l 20.08553692318766774093L
143 static int noErrors; /* number of errors */
144 static int noTests; /* number of tests (without testing exceptions) */
145 static int noExcTests; /* number of tests for exception flags */
147 static int verbose = 3;
148 static MATHTYPE minus_zero, plus_zero;
149 static MATHTYPE plus_infty, minus_infty, nan_value;
151 typedef MATHTYPE (*mathfunc) (MATHTYPE);
153 #define BUILD_COMPLEX(real, imag) \
154 ({ __complex__ MATHTYPE __retval; \
155 __real__ __retval = (real); \
156 __imag__ __retval = (imag); \
159 /* Test if Floating-Point stack hasn't changed */
161 fpstack_test (const char *test_name)
164 static int old_stack;
167 asm ("fnstsw" : "=a" (sw));
173 printf ("FP-Stack wrong after test %s (%d, should be %d)\n",
174 test_name, sw, old_stack);
182 /* Get a random value x with min_value < x < max_value
183 and min_value, max_value finite,
184 max_value and min_value shouldn't be too close together */
186 random_value (MATHTYPE min_value, MATHTYPE max_value)
193 x = (max_value - min_value) / RAND_MAX * (MATHTYPE) r + min_value;
195 if ((x <= min_value) || (x >= max_value) || !isfinite (x))
196 x = (max_value - min_value) / 2 + min_value;
198 /* Make sure the RNG has no influence on the exceptions. */
199 feclearexcept (FE_ALL_EXCEPT);
205 /* Get a random value x with x > min_value. */
207 random_greater (MATHTYPE min_value)
209 return random_value (min_value, 1e6); /* CHOOSE (LDBL_MAX, DBL_MAX, FLT_MAX) */
213 /* Get a random value x with x < max_value. */
215 random_less (MATHTYPE max_value)
217 return random_value (-1e6, max_value);
222 output_new_test (const char *test_name)
225 printf ("\nTesting: %s\n", test_name);
230 output_pass_value (void)
233 printf ("Pass: Value Ok.\n");
238 output_fail_value (const char *test_name)
240 if (verbose > 0 && verbose < 3)
241 printf ("Fail: %s\n", test_name);
247 /* Test whether a given exception was raised. */
249 test_single_exception (const char *test_name,
253 const char *flag_name)
256 if (exception & exc_flag)
258 if (fetestexcept (fe_flag))
261 printf ("Pass: Exception \"%s\" set\n", flag_name);
265 if (verbose && verbose < 3)
266 printf ("Fail: %s: Exception \"%s\" not set\n",
267 test_name, flag_name);
269 printf ("Fail: Exception \"%s\" not set\n",
276 if (fetestexcept (fe_flag))
278 if (verbose && verbose < 3)
279 printf ("Fail: %s: Exception \"%s\" set\n",
280 test_name, flag_name);
282 printf ("Fail: Exception \"%s\" set\n",
289 printf ("Pass: Exception \"%s\" not set\n",
297 /* Test whether exception given by EXCEPTION are raised. */
299 test_not_exception (const char *test_name, short int exception)
303 if ((exception & DIVIDE_BY_ZERO_EXCEPTION) == 0)
304 test_single_exception (test_name, exception,
305 DIVIDE_BY_ZERO_EXCEPTION, FE_DIVBYZERO,
309 if ((exception & INVALID_EXCEPTION) == 0)
310 test_single_exception (test_name, exception, INVALID_EXCEPTION, FE_INVALID,
311 "Invalid operation");
313 feclearexcept (FE_ALL_EXCEPT);
317 /* Test whether exceptions given by EXCEPTION are raised. */
319 test_exceptions (const char *test_name, short int exception)
323 test_single_exception (test_name, exception,
324 DIVIDE_BY_ZERO_EXCEPTION, FE_DIVBYZERO,
328 test_single_exception (test_name, exception, INVALID_EXCEPTION, FE_INVALID,
329 "Invalid operation");
331 feclearexcept (FE_ALL_EXCEPT);
335 /* Test if two floating point numbers are equal. */
337 check_equal (MATHTYPE computed, MATHTYPE supplied, MATHTYPE eps, MATHTYPE * diff)
341 /* Both plus Infinity or both minus infinity. */
342 if (isinf (computed) && (isinf (computed) == isinf (supplied)))
345 if (isnan (computed) && isnan (supplied)) /* isnan works for all types */
348 *diff = FUNC(fabs) (computed - supplied);
351 ret_value = (*diff <= eps &&
352 (signbit (computed) == signbit (supplied) || eps != 0.0));
354 /* Make sure the subtraction/comparison
355 have no influence on the exceptions. */
356 feclearexcept (FE_ALL_EXCEPT);
363 output_result_bool (const char *test_name, int result)
368 output_pass_value ();
372 output_fail_value (test_name);
374 printf (" Value: %d\n", result);
378 fpstack_test (test_name);
383 output_isvalue (const char *test_name, int result,
389 output_pass_value ();
393 output_fail_value (test_name);
395 printf (" Value: % .20" PRINTF_EXPR " % .20" PRINTF_XEXPR "\n",
400 fpstack_test (test_name);
405 output_isvalue_ext (const char *test_name, int result,
406 MATHTYPE value, MATHTYPE parameter)
411 output_pass_value ();
415 output_fail_value (test_name);
418 printf (" Value: % .20" PRINTF_EXPR " % .20" PRINTF_XEXPR "\n",
420 printf (" Parameter: % .20" PRINTF_EXPR " % .20" PRINTF_XEXPR "\n",
421 parameter, parameter);
426 fpstack_test (test_name);
431 output_result (const char *test_name, int result,
432 MATHTYPE computed, MATHTYPE expected,
434 int print_values, int print_diff)
439 output_pass_value ();
443 output_fail_value (test_name);
444 if (verbose > 1 && print_values)
446 printf ("Result:\n");
447 printf (" is: % .20" PRINTF_EXPR " % .20" PRINTF_XEXPR "\n",
449 printf (" should be: % .20" PRINTF_EXPR " % .20" PRINTF_XEXPR "\n",
452 printf (" difference: % .20" PRINTF_EXPR " % .20" PRINTF_XEXPR
453 "\n", difference, difference);
458 fpstack_test (test_name);
463 output_result_ext (const char *test_name, int result,
464 MATHTYPE computed, MATHTYPE expected,
467 int print_values, int print_diff)
472 output_pass_value ();
476 output_fail_value (test_name);
477 if (verbose > 1 && print_values)
479 printf ("Result:\n");
480 printf (" is: % .20" PRINTF_EXPR " % .20" PRINTF_XEXPR "\n",
482 printf (" should be: % .20" PRINTF_EXPR " % .20" PRINTF_XEXPR "\n",
485 printf (" difference: % .20" PRINTF_EXPR " % .20" PRINTF_XEXPR
486 "\n", difference, difference);
487 printf ("Parameter: % .20" PRINTF_EXPR " % .20" PRINTF_XEXPR "\n",
488 parameter, parameter);
493 fpstack_test (test_name);
497 /* check that computed and expected values are the same */
499 check (const char *test_name, MATHTYPE computed, MATHTYPE expected)
504 output_new_test (test_name);
505 test_exceptions (test_name, NO_EXCEPTION);
506 result = check_equal (computed, expected, 0, &diff);
507 output_result (test_name, result,
508 computed, expected, diff, PRINT, PRINT);
512 /* check that computed and expected values are the same,
513 outputs the parameter to the function */
515 check_ext (const char *test_name, MATHTYPE computed, MATHTYPE expected,
521 output_new_test (test_name);
522 test_exceptions (test_name, NO_EXCEPTION);
523 result = check_equal (computed, expected, 0, &diff);
524 output_result_ext (test_name, result,
525 computed, expected, diff, parameter, PRINT, PRINT);
529 /* check that computed and expected values are the same and
530 checks also for exception flags */
532 check_exc (const char *test_name, MATHTYPE computed, MATHTYPE expected,
538 output_new_test (test_name);
539 test_exceptions (test_name, exception);
540 result = check_equal (computed, expected, 0, &diff);
541 output_result (test_name, result,
542 computed, expected, diff, PRINT, PRINT);
546 /* check that computed and expected values are close enough */
548 check_eps (const char *test_name, MATHTYPE computed, MATHTYPE expected,
554 output_new_test (test_name);
555 test_exceptions (test_name, NO_EXCEPTION);
556 result = check_equal (computed, expected, epsilon, &diff);
557 output_result (test_name, result,
558 computed, expected, diff, PRINT, PRINT);
562 /* check a boolean condition */
564 check_bool (const char *test_name, int computed)
566 output_new_test (test_name);
567 test_exceptions (test_name, NO_EXCEPTION);
568 output_result_bool (test_name, computed);
572 /* check that computed and expected values are equal (int values) */
574 check_int (const char *test_name, int computed, int expected)
576 int diff = computed - expected;
577 int result = diff == 0;
579 output_new_test (test_name);
580 test_exceptions (test_name, NO_EXCEPTION);
584 output_pass_value ();
588 output_fail_value (test_name);
591 printf ("Result:\n");
592 printf (" is: %d\n", computed);
593 printf (" should be: %d\n", expected);
598 fpstack_test (test_name);
602 /* check that computed and expected values are equal (long int values) */
604 check_long (const char *test_name, long int computed, long int expected)
606 long int diff = computed - expected;
607 int result = diff == 0;
610 output_new_test (test_name);
611 test_exceptions (test_name, NO_EXCEPTION);
615 output_pass_value ();
619 output_fail_value (test_name);
622 printf ("Result:\n");
623 printf (" is: %ld\n", computed);
624 printf (" should be: %ld\n", expected);
629 fpstack_test (test_name);
633 /* check that computed and expected values are equal (long long int values) */
635 check_longlong (const char *test_name, long long int computed,
636 long long int expected)
638 long long int diff = computed - expected;
639 int result = diff == 0;
642 output_new_test (test_name);
643 test_exceptions (test_name, NO_EXCEPTION);
647 output_pass_value ();
651 output_fail_value (test_name);
654 printf ("Result:\n");
655 printf (" is: %lld\n", computed);
656 printf (" should be: %lld\n", expected);
661 fpstack_test (test_name);
665 /* check that computed value is not-a-number */
667 check_isnan (const char *test_name, MATHTYPE computed)
669 output_new_test (test_name);
670 test_exceptions (test_name, NO_EXCEPTION);
671 output_isvalue (test_name, isnan (computed), computed);
675 /* check that computed value is not-a-number and test for exceptions */
677 check_isnan_exc (const char *test_name, MATHTYPE computed,
680 output_new_test (test_name);
681 test_exceptions (test_name, exception);
682 output_isvalue (test_name, isnan (computed), computed);
686 /* check that computed value is not-a-number and test for exceptions */
688 check_isnan_maybe_exc (const char *test_name, MATHTYPE computed,
691 output_new_test (test_name);
692 test_not_exception (test_name, exception);
693 output_isvalue (test_name, isnan (computed), computed);
697 /* check that computed value is not-a-number and supply parameter */
700 check_isnan_ext (const char *test_name, MATHTYPE computed,
703 output_new_test (test_name);
704 test_exceptions (test_name, NO_EXCEPTION);
705 output_isvalue_ext (test_name, isnan (computed), computed, parameter);
709 /* check that computed value is not-a-number, test for exceptions
710 and supply parameter */
712 check_isnan_exc_ext (const char *test_name, MATHTYPE computed,
713 short exception, MATHTYPE parameter)
715 output_new_test (test_name);
716 test_exceptions (test_name, exception);
717 output_isvalue_ext (test_name, isnan (computed), computed, parameter);
721 /* Tests if computed is +Inf */
723 check_isinfp (const char *test_name, MATHTYPE computed)
725 output_new_test (test_name);
726 test_exceptions (test_name, NO_EXCEPTION);
727 output_isvalue (test_name, (isinf (computed) == +1), computed);
731 /* Tests if computed is +Inf and supply parameter */
733 check_isinfp_ext (const char *test_name, MATHTYPE computed,
736 output_new_test (test_name);
737 test_exceptions (test_name, NO_EXCEPTION);
738 output_isvalue_ext (test_name, (isinf (computed) == +1), computed, parameter);
742 /* Tests if computed is +Inf and check exceptions */
744 check_isinfp_exc (const char *test_name, MATHTYPE computed,
747 output_new_test (test_name);
748 test_exceptions (test_name, exception);
749 output_isvalue (test_name, (isinf (computed) == +1), computed);
753 /* Tests if computed is -Inf */
755 check_isinfn (const char *test_name, MATHTYPE computed)
757 output_new_test (test_name);
758 test_exceptions (test_name, NO_EXCEPTION);
759 output_isvalue (test_name, (isinf (computed) == -1), computed);
763 /* Tests if computed is -Inf and supply parameter */
766 check_isinfn_ext (const char *test_name, MATHTYPE computed,
769 output_new_test (test_name);
770 test_exceptions (test_name, NO_EXCEPTION);
771 output_isvalue_ext (test_name, (isinf (computed) == -1), computed, parameter);
775 /* Tests if computed is -Inf and check exceptions */
777 check_isinfn_exc (const char *test_name, MATHTYPE computed,
780 output_new_test (test_name);
781 test_exceptions (test_name, exception);
782 output_isvalue (test_name, (isinf (computed) == -1), computed);
786 /* This is to prevent messages from the SVID libm emulation. */
788 matherr (struct exception *x __attribute__ ((unused)))
794 /****************************************************************************
795 Test for single functions of libm
796 ****************************************************************************/
804 x = random_greater (1);
805 check_isnan_exc ("acos (x) == NaN plus invalid exception for |x| > 1",
810 check_isnan_exc ("acos (x) == NaN plus invalid exception for |x| > 1",
814 check ("acos (0) == pi/2", FUNC(acos) (0), M_PI_2l);
815 check ("acos (-0) == pi/2", FUNC(acos) (minus_zero), M_PI_2l);
817 check ("acos (1) == 0", FUNC(acos) (1), 0);
818 check ("acos (-1) == pi", FUNC(acos) (-1), M_PIl);
820 check_eps ("acos (0.5) == pi/3", FUNC(acos) (0.5), M_PI_6l * 2.0,
821 CHOOSE (1e-18, 0, 0));
822 check_eps ("acos (-0.5) == 2*pi/3", FUNC(acos) (-0.5), M_PI_6l * 4.0,
823 CHOOSE (1e-17, 0, 0));
825 check_eps ("acos (0.7) == 0.795398830...", FUNC(acos) (0.7),
826 0.7953988301841435554L, CHOOSE (7e-17L, 0, 0));
836 check_isinfp ("acosh(+inf) == +inf", FUNC(acosh) (plus_infty));
839 check_isnan_exc ("acosh(x) == NaN plus invalid exception if x < 1",
840 FUNC(acosh) (x), INVALID_EXCEPTION);
843 check ("acosh(1) == 0", FUNC(acosh) (1), 0);
844 check_eps ("acosh(7) == 2.633915793...", FUNC(acosh) (7),
845 2.6339157938496334172L, CHOOSE (3e-19, 0, 0));
855 x = random_greater (1);
856 check_isnan_exc ("asin x == NaN plus invalid exception for |x| > 1",
861 check_isnan_exc ("asin x == NaN plus invalid exception for |x| > 1",
866 check ("asin (0) == 0", FUNC(asin) (0), 0);
867 check ("asin (-0) == -0", FUNC(asin) (minus_zero), minus_zero);
868 check_eps ("asin (0.5) == pi/6", FUNC(asin) (0.5), M_PI_6l,
869 CHOOSE (3.5e-18, 0, 2e-7));
870 check_eps ("asin (-0.5) == -pi/6", FUNC(asin) (-0.5), -M_PI_6l,
871 CHOOSE (3.5e-18, 0, 2e-7));
872 check ("asin (1.0) == pi/2", FUNC(asin) (1.0), M_PI_2l);
873 check ("asin (-1.0) == -pi/2", FUNC(asin) (-1.0), -M_PI_2l);
874 check_eps ("asin (0.7) == 0.775397496...", FUNC(asin) (0.7),
875 0.7753974966107530637L, CHOOSE (7e-17L, 2e-16, 2e-7));
882 check ("asinh(+0) == +0", FUNC(asinh) (0), 0);
884 check ("asinh(-0) == -0", FUNC(asinh) (minus_zero), minus_zero);
885 check_isinfp ("asinh(+inf) == +inf", FUNC(asinh) (plus_infty));
886 check_isinfn ("asinh(-inf) == -inf", FUNC(asinh) (minus_infty));
888 check_eps ("asinh(0.7) == 0.652666566...", FUNC(asinh) (0.7),
889 0.652666566082355786L, CHOOSE (4e-17L, 0, 6e-8));
896 check ("atan (0) == 0", FUNC(atan) (0), 0);
897 check ("atan (-0) == -0", FUNC(atan) (minus_zero), minus_zero);
899 check ("atan (+inf) == pi/2", FUNC(atan) (plus_infty), M_PI_2l);
900 check ("atan (-inf) == -pi/2", FUNC(atan) (minus_infty), -M_PI_2l);
902 check_eps ("atan (1) == pi/4", FUNC(atan) (1), M_PI_4l,
903 CHOOSE (1e-18, 0, 0));
904 check_eps ("atan (-1) == -pi/4", FUNC(atan) (1), M_PI_4l,
905 CHOOSE (1e-18, 0, 0));
907 check_eps ("atan (0.7) == 0.610725964...", FUNC(atan) (0.7),
908 0.6107259643892086165L, CHOOSE (3e-17L, 0, 0));
917 x = random_greater (0);
918 check ("atan2 (0,x) == 0 for x > 0",
919 FUNC(atan2) (0, x), 0);
920 x = random_greater (0);
921 check ("atan2 (-0,x) == -0 for x > 0",
922 FUNC(atan2) (minus_zero, x), minus_zero);
924 check ("atan2 (+0,+0) == +0", FUNC(atan2) (0, 0), 0);
925 check ("atan2 (-0,+0) == -0", FUNC(atan2) (minus_zero, 0), minus_zero);
927 x = -random_greater (0);
928 check ("atan2 (+0,x) == +pi for x < 0", FUNC(atan2) (0, x), M_PIl);
930 x = -random_greater (0);
931 check ("atan2 (-0,x) == -pi for x < 0", FUNC(atan2) (minus_zero, x), -M_PIl);
933 check ("atan2 (+0,-0) == +pi", FUNC(atan2) (0, minus_zero), M_PIl);
934 check ("atan2 (-0,-0) == -pi", FUNC(atan2) (minus_zero, minus_zero), -M_PIl);
936 x = random_greater (0);
937 check ("atan2 (y,+0) == pi/2 for y > 0", FUNC(atan2) (x, 0), M_PI_2l);
939 x = random_greater (0);
940 check ("atan2 (y,-0) == pi/2 for y > 0", FUNC(atan2) (x, minus_zero),
944 check ("atan2 (y,+0) == -pi/2 for y < 0", FUNC(atan2) (x, 0), -M_PI_2l);
947 check ("atan2 (y,-0) == -pi/2 for y < 0", FUNC(atan2) (x, minus_zero),
950 x = random_greater (0);
951 check ("atan2 (y,inf) == +0 for finite y > 0",
952 FUNC(atan2) (x, plus_infty), 0);
954 x = -random_greater (0);
955 check ("atan2 (y,inf) == -0 for finite y < 0",
956 FUNC(atan2) (x, plus_infty), minus_zero);
958 x = random_value (-1e4, 1e4);
959 check ("atan2(+inf, x) == pi/2 for finite x",
960 FUNC(atan2) (plus_infty, x), M_PI_2l);
962 x = random_value (-1e4, 1e4);
963 check ("atan2(-inf, x) == -pi/2 for finite x",
964 FUNC(atan2) (minus_infty, x), -M_PI_2l);
966 x = random_greater (0);
967 check ("atan2 (y,-inf) == +pi for finite y > 0",
968 FUNC(atan2) (x, minus_infty), M_PIl);
970 x = -random_greater (0);
971 check ("atan2 (y,-inf) == -pi for finite y < 0",
972 FUNC(atan2) (x, minus_infty), -M_PIl);
974 check ("atan2 (+inf,+inf) == +pi/4",
975 FUNC(atan2) (plus_infty, plus_infty), M_PI_4l);
977 check ("atan2 (-inf,+inf) == -pi/4",
978 FUNC(atan2) (minus_infty, plus_infty), -M_PI_4l);
980 check ("atan2 (+inf,-inf) == +3*pi/4",
981 FUNC(atan2) (plus_infty, minus_infty), 3 * M_PI_4l);
983 check ("atan2 (-inf,-inf) == -3*pi/4",
984 FUNC(atan2) (minus_infty, minus_infty), -3 * M_PI_4l);
986 /* FIXME: Add some specific tests */
987 check_eps ("atan2 (0.7,1) == 0.61072...", FUNC(atan2) (0.7, 1),
988 0.6107259643892086165L, CHOOSE (3e-17L, 0, 0));
989 check_eps ("atan2 (0.4,0.0003) == 1.57004...", FUNC(atan2) (0.4, 0.0003),
990 1.5700463269355215718L, CHOOSE (2e-19L, 0, 1.2e-7));
1001 check ("atanh(+0) == +0", FUNC(atanh) (0), 0);
1003 check ("atanh(-0) == -0", FUNC(atanh) (minus_zero), minus_zero);
1005 check_isinfp_exc ("atanh(+1) == +inf plus divide-by-zero exception",
1006 FUNC(atanh) (1), DIVIDE_BY_ZERO_EXCEPTION);
1007 check_isinfn_exc ("atanh(-1) == -inf plus divide-by-zero exception",
1008 FUNC(atanh) (-1), DIVIDE_BY_ZERO_EXCEPTION);
1010 x = random_greater (1.0);
1011 check_isnan_exc_ext ("atanh (x) == NaN plus invalid exception if |x| > 1",
1012 FUNC(atanh) (x), INVALID_EXCEPTION, x);
1014 x = random_less (1.0);
1015 check_isnan_exc_ext ("atanh (x) == NaN plus invalid exception if |x| > 1",
1016 FUNC(atanh) (x), INVALID_EXCEPTION, x);
1019 check_eps ("atanh(0.7) == 0.867300527...", FUNC(atanh) (0.7),
1020 0.8673005276940531944L, CHOOSE (9e-17L, 2e-16, 0));
1027 check ("cbrt (+0) == +0", FUNC(cbrt) (0.0), 0.0);
1028 check ("cbrt (-0) == -0", FUNC(cbrt) (minus_zero), minus_zero);
1031 check_isinfp ("cbrt (+inf) == +inf", FUNC(cbrt) (plus_infty));
1032 check_isinfn ("cbrt (-inf) == -inf", FUNC(cbrt) (minus_infty));
1033 check_isnan ("cbrt (NaN) == NaN", FUNC(cbrt) (nan_value));
1035 check_eps ("cbrt (-0.001) == -0.1", FUNC(cbrt) (-0.001), -0.1,
1036 CHOOSE (5e-18L, 0, 0));
1037 check_eps ("cbrt (8) == 2", FUNC(cbrt) (8), 2, CHOOSE (5e-17L, 0, 0));
1038 check_eps ("cbrt (-27) == -3", FUNC(cbrt) (-27.0), -3.0,
1039 CHOOSE (3e-16L, 5e-16, 0));
1040 check_eps ("cbrt (0.970299) == 0.99", FUNC(cbrt) (0.970299), 0.99,
1041 CHOOSE (2e-17L, 2e-16, 0));
1042 check_eps ("cbrt (0.7) == .8879040017...", FUNC(cbrt) (0.7),
1043 0.8879040017426007084L, CHOOSE (2e-17L, 6e-16, 0));
1050 check ("ceil (+0) == +0", FUNC(ceil) (0.0), 0.0);
1051 check ("ceil (-0) == -0", FUNC(ceil) (minus_zero), minus_zero);
1052 check_isinfp ("ceil (+inf) == +inf", FUNC(ceil) (plus_infty));
1053 check_isinfn ("ceil (-inf) == -inf", FUNC(ceil) (minus_infty));
1055 check ("ceil (pi) == 4", FUNC(ceil) (M_PIl), 4.0);
1056 check ("ceil (-pi) == -3", FUNC(ceil) (-M_PIl), -3.0);
1063 check ("cos (+0) == 1", FUNC(cos) (0), 1);
1064 check ("cos (-0) == 1", FUNC(cos) (minus_zero), 1);
1065 check_isnan_exc ("cos (+inf) == NaN plus invalid exception",
1066 FUNC(cos) (plus_infty),
1068 check_isnan_exc ("cos (-inf) == NaN plus invalid exception",
1069 FUNC(cos) (minus_infty),
1072 check_eps ("cos (pi/3) == 0.5", FUNC(cos) (M_PI_6l * 2.0),
1073 0.5, CHOOSE (4e-18L, 1e-15L, 1e-7L));
1074 check_eps ("cos (2*pi/3) == -0.5", FUNC(cos) (M_PI_6l * 4.0),
1075 -0.5, CHOOSE (4e-18L, 1e-15L, 1e-7L));
1076 check_eps ("cos (pi/2) == 0", FUNC(cos) (M_PI_2l),
1077 0, CHOOSE (1e-19L, 1e-16L, 1e-7L));
1079 check_eps ("cos (0.7) == 0.7648421872...", FUNC(cos) (0.7),
1080 0.7648421872844884262L, CHOOSE (3e-17, 2e-16, 6e-8));
1087 check ("cosh (+0) == 1", FUNC(cosh) (0), 1);
1088 check ("cosh (-0) == 1", FUNC(cosh) (minus_zero), 1);
1091 check_isinfp ("cosh (+inf) == +inf", FUNC(cosh) (plus_infty));
1092 check_isinfp ("cosh (-inf) == +inf", FUNC(cosh) (minus_infty));
1095 check_eps ("cosh (0.7) == 1.2551690056...", FUNC(cosh) (0.7),
1096 1.255169005630943018L, CHOOSE (4e-17L, 2.3e-16, 0));
1105 if (errno == ENOSYS)
1106 /* Function not implemented. */
1109 check ("erf (+0) == +0", FUNC(erf) (0), 0);
1110 check ("erf (-0) == -0", FUNC(erf) (minus_zero), minus_zero);
1111 check ("erf (+inf) == +1", FUNC(erf) (plus_infty), 1);
1112 check ("erf (-inf) == -1", FUNC(erf) (minus_infty), -1);
1114 check_eps ("erf (0.7) == 0.6778011938...", FUNC(erf) (0.7),
1115 0.67780119383741847297L, CHOOSE (0, 2e-16, 0));
1124 if (errno == ENOSYS)
1125 /* Function not implemented. */
1128 check ("erfc (+inf) == 0", FUNC(erfc) (plus_infty), 0.0);
1129 check ("erfc (-inf) == 2", FUNC(erfc) (minus_infty), 2.0);
1130 check ("erfc (+0) == 1", FUNC(erfc) (0.0), 1.0);
1131 check ("erfc (-0) == 1", FUNC(erfc) (minus_zero), 1.0);
1133 check_eps ("erfc (0.7) == 0.3221988061...", FUNC(erfc) (0.7),
1134 0.32219880616258152702L, CHOOSE (0, 6e-17, 0));
1141 check ("exp (+0) == 1", FUNC(exp) (0), 1);
1142 check ("exp (-0) == 1", FUNC(exp) (minus_zero), 1);
1145 check_isinfp ("exp (+inf) == +inf", FUNC(exp) (plus_infty));
1146 check ("exp (-inf) == 0", FUNC(exp) (minus_infty), 0);
1148 check_eps ("exp (1) == e", FUNC(exp) (1), M_El, CHOOSE (4e-18L, 0, 0));
1150 check_eps ("exp (2) == e^2", FUNC(exp) (2), M_E2l,
1151 CHOOSE (1e-18, 8.9e-16, 0));
1152 check_eps ("exp (3) == e^3", FUNC(exp) (3), M_E3l,
1153 CHOOSE (1.5e-17, 3.6e-15, 0));
1154 check_eps ("exp (0.7) == 2.0137527074...", FUNC(exp) (0.7),
1155 2.0137527074704765216L, CHOOSE (9e-17L, 4.5e-16, 0));
1164 if (errno == ENOSYS)
1165 /* Function not implemented. */
1168 check ("exp10 (+0) == 1", FUNC(exp10) (0), 1);
1169 check ("exp10 (-0) == 1", FUNC(exp10) (minus_zero), 1);
1171 check_isinfp ("exp10 (+inf) == +inf", FUNC(exp10) (plus_infty));
1172 check ("exp10 (-inf) == 0", FUNC(exp10) (minus_infty), 0);
1173 check_eps ("exp10 (3) == 1000", FUNC(exp10) (3), 1000,
1174 CHOOSE (5e-16, 7e-13, 2e-4));
1175 check_eps ("exp10 (-1) == 0.1", FUNC(exp10) (-1), 0.1,
1176 CHOOSE (6e-18, 3e-17, 8e-09));
1177 check_isinfp ("exp10 (1e6) == +inf", FUNC(exp10) (1e6));
1178 check ("exp10 (-1e6) == 0", FUNC(exp10) (-1e6), 0);
1179 check_eps ("exp10 (0.7) == 5.0118723...", FUNC(exp10) (0.7),
1180 5.0118723362727228500L, CHOOSE (6e-16, 9e-16, 5e-7));
1189 if (errno == ENOSYS)
1190 /* Function not implemented. */
1193 check ("exp2 (+0) == 1", FUNC(exp2) (0), 1);
1194 check ("exp2 (-0) == 1", FUNC(exp2) (minus_zero), 1);
1196 check_isinfp ("exp2 (+inf) == +inf", FUNC(exp2) (plus_infty));
1197 check ("exp2 (-inf) == 0", FUNC(exp2) (minus_infty), 0);
1198 check ("exp2 (10) == 1024", FUNC(exp2) (10), 1024);
1199 check ("exp2 (-1) == 0.5", FUNC(exp2) (-1), 0.5);
1200 check_isinfp ("exp2 (1e6) == +inf", FUNC(exp2) (1e6));
1201 check ("exp2 (-1e6) == 0", FUNC(exp2) (-1e6), 0);
1202 check_eps ("exp2 (0.7) == 1.6245047927...", FUNC(exp2) (0.7),
1203 1.6245047927124710452L, CHOOSE (6e-17L, 0, 1.2e-7));
1210 check ("expm1 (+0) == 0", FUNC(expm1) (0), 0);
1212 check ("expm1 (-0) == -0", FUNC(expm1) (minus_zero), minus_zero);
1214 check_isinfp ("expm1 (+inf) == +inf", FUNC(expm1) (plus_infty));
1215 check ("expm1 (-inf) == -1", FUNC(expm1) (minus_infty), -1);
1218 check_eps ("expm1 (1) == e-1", FUNC(expm1) (1), M_El - 1.0,
1219 CHOOSE (4e-18L, 0, 2e-7));
1221 check_eps ("expm1 (0.7) == 1.01375...", FUNC(expm1) (0.7),
1222 1.0137527074704765216L, CHOOSE (9e-17L, 0, 0));
1227 check_frexp (const char *test_name, MATHTYPE computed, MATHTYPE expected,
1228 int comp_int, int exp_int)
1233 result = (check_equal (computed, expected, 0, &diff)
1234 && (comp_int == exp_int));
1239 printf ("Pass: %s\n", test_name);
1244 printf ("Fail: %s\n", test_name);
1247 printf ("Result:\n");
1248 printf (" is: %.20" PRINTF_EXPR " *2^%d %.20"
1249 PRINTF_XEXPR "*2^%d\n",
1250 computed, comp_int, computed, comp_int);
1251 printf (" should be: %.20" PRINTF_EXPR " *2^%d %.20"
1252 PRINTF_XEXPR "*2^%d\n",
1253 expected, exp_int, expected, exp_int);
1254 printf (" difference: %.20" PRINTF_EXPR " %.20" PRINTF_XEXPR "\n",
1259 fpstack_test (test_name);
1260 output_result (test_name, result,
1261 computed, expected, diff, PRINT, PRINT);
1271 result = FUNC(frexp) (plus_infty, &x_int);
1272 check_isinfp ("frexp (+inf, expr) == +inf", result);
1274 result = FUNC(frexp) (minus_infty, &x_int);
1275 check_isinfn ("frexp (-inf, expr) == -inf", result);
1277 result = FUNC(frexp) (nan_value, &x_int);
1278 check_isnan ("frexp (Nan, expr) == NaN", result);
1280 result = FUNC(frexp) (0, &x_int);
1281 check_frexp ("frexp: +0 == 0 * 2^0", result, 0, x_int, 0);
1283 result = FUNC(frexp) (minus_zero, &x_int);
1284 check_frexp ("frexp: -0 == -0 * 2^0", result, minus_zero, x_int, 0);
1286 result = FUNC(frexp) (12.8L, &x_int);
1287 check_frexp ("frexp: 12.8 == 0.8 * 2^4", result, 0.8L, x_int, 4);
1289 result = FUNC(frexp) (-27.34L, &x_int);
1290 check_frexp ("frexp: -27.34 == -0.854375 * 2^5",
1291 result, -0.854375L, x_int, 5);
1296 fpclassify_test (void)
1300 /* fpclassify is a macro, don't give it constants as parameter */
1301 check_bool ("fpclassify (NaN) == FP_NAN", fpclassify (nan_value) == FP_NAN);
1302 check_bool ("fpclassify (+inf) == FP_INFINITE",
1303 fpclassify (plus_infty) == FP_INFINITE);
1304 check_bool ("fpclassify (-inf) == FP_INFINITE",
1305 fpclassify (minus_infty) == FP_INFINITE);
1306 check_bool ("fpclassify (+0) == FP_ZERO",
1307 fpclassify (plus_zero) == FP_ZERO);
1308 check_bool ("fpclassify (-0) == FP_ZERO",
1309 fpclassify (minus_zero) == FP_ZERO);
1312 check_bool ("fpclassify (1000) == FP_NORMAL",
1313 fpclassify (x) == FP_NORMAL);
1318 isfinite_test (void)
1320 check_bool ("isfinite (0) != 0", isfinite (0));
1321 check_bool ("isfinite (-0) != 0", isfinite (minus_zero));
1322 check_bool ("isfinite (10) != 0", isfinite (10));
1323 check_bool ("isfinite (+inf) == 0", isfinite (plus_infty) == 0);
1324 check_bool ("isfinite (-inf) == 0", isfinite (minus_infty) == 0);
1325 check_bool ("isfinite (NaN) == 0", isfinite (nan_value) == 0);
1330 isnormal_test (void)
1332 check_bool ("isnormal (0) == 0", isnormal (0) == 0);
1333 check_bool ("isnormal (-0) == 0", isnormal (minus_zero) == 0);
1334 check_bool ("isnormal (10) != 0", isnormal (10));
1335 check_bool ("isnormal (+inf) == 0", isnormal (plus_infty) == 0);
1336 check_bool ("isnormal (-inf) == 0", isnormal (minus_infty) == 0);
1337 check_bool ("isnormal (NaN) == 0", isnormal (nan_value) == 0);
1346 check_bool ("signbit (+0) == 0", signbit (0) == 0);
1347 check_bool ("signbit (-0) != 0", signbit (minus_zero));
1348 check_bool ("signbit (+inf) == 0", signbit (plus_infty) == 0);
1349 check_bool ("signbit (-inf) != 0", signbit (minus_infty));
1351 x = random_less (0);
1352 check_bool ("signbit (x) != 0 for x < 0", signbit (x));
1354 x = random_greater (0);
1355 check_bool ("signbit (x) == 0 for x > 0", signbit (x) == 0);
1364 if (errno == ENOSYS)
1365 /* Function not implemented. */
1367 feclearexcept (FE_ALL_EXCEPT);
1370 check_isinfp ("gamma (+inf) == +inf", FUNC(gamma) (plus_infty));
1371 check_isinfp_exc ("gamma (0) == +inf plus divide by zero exception",
1372 FUNC(gamma) (0), DIVIDE_BY_ZERO_EXCEPTION);
1374 check_isinfp_exc ("gamma (x) == +inf plus divide by zero exception for integer x <= 0",
1375 FUNC(gamma) (-3), DIVIDE_BY_ZERO_EXCEPTION);
1376 check_isnan_exc ("gamma (-inf) == NaN plus invalid exception",
1377 FUNC(gamma) (minus_infty), INVALID_EXCEPTION);
1380 check ("gamma (1) == 0", FUNC(gamma) (1), 0);
1381 check_int ("gamma (1) sets signgam to 1", signgam, 1);
1384 check ("gamma (3) == M_LN2", FUNC(gamma) (3), M_LN2l);
1385 check_int ("gamma (3) sets signgam to 1", signgam, 1);
1388 check_eps ("gamma (0.5) == log(sqrt(pi))", FUNC(gamma) (0.5),
1389 FUNC(log) (FUNC(sqrt) (M_PIl)), CHOOSE (0, 1e-15, 1e-7));
1390 check_int ("gamma (0.5) sets signgam to 1", signgam, 1);
1393 check_eps ("gamma (-0.5) == log(2*sqrt(pi))", FUNC(gamma) (-0.5),
1394 FUNC(log) (2*FUNC(sqrt) (M_PIl)), CHOOSE (0, 1e-15, 0));
1396 check_int ("gamma (-0.5) sets signgam to -1", signgam, -1);
1405 if (errno == ENOSYS)
1406 /* Function not implemented. */
1408 feclearexcept (FE_ALL_EXCEPT);
1410 check_isinfp ("tgamma (+inf) == +inf", FUNC(tgamma) (plus_infty));
1411 check_isnan_exc ("tgamma (0) == NaN plus invalid exception",
1412 FUNC(tgamma) (0), INVALID_EXCEPTION);
1414 check_isnan_exc_ext ("tgamma (x) == NaN plus invalid exception for integer x <= 0",
1415 FUNC(tgamma) (-2), INVALID_EXCEPTION, -2);
1416 check_isnan_exc ("tgamma (-inf) == NaN plus invalid exception",
1417 FUNC(tgamma) (minus_infty), INVALID_EXCEPTION);
1419 check_eps ("tgamma (0.5) == sqrt(pi)", FUNC(tgamma) (0.5),
1420 FUNC(sqrt) (M_PIl), CHOOSE (0, 5e-16, 2e-7));
1421 check_eps ("tgamma (-0.5) == -2*sqrt(pi)", FUNC(tgamma) (-0.5),
1422 -2*FUNC(sqrt) (M_PIl), CHOOSE (0, 5e-16, 3e-7));
1424 check ("tgamma (1) == 1", FUNC(tgamma) (1), 1);
1425 check_eps ("tgamma (4) == 6", FUNC(tgamma) (4), 6, CHOOSE (0, 8.9e-16, 0));
1427 check_eps ("tgamma (0.7) == 1.29805...", FUNC(tgamma) (0.7),
1428 1.29805533264755778568L, CHOOSE (0, 3e-16, 2e-7));
1429 check_eps ("tgamma (1.2) == 0.91816...", FUNC(tgamma) (1.2),
1430 0.91816874239976061064L, CHOOSE (0, 1.2e-16, 0));
1439 if (errno == ENOSYS)
1440 /* Function not implemented. */
1442 feclearexcept (FE_ALL_EXCEPT);
1444 check_isinfp ("lgamma (+inf) == +inf", FUNC(lgamma) (plus_infty));
1445 check_isinfp_exc ("lgamma (0) == +inf plus divide by zero exception",
1446 FUNC(lgamma) (0), DIVIDE_BY_ZERO_EXCEPTION);
1448 check_isinfp_exc ("lgamma (x) == +inf plus divide by zero exception for integer x <= 0",
1449 FUNC(lgamma) (-3), DIVIDE_BY_ZERO_EXCEPTION);
1450 check_isnan_exc ("lgamma (-inf) == NaN plus invalid exception",
1451 FUNC(lgamma) (minus_infty), INVALID_EXCEPTION);
1454 check ("lgamma (1) == 0", FUNC(lgamma) (1), 0);
1455 check_int ("lgamma (0) sets signgam to 1", signgam, 1);
1458 check ("lgamma (3) == M_LN2", FUNC(lgamma) (3), M_LN2l);
1459 check_int ("lgamma (3) sets signgam to 1", signgam, 1);
1462 check_eps ("lgamma (0.5) == log(sqrt(pi))", FUNC(lgamma) (0.5),
1463 FUNC(log) (FUNC(sqrt) (M_PIl)), CHOOSE (0, 1e-15, 1e-7));
1464 check_int ("lgamma (0.5) sets signgam to 1", signgam, 1);
1467 check_eps ("lgamma (-0.5) == log(2*sqrt(pi))", FUNC(lgamma) (-0.5),
1468 FUNC(log) (2*FUNC(sqrt) (M_PIl)), CHOOSE (0, 1e-15, 0));
1470 check_int ("lgamma (-0.5) sets signgam to -1", signgam, -1);
1473 check_eps ("lgamma (0.7) == 0.26086...", FUNC(lgamma) (0.7),
1474 0.26086724653166651439L, CHOOSE (0, 6e-17, 3e-8));
1475 check_int ("lgamma (0.7) sets signgam to 1", signgam, 1);
1478 check_eps ("lgamma (1.2) == -0.08537...", FUNC(lgamma) (1.2),
1479 -0.853740900033158497197e-1L, CHOOSE (0, 2e-17, 2e-8));
1480 check_int ("lgamma (1.2) sets signgam to 1", signgam, 1);
1489 check_int ("ilogb (1) == 0", FUNC(ilogb) (1), 0);
1490 check_int ("ilogb (e) == 1", FUNC(ilogb) (M_El), 1);
1491 check_int ("ilogb (1024) == 10", FUNC(ilogb) (1024), 10);
1492 check_int ("ilogb (-2000) == 10", FUNC(ilogb) (-2000), 10);
1494 /* XXX We have a problem here: the standard does not tell us whether
1495 exceptions are allowed/required. ignore them for now. */
1496 i = FUNC(ilogb) (0.0);
1497 feclearexcept (FE_ALL_EXCEPT);
1498 check_int ("ilogb (0) == FP_ILOGB0", i, FP_ILOGB0);
1499 i = FUNC(ilogb) (nan_value);
1500 feclearexcept (FE_ALL_EXCEPT);
1501 check_int ("ilogb (NaN) == FP_ILOGBNAN", i, FP_ILOGBNAN);
1510 check ("ldexp (0, 0) == 0", FUNC(ldexp) (0, 0), 0);
1512 check_isinfp ("ldexp (+inf, 1) == +inf", FUNC(ldexp) (plus_infty, 1));
1513 check_isinfn ("ldexp (-inf, 1) == -inf", FUNC(ldexp) (minus_infty, 1));
1514 check_isnan ("ldexp (NaN, 1) == NaN", FUNC(ldexp) (nan_value, 1));
1516 check ("ldexp (0.8, 4) == 12.8", FUNC(ldexp) (0.8L, 4), 12.8L);
1517 check ("ldexp (-0.854375, 5) == -27.34", FUNC(ldexp) (-0.854375L, 5), -27.34L);
1519 x = random_greater (0.0);
1520 check_ext ("ldexp (x, 0) == x", FUNC(ldexp) (x, 0L), x, x);
1527 check_isinfn_exc ("log (+0) == -inf plus divide-by-zero exception",
1528 FUNC(log) (0), DIVIDE_BY_ZERO_EXCEPTION);
1529 check_isinfn_exc ("log (-0) == -inf plus divide-by-zero exception",
1530 FUNC(log) (minus_zero), DIVIDE_BY_ZERO_EXCEPTION);
1532 check ("log (1) == 0", FUNC(log) (1), 0);
1534 check_isnan_exc ("log (x) == NaN plus invalid exception if x < 0",
1535 FUNC(log) (-1), INVALID_EXCEPTION);
1536 check_isinfp ("log (+inf) == +inf", FUNC(log) (plus_infty));
1538 check_eps ("log (e) == 1", FUNC(log) (M_El), 1, CHOOSE (1e-18L, 0, 9e-8L));
1539 check_eps ("log (1/e) == -1", FUNC(log) (1.0 / M_El), -1,
1540 CHOOSE (2e-18L, 0, 0));
1541 check_eps ("log (2) == M_LN2", FUNC(log) (2), M_LN2l,
1542 CHOOSE (6e-20L, 0, 0));
1543 check_eps ("log (10) == M_LN10", FUNC(log) (10), M_LN10l,
1544 CHOOSE (1e-18L, 0, 0));
1545 check_eps ("log (0.7) == -0.3566749439...", FUNC(log) (0.7),
1546 -0.35667494393873237891L, CHOOSE (7e-17L, 6e-17, 3e-8));
1553 check_isinfn_exc ("log10 (+0) == -inf plus divide-by-zero exception",
1554 FUNC(log10) (0), DIVIDE_BY_ZERO_EXCEPTION);
1555 check_isinfn_exc ("log10 (-0) == -inf plus divide-by-zero exception",
1556 FUNC(log10) (minus_zero), DIVIDE_BY_ZERO_EXCEPTION);
1558 check ("log10 (1) == +0", FUNC(log10) (1), 0);
1560 check_isnan_exc ("log10 (x) == NaN plus invalid exception if x < 0",
1561 FUNC(log10) (-1), INVALID_EXCEPTION);
1563 check_isinfp ("log10 (+inf) == +inf", FUNC(log10) (plus_infty));
1565 check_eps ("log10 (0.1) == -1", FUNC(log10) (0.1L), -1,
1566 CHOOSE (1e-18L, 0, 0));
1567 check_eps ("log10 (10) == 1", FUNC(log10) (10.0), 1,
1568 CHOOSE (1e-18L, 0, 0));
1569 check_eps ("log10 (100) == 2", FUNC(log10) (100.0), 2,
1570 CHOOSE (1e-18L, 0, 0));
1571 check ("log10 (10000) == 4", FUNC(log10) (10000.0), 4);
1572 check_eps ("log10 (e) == M_LOG10E", FUNC(log10) (M_El), M_LOG10El,
1573 CHOOSE (1e-18, 0, 9e-8));
1574 check_eps ("log10 (0.7) == -0.1549019599...", FUNC(log10) (0.7),
1575 -0.15490195998574316929L, CHOOSE (3e-17L, 3e-17, 2e-8));
1582 check ("log1p (+0) == +0", FUNC(log1p) (0), 0);
1583 check ("log1p (-0) == -0", FUNC(log1p) (minus_zero), minus_zero);
1585 check_isinfn_exc ("log1p (-1) == -inf plus divide-by-zero exception",
1586 FUNC(log1p) (-1), DIVIDE_BY_ZERO_EXCEPTION);
1587 check_isnan_exc ("log1p (x) == NaN plus invalid exception if x < -1",
1588 FUNC(log1p) (-2), INVALID_EXCEPTION);
1590 check_isinfp ("log1p (+inf) == +inf", FUNC(log1p) (plus_infty));
1592 check_eps ("log1p (e-1) == 1", FUNC(log1p) (M_El - 1.0), 1,
1593 CHOOSE (1e-18L, 0, 6e-8));
1595 check_eps ("log1p (-0.3) == -0.35667...", FUNC(log1p) (-0.3),
1596 -0.35667494393873237891L, CHOOSE (2e-17L, 6e-17, 3e-8));
1603 check_isinfn_exc ("log2 (+0) == -inf plus divide-by-zero exception",
1604 FUNC(log2) (0), DIVIDE_BY_ZERO_EXCEPTION);
1605 check_isinfn_exc ("log2 (-0) == -inf plus divide-by-zero exception",
1606 FUNC(log2) (minus_zero), DIVIDE_BY_ZERO_EXCEPTION);
1608 check ("log2 (1) == +0", FUNC(log2) (1), 0);
1610 check_isnan_exc ("log2 (x) == NaN plus invalid exception if x < 0",
1611 FUNC(log2) (-1), INVALID_EXCEPTION);
1613 check_isinfp ("log2 (+inf) == +inf", FUNC(log2) (plus_infty));
1615 check_eps ("log2 (e) == M_LOG2E", FUNC(log2) (M_El), M_LOG2El,
1616 CHOOSE (1e-18L, 0, 0));
1617 check ("log2 (2) == 1", FUNC(log2) (2.0), 1);
1618 check_eps ("log2 (16) == 4", FUNC(log2) (16.0), 4, CHOOSE (1e-18L, 0, 0));
1619 check ("log2 (256) == 8", FUNC(log2) (256.0), 8);
1620 check_eps ("log2 (0.7) == -0.5145731728...", FUNC(log2) (0.7),
1621 -0.51457317282975824043L, CHOOSE (1e-16L, 2e-16, 6e-8));
1628 check_isinfp ("logb (+inf) == +inf", FUNC(logb) (plus_infty));
1629 check_isinfp ("logb (-inf) == +inf", FUNC(logb) (minus_infty));
1631 check_isinfn_exc ("logb (+0) == -inf plus divide-by-zero exception",
1632 FUNC(logb) (0), DIVIDE_BY_ZERO_EXCEPTION);
1634 check_isinfn_exc ("logb (-0) == -inf plus divide-by-zero exception",
1635 FUNC(logb) (minus_zero), DIVIDE_BY_ZERO_EXCEPTION);
1637 check ("logb (1) == 0", FUNC(logb) (1), 0);
1638 check ("logb (e) == 1", FUNC(logb) (M_El), 1);
1639 check ("logb (1024) == 10", FUNC(logb) (1024), 10);
1640 check ("logb (-2000) == 10", FUNC(logb) (-2000), 10);
1647 MATHTYPE result, intpart;
1649 result = FUNC(modf) (plus_infty, &intpart);
1650 check ("modf (+inf, &x) returns +0", result, 0);
1651 check_isinfp ("modf (+inf, &x) set x to +inf", intpart);
1653 result = FUNC(modf) (minus_infty, &intpart);
1654 check ("modf (-inf, &x) returns -0", result, minus_zero);
1655 check_isinfn ("modf (-inf, &x) sets x to -inf", intpart);
1657 result = FUNC(modf) (nan_value, &intpart);
1658 check_isnan ("modf (NaN, &x) returns NaN", result);
1659 check_isnan ("modf (NaN, &x) sets x to NaN", intpart);
1661 result = FUNC(modf) (0, &intpart);
1662 check ("modf (0, &x) returns 0", result, 0);
1663 check ("modf (0, &x) sets x to 0", intpart, 0);
1665 result = FUNC(modf) (minus_zero, &intpart);
1666 check ("modf (-0, &x) returns -0", result, minus_zero);
1667 check ("modf (-0, &x) sets x to -0", intpart, minus_zero);
1669 result = FUNC(modf) (1.5, &intpart);
1670 check ("modf (1.5, &x) returns 0.5", result, 0.5);
1671 check ("modf (1.5, &x) sets x to 1", intpart, 1);
1673 result = FUNC(modf) (2.5, &intpart);
1674 check ("modf (2.5, &x) returns 0.5", result, 0.5);
1675 check ("modf (2.5, &x) sets x to 2", intpart, 2);
1677 result = FUNC(modf) (-2.5, &intpart);
1678 check ("modf (-2.5, &x) returns -0.5", result, -0.5);
1679 check ("modf (-2.5, &x) sets x to -2", intpart, -2);
1681 result = FUNC(modf) (20, &intpart);
1682 check ("modf (20, &x) returns 0", result, 0);
1683 check ("modf (20, &x) sets x to 20", intpart, 20);
1685 result = FUNC(modf) (21, &intpart);
1686 check ("modf (21, &x) returns 0", result, 0);
1687 check ("modf (21, &x) sets x to 21", intpart, 21);
1689 result = FUNC(modf) (89.6, &intpart);
1690 check_eps ("modf (89.6, &x) returns 0.6", result, 0.6,
1691 CHOOSE (6e-15L, 6e-15, 2e-6));
1692 check ("modf (89.6, &x) sets x to 89", intpart, 89);
1701 check_isnan ("scalb (2, 0.5) == NaN", FUNC(scalb) (2, 0.5));
1702 check_isnan ("scalb (3, -2.5) == NaN", FUNC(scalb) (3, -2.5));
1704 check_isnan ("scalb (0, NaN) == NaN", FUNC(scalb) (0, nan_value));
1705 check_isnan ("scalb (1, NaN) == NaN", FUNC(scalb) (1, nan_value));
1707 x = random_greater (0.0);
1708 check ("scalb (x, 0) == 0", FUNC(scalb) (x, 0), x);
1709 x = random_greater (0.0);
1710 check ("scalb (-x, 0) == 0", FUNC(scalb) (-x, 0), -x);
1712 check_isnan_exc ("scalb (+0, +inf) == NaN plus invalid exception",
1713 FUNC(scalb) (0, plus_infty), INVALID_EXCEPTION);
1714 check_isnan_exc ("scalb (-0, +inf) == NaN plus invalid exception",
1715 FUNC(scalb) (minus_zero, plus_infty), INVALID_EXCEPTION);
1717 check ("scalb (+0, 2) == +0", FUNC(scalb) (0, 2), 0);
1718 check ("scalb (-0, 4) == -0", FUNC(scalb) (minus_zero, -4), minus_zero);
1719 check ("scalb (+0, 0) == +0", FUNC(scalb) (0, 0), 0);
1720 check ("scalb (-0, 0) == -0", FUNC(scalb) (minus_zero, 0), minus_zero);
1721 check ("scalb (+0, -1) == +0", FUNC(scalb) (0, -1), 0);
1722 check ("scalb (-0, -10) == -0", FUNC(scalb) (minus_zero, -10), minus_zero);
1723 check ("scalb (+0, -inf) == +0", FUNC(scalb) (0, minus_infty), 0);
1724 check ("scalb (-0, -inf) == -0", FUNC(scalb) (minus_zero, minus_infty),
1727 check_isinfp ("scalb (+inf, -1) == +inf", FUNC(scalb) (plus_infty, -1));
1728 check_isinfn ("scalb (-inf, -10) == -inf", FUNC(scalb) (minus_infty, -10));
1729 check_isinfp ("scalb (+inf, 0) == +inf", FUNC(scalb) (plus_infty, 0));
1730 check_isinfn ("scalb (-inf, 0) == -inf", FUNC(scalb) (minus_infty, 0));
1731 check_isinfp ("scalb (+inf, 2) == +inf", FUNC(scalb) (plus_infty, 2));
1732 check_isinfn ("scalb (-inf, 100) == -inf", FUNC(scalb) (minus_infty, 100));
1734 x = random_greater (0.0);
1735 check ("scalb (x, -inf) == 0", FUNC(scalb) (x, minus_infty), 0.0);
1736 check ("scalb (-x, -inf) == -0", FUNC(scalb) (-x, minus_infty), minus_zero);
1738 x = random_greater (0.0);
1739 check_isinfp ("scalb (x, +inf) == +inf", FUNC(scalb) (x, plus_infty));
1740 x = random_greater (0.0);
1741 check_isinfn ("scalb (-x, +inf) == -inf", FUNC(scalb) (-x, plus_infty));
1742 check_isinfp ("scalb (+inf, +inf) == +inf",
1743 FUNC(scalb) (plus_infty, plus_infty));
1744 check_isinfn ("scalb (-inf, +inf) == -inf",
1745 FUNC(scalb) (minus_infty, plus_infty));
1747 check_isnan ("scalb (+inf, -inf) == NaN",
1748 FUNC(scalb) (plus_infty, minus_infty));
1749 check_isnan ("scalb (-inf, -inf) == NaN",
1750 FUNC(scalb) (minus_infty, minus_infty));
1752 check_isnan ("scalb (NaN, 1) == NaN", FUNC(scalb) (nan_value, 1));
1753 check_isnan ("scalb (1, NaN) == NaN", FUNC(scalb) (1, nan_value));
1754 check_isnan ("scalb (NaN, 0) == NaN", FUNC(scalb) (nan_value, 0));
1755 check_isnan ("scalb (0, NaN) == NaN", FUNC(scalb) (0, nan_value));
1756 check_isnan ("scalb (NaN, +inf) == NaN",
1757 FUNC(scalb) (nan_value, plus_infty));
1758 check_isnan ("scalb (+inf, NaN) == NaN",
1759 FUNC(scalb) (plus_infty, nan_value));
1760 check_isnan ("scalb (NaN, NaN) == NaN", FUNC(scalb) (nan_value, nan_value));
1762 check ("scalb (0.8, 4) == 12.8", FUNC(scalb) (0.8L, 4), 12.8L);
1763 check ("scalb (-0.854375, 5) == -27.34", FUNC(scalb) (-0.854375L, 5), -27.34L);
1772 check ("scalbn (0, 0) == 0", FUNC(scalbn) (0, 0), 0);
1774 check_isinfp ("scalbn (+inf, 1) == +inf", FUNC(scalbn) (plus_infty, 1));
1775 check_isinfn ("scalbn (-inf, 1) == -inf", FUNC(scalbn) (minus_infty, 1));
1776 check_isnan ("scalbn (NaN, 1) == NaN", FUNC(scalbn) (nan_value, 1));
1778 check ("scalbn (0.8, 4) == 12.8", FUNC(scalbn) (0.8L, 4), 12.8L);
1779 check ("scalbn (-0.854375, 5) == -27.34", FUNC(scalbn) (-0.854375L, 5), -27.34L);
1781 x = random_greater (0.0);
1782 check_ext ("scalbn (x, 0) == x", FUNC(scalbn) (x, 0L), x, x);
1789 check ("sin (+0) == +0", FUNC(sin) (0), 0);
1790 check ("sin (-0) == -0", FUNC(sin) (minus_zero), minus_zero);
1791 check_isnan_exc ("sin (+inf) == NaN plus invalid exception",
1792 FUNC(sin) (plus_infty),
1794 check_isnan_exc ("sin (-inf) == NaN plus invalid exception",
1795 FUNC(sin) (minus_infty),
1798 check_eps ("sin (pi/6) == 0.5", FUNC(sin) (M_PI_6l),
1799 0.5, CHOOSE (4e-18L, 0, 0));
1800 check_eps ("sin (-pi/6) == -0.5", FUNC(sin) (-M_PI_6l),
1801 -0.5, CHOOSE (4e-18L, 0, 0));
1802 check ("sin (pi/2) == 1", FUNC(sin) (M_PI_2l), 1);
1803 check ("sin (-pi/2) == -1", FUNC(sin) (-M_PI_2l), -1);
1804 check_eps ("sin (0.7) == 0.6442176872...", FUNC(sin) (0.7),
1805 0.64421768723769105367L, CHOOSE (4e-17L, 0, 0));
1812 check ("sinh (+0) == +0", FUNC(sinh) (0), 0);
1815 check ("sinh (-0) == -0", FUNC(sinh) (minus_zero), minus_zero);
1817 check_isinfp ("sinh (+inf) == +inf", FUNC(sinh) (plus_infty));
1818 check_isinfn ("sinh (-inf) == -inf", FUNC(sinh) (minus_infty));
1821 check_eps ("sinh (0.7) == 0.7585837018...", FUNC(sinh) (0.7),
1822 0.75858370183953350346L, CHOOSE (6e-17L, 2e-16, 6e-8));
1829 MATHTYPE sin_res, cos_res;
1832 FUNC(sincos) (0, &sin_res, &cos_res);
1834 check ("sincos (+0, &sin, &cos) puts +0 in sin", sin_res, 0);
1836 check ("sincos (+0, &sin, &cos) puts 1 in cos", cos_res, 1);
1838 FUNC(sincos) (minus_zero, &sin_res, &cos_res);
1840 check ("sincos (-0, &sin, &cos) puts -0 in sin", sin_res, minus_zero);
1842 check ("sincos (-0, &sin, &cos) puts 1 in cos", cos_res, 1);
1844 FUNC(sincos) (plus_infty, &sin_res, &cos_res);
1846 check_isnan_exc ("sincos (+inf, &sin, &cos) puts NaN in sin plus invalid exception",
1847 sin_res, INVALID_EXCEPTION);
1849 check_isnan_exc ("sincos (+inf, &sin, &cos) puts NaN in cos plus invalid exception",
1850 cos_res, INVALID_EXCEPTION);
1852 FUNC(sincos) (minus_infty, &sin_res, &cos_res);
1854 check_isnan_exc ("sincos (-inf,&sin, &cos) puts NaN in sin plus invalid exception",
1855 sin_res, INVALID_EXCEPTION);
1857 check_isnan_exc ("sincos (-inf,&sin, &cos) puts NaN in cos plus invalid exception",
1858 cos_res, INVALID_EXCEPTION);
1860 FUNC(sincos) (M_PI_2l, &sin_res, &cos_res);
1862 check ("sincos (pi/2, &sin, &cos) puts 1 in sin", sin_res, 1);
1864 check_eps ("sincos (pi/2, &sin, &cos) puts 0 in cos", cos_res, 0,
1865 CHOOSE (1e-18L, 1e-16, 1e-7));
1867 FUNC(sincos) (M_PI_6l, &sin_res, &cos_res);
1868 check_eps ("sincos (pi/6, &sin, &cos) puts 0.5 in sin", sin_res, 0.5,
1869 CHOOSE (5e-18L, 0, 0));
1871 FUNC(sincos) (M_PI_6l*2.0, &sin_res, &cos_res);
1872 check_eps ("sincos (pi/3, &sin, &cos) puts 0.5 in cos", cos_res, 0.5,
1873 CHOOSE (5e-18L, 1e-15, 1e-7));
1875 FUNC(sincos) (0.7, &sin_res, &cos_res);
1876 check_eps ("sincos (0.7, &sin, &cos) puts 0.6442176872... in sin", sin_res,
1877 0.64421768723769105367L, CHOOSE (4e-17L, 0, 0));
1878 check_eps ("sincos (0.7, &sin, &cos) puts 0.7648421872... in cos", cos_res,
1879 0.76484218728448842626L, CHOOSE (3e-17L, 2e-16, 6e-8));
1886 check ("tan (+0) == +0", FUNC(tan) (0), 0);
1887 check ("tan (-0) == -0", FUNC(tan) (minus_zero), minus_zero);
1888 check_isnan_exc ("tan (+inf) == NaN plus invalid exception",
1889 FUNC(tan) (plus_infty), INVALID_EXCEPTION);
1890 check_isnan_exc ("tan (-inf) == NaN plus invalid exception",
1891 FUNC(tan) (minus_infty), INVALID_EXCEPTION);
1893 check_eps ("tan (pi/4) == 1", FUNC(tan) (M_PI_4l), 1,
1894 CHOOSE (2e-18L, 1e-15L, 2e-7));
1895 check_eps ("tan (0.7) == 0.8422883804...", FUNC(tan) (0.7),
1896 0.84228838046307944813L, CHOOSE (8e-17L, 0, 0));
1903 check ("tanh (+0) == +0", FUNC(tanh) (0), 0);
1905 check ("tanh (-0) == -0", FUNC(tanh) (minus_zero), minus_zero);
1907 check ("tanh (+inf) == +1", FUNC(tanh) (plus_infty), 1);
1908 check ("tanh (-inf) == -1", FUNC(tanh) (minus_infty), -1);
1910 check_eps ("tanh (0.7) == 0.6043677771...", FUNC(tanh) (0.7),
1911 0.60436777711716349631L, CHOOSE (3e-17L, 2e-16, 6e-8));
1918 check ("fabs (+0) == +0", FUNC(fabs) (0), 0);
1919 check ("fabs (-0) == +0", FUNC(fabs) (minus_zero), 0);
1921 check_isinfp ("fabs (+inf) == +inf", FUNC(fabs) (plus_infty));
1922 check_isinfp ("fabs (-inf) == +inf", FUNC(fabs) (minus_infty));
1924 check ("fabs (+38) == 38", FUNC(fabs) (38.0), 38.0);
1925 check ("fabs (-e) == e", FUNC(fabs) (-M_El), M_El);
1932 check ("floor (+0) == +0", FUNC(floor) (0.0), 0.0);
1933 check ("floor (-0) == -0", FUNC(floor) (minus_zero), minus_zero);
1934 check_isinfp ("floor (+inf) == +inf", FUNC(floor) (plus_infty));
1935 check_isinfn ("floor (-inf) == -inf", FUNC(floor) (minus_infty));
1937 check ("floor (pi) == 3", FUNC(floor) (M_PIl), 3.0);
1938 check ("floor (-pi) == -4", FUNC(floor) (-M_PIl), -4.0);
1947 a = random_greater (0);
1948 check_isinfp_ext ("hypot (+inf, x) == +inf", FUNC(hypot) (plus_infty, a), a);
1949 check_isinfp_ext ("hypot (-inf, x) == +inf", FUNC(hypot) (minus_infty, a), a);
1952 check_isinfp ("hypot (+inf, NaN) == +inf", FUNC(hypot) (plus_infty, nan_value));
1953 check_isinfp ("hypot (-inf, NaN) == +inf", FUNC(hypot) (minus_infty, nan_value));
1956 check_isnan ("hypot (NaN, NaN) == NaN", FUNC(hypot) (nan_value, nan_value));
1958 a = FUNC(hypot) (12.4L, 0.7L);
1959 check ("hypot (x,y) == hypot (y,x)", FUNC(hypot) (0.7L, 12.4L), a);
1960 check ("hypot (x,y) == hypot (-x,y)", FUNC(hypot) (-12.4L, 0.7L), a);
1961 check ("hypot (x,y) == hypot (-y,x)", FUNC(hypot) (-0.7L, 12.4L), a);
1962 check ("hypot (x,y) == hypot (-x,-y)", FUNC(hypot) (-12.4L, -0.7L), a);
1963 check ("hypot (x,y) == hypot (-y,-x)", FUNC(hypot) (-0.7L, -12.4L), a);
1964 check ("hypot (x,0) == fabs (x)", FUNC(hypot) (-0.7L, 0), 0.7L);
1965 check ("hypot (x,0) == fabs (x)", FUNC(hypot) (0.7L, 0), 0.7L);
1966 check ("hypot (x,0) == fabs (x)", FUNC(hypot) (-1.0L, 0), 1.0L);
1967 check ("hypot (x,0) == fabs (x)", FUNC(hypot) (1.0L, 0), 1.0L);
1968 check ("hypot (x,0) == fabs (x)", FUNC(hypot) (-5.7e7L, 0), 5.7e7L);
1969 check ("hypot (x,0) == fabs (x)", FUNC(hypot) (5.7e7L, 0), 5.7e7L);
1971 check_eps ("hypot (0.7,1.2) == 1.38924...", FUNC(hypot) (0.7, 1.2),
1972 1.3892443989449804508L, CHOOSE (7e-17L, 3e-16, 0));
1981 check ("pow (+0, +0) == 1", FUNC(pow) (0, 0), 1);
1982 check ("pow (+0, -0) == 1", FUNC(pow) (0, minus_zero), 1);
1983 check ("pow (-0, +0) == 1", FUNC(pow) (minus_zero, 0), 1);
1984 check ("pow (-0, -0) == 1", FUNC(pow) (minus_zero, minus_zero), 1);
1986 check ("pow (+10, +0) == 1", FUNC(pow) (10, 0), 1);
1987 check ("pow (+10, -0) == 1", FUNC(pow) (10, minus_zero), 1);
1988 check ("pow (-10, +0) == 1", FUNC(pow) (-10, 0), 1);
1989 check ("pow (-10, -0) == 1", FUNC(pow) (-10, minus_zero), 1);
1991 check ("pow (NaN, +0) == 1", FUNC(pow) (nan_value, 0), 1);
1992 check ("pow (NaN, -0) == 1", FUNC(pow) (nan_value, minus_zero), 1);
1995 check_isinfp ("pow (+1.1, +inf) == +inf", FUNC(pow) (1.1, plus_infty));
1996 check_isinfp ("pow (+inf, +inf) == +inf", FUNC(pow) (plus_infty, plus_infty));
1997 check_isinfp ("pow (-1.1, +inf) == +inf", FUNC(pow) (-1.1, plus_infty));
1998 check_isinfp ("pow (-inf, +inf) == +inf", FUNC(pow) (minus_infty, plus_infty));
2000 check ("pow (0.9, +inf) == +0", FUNC(pow) (0.9L, plus_infty), 0);
2001 check ("pow (1e-7, +inf) == +0", FUNC(pow) (1e-7L, plus_infty), 0);
2002 check ("pow (-0.9, +inf) == +0", FUNC(pow) (-0.9L, plus_infty), 0);
2003 check ("pow (-1e-7, +inf) == +0", FUNC(pow) (-1e-7L, plus_infty), 0);
2005 check ("pow (+1.1, -inf) == 0", FUNC(pow) (1.1, minus_infty), 0);
2006 check ("pow (+inf, -inf) == 0", FUNC(pow) (plus_infty, minus_infty), 0);
2007 check ("pow (-1.1, -inf) == 0", FUNC(pow) (-1.1, minus_infty), 0);
2008 check ("pow (-inf, -inf) == 0", FUNC(pow) (minus_infty, minus_infty), 0);
2010 check_isinfp ("pow (0.9, -inf) == +inf", FUNC(pow) (0.9L, minus_infty));
2011 check_isinfp ("pow (1e-7, -inf) == +inf", FUNC(pow) (1e-7L, minus_infty));
2012 check_isinfp ("pow (-0.9, -inf) == +inf", FUNC(pow) (-0.9L, minus_infty));
2013 check_isinfp ("pow (-1e-7, -inf) == +inf", FUNC(pow) (-1e-7L, minus_infty));
2015 check_isinfp ("pow (+inf, 1e-7) == +inf", FUNC(pow) (plus_infty, 1e-7L));
2016 check_isinfp ("pow (+inf, 1) == +inf", FUNC(pow) (plus_infty, 1));
2017 check_isinfp ("pow (+inf, 1e7) == +inf", FUNC(pow) (plus_infty, 1e7L));
2019 check ("pow (+inf, -1e-7) == 0", FUNC(pow) (plus_infty, -1e-7L), 0);
2020 check ("pow (+inf, -1) == 0", FUNC(pow) (plus_infty, -1), 0);
2021 check ("pow (+inf, -1e7) == 0", FUNC(pow) (plus_infty, -1e7L), 0);
2023 check_isinfn ("pow (-inf, 1) == -inf", FUNC(pow) (minus_infty, 1));
2024 check_isinfn ("pow (-inf, 11) == -inf", FUNC(pow) (minus_infty, 11));
2025 check_isinfn ("pow (-inf, 1001) == -inf", FUNC(pow) (minus_infty, 1001));
2027 check_isinfp ("pow (-inf, 2) == +inf", FUNC(pow) (minus_infty, 2));
2028 check_isinfp ("pow (-inf, 12) == +inf", FUNC(pow) (minus_infty, 12));
2029 check_isinfp ("pow (-inf, 1002) == +inf", FUNC(pow) (minus_infty, 1002));
2030 check_isinfp ("pow (-inf, 0.1) == +inf", FUNC(pow) (minus_infty, 0.1));
2031 check_isinfp ("pow (-inf, 1.1) == +inf", FUNC(pow) (minus_infty, 1.1));
2032 check_isinfp ("pow (-inf, 11.1) == +inf", FUNC(pow) (minus_infty, 11.1));
2033 check_isinfp ("pow (-inf, 1001.1) == +inf", FUNC(pow) (minus_infty, 1001.1));
2035 check ("pow (-inf, -1) == -0", FUNC(pow) (minus_infty, -1), minus_zero);
2036 check ("pow (-inf, -11) == -0", FUNC(pow) (minus_infty, -11), minus_zero);
2037 check ("pow (-inf, -1001) == -0", FUNC(pow) (minus_infty, -1001), minus_zero);
2039 check ("pow (-inf, -2) == +0", FUNC(pow) (minus_infty, -2), 0);
2040 check ("pow (-inf, -12) == +0", FUNC(pow) (minus_infty, -12), 0);
2041 check ("pow (-inf, -1002) == +0", FUNC(pow) (minus_infty, -1002), 0);
2042 check ("pow (-inf, -0.1) == +0", FUNC(pow) (minus_infty, -0.1), 0);
2043 check ("pow (-inf, -1.1) == +0", FUNC(pow) (minus_infty, -1.1), 0);
2044 check ("pow (-inf, -11.1) == +0", FUNC(pow) (minus_infty, -11.1), 0);
2045 check ("pow (-inf, -1001.1) == +0", FUNC(pow) (minus_infty, -1001.1), 0);
2047 check_isnan ("pow (NaN, NaN) == NaN", FUNC(pow) (nan_value, nan_value));
2048 check_isnan ("pow (0, NaN) == NaN", FUNC(pow) (0, nan_value));
2049 check_isnan ("pow (1, NaN) == NaN", FUNC(pow) (1, nan_value));
2050 check_isnan ("pow (-1, NaN) == NaN", FUNC(pow) (-1, nan_value));
2051 check_isnan ("pow (NaN, 1) == NaN", FUNC(pow) (nan_value, 1));
2052 check_isnan ("pow (NaN, -1) == NaN", FUNC(pow) (nan_value, -1));
2054 x = random_greater (0.0);
2055 check_isnan_ext ("pow (x, NaN) == NaN", FUNC(pow) (x, nan_value), x);
2057 check_isnan_exc ("pow (+1, +inf) == NaN plus invalid exception",
2058 FUNC(pow) (1, plus_infty), INVALID_EXCEPTION);
2059 check_isnan_exc ("pow (-1, +inf) == NaN plus invalid exception",
2060 FUNC(pow) (-1, plus_infty), INVALID_EXCEPTION);
2061 check_isnan_exc ("pow (+1, -inf) == NaN plus invalid exception",
2062 FUNC(pow) (1, minus_infty), INVALID_EXCEPTION);
2063 check_isnan_exc ("pow (-1, -inf) == NaN plus invalid exception",
2064 FUNC(pow) (-1, minus_infty), INVALID_EXCEPTION);
2066 check_isnan_exc ("pow (-0.1, 1.1) == NaN plus invalid exception",
2067 FUNC(pow) (-0.1, 1.1), INVALID_EXCEPTION);
2068 check_isnan_exc ("pow (-0.1, -1.1) == NaN plus invalid exception",
2069 FUNC(pow) (-0.1, -1.1), INVALID_EXCEPTION);
2070 check_isnan_exc ("pow (-10.1, 1.1) == NaN plus invalid exception",
2071 FUNC(pow) (-10.1, 1.1), INVALID_EXCEPTION);
2072 check_isnan_exc ("pow (-10.1, -1.1) == NaN plus invalid exception",
2073 FUNC(pow) (-10.1, -1.1), INVALID_EXCEPTION);
2075 check_isinfp_exc ("pow (+0, -1) == +inf plus divide-by-zero exception",
2076 FUNC(pow) (0, -1), DIVIDE_BY_ZERO_EXCEPTION);
2077 check_isinfp_exc ("pow (+0, -11) == +inf plus divide-by-zero exception",
2078 FUNC(pow) (0, -11), DIVIDE_BY_ZERO_EXCEPTION);
2079 check_isinfn_exc ("pow (-0, -1) == -inf plus divide-by-zero exception",
2080 FUNC(pow) (minus_zero, -1), DIVIDE_BY_ZERO_EXCEPTION);
2081 check_isinfn_exc ("pow (-0, -11) == -inf plus divide-by-zero exception",
2082 FUNC(pow) (minus_zero, -11), DIVIDE_BY_ZERO_EXCEPTION);
2084 check_isinfp_exc ("pow (+0, -2) == +inf plus divide-by-zero exception",
2085 FUNC(pow) (0, -2), DIVIDE_BY_ZERO_EXCEPTION);
2086 check_isinfp_exc ("pow (+0, -11.1) == +inf plus divide-by-zero exception",
2087 FUNC(pow) (0, -11.1), DIVIDE_BY_ZERO_EXCEPTION);
2088 check_isinfp_exc ("pow (-0, -2) == +inf plus divide-by-zero exception",
2089 FUNC(pow) (minus_zero, -2), DIVIDE_BY_ZERO_EXCEPTION);
2090 check_isinfp_exc ("pow (-0, -11.1) == +inf plus divide-by-zero exception",
2091 FUNC(pow) (minus_zero, -11.1), DIVIDE_BY_ZERO_EXCEPTION);
2094 check ("pow (+0, 1) == +0", FUNC(pow) (0, 1), 0);
2095 check ("pow (+0, 11) == +0", FUNC(pow) (0, 11), 0);
2097 check ("pow (-0, 1) == -0", FUNC(pow) (minus_zero, 1), minus_zero);
2098 check ("pow (-0, 11) == -0", FUNC(pow) (minus_zero, 11), minus_zero);
2101 check ("pow (+0, 2) == +0", FUNC(pow) (0, 2), 0);
2102 check ("pow (+0, 11.1) == +0", FUNC(pow) (0, 11.1), 0);
2105 check ("pow (-0, 2) == +0", FUNC(pow) (minus_zero, 2), 0);
2106 check ("pow (-0, 11.1) == +0", FUNC(pow) (minus_zero, 11.1), 0);
2108 x = random_greater (1.0);
2109 check_isinfp_ext ("pow (x, +inf) == +inf for |x| > 1",
2110 FUNC(pow) (x, plus_infty), x);
2112 x = random_value (-1.0, 1.0);
2113 check_ext ("pow (x, +inf) == +0 for |x| < 1",
2114 FUNC(pow) (x, plus_infty), 0.0, x);
2116 x = random_greater (1.0);
2117 check_ext ("pow (x, -inf) == +0 for |x| > 1",
2118 FUNC(pow) (x, minus_infty), 0.0, x);
2120 x = random_value (-1.0, 1.0);
2121 check_isinfp_ext ("pow (x, -inf) == +inf for |x| < 1",
2122 FUNC(pow) (x, minus_infty), x);
2124 x = random_greater (0.0);
2125 check_isinfp_ext ("pow (+inf, y) == +inf for y > 0",
2126 FUNC(pow) (plus_infty, x), x);
2128 x = random_less (0.0);
2129 check_ext ("pow (+inf, y) == +0 for y < 0",
2130 FUNC(pow) (plus_infty, x), 0.0, x);
2132 x = (rand () % 1000000) * 2.0 + 1; /* Get random odd integer > 0 */
2133 check_isinfn_ext ("pow (-inf, y) == -inf for y an odd integer > 0",
2134 FUNC(pow) (minus_infty, x), x);
2136 x = ((rand () % 1000000) + 1) * 2.0; /* Get random even integer > 1 */
2137 check_isinfp_ext ("pow (-inf, y) == +inf for y > 0 and not an odd integer",
2138 FUNC(pow) (minus_infty, x), x);
2140 x = -((rand () % 1000000) * 2.0 + 1); /* Get random odd integer < 0 */
2141 check_ext ("pow (-inf, y) == -0 for y an odd integer < 0",
2142 FUNC(pow) (minus_infty, x), minus_zero, x);
2144 x = ((rand () % 1000000) + 1) * -2.0; /* Get random even integer < 0 */
2145 check_ext ("pow (-inf, y) == +0 for y < 0 and not an odd integer",
2146 FUNC(pow) (minus_infty, x), 0.0, x);
2149 x = (rand () % 1000000) * 2.0 + 1; /* Get random odd integer > 0 */
2150 check_ext ("pow (+0, y) == +0 for y an odd integer > 0",
2151 FUNC(pow) (0.0, x), 0.0, x);
2153 x = (rand () % 1000000) * 2.0 + 1; /* Get random odd integer > 0 */
2154 check_ext ("pow (-0, y) == -0 for y an odd integer > 0",
2155 FUNC(pow) (minus_zero, x), minus_zero, x);
2158 x = ((rand () % 1000000) + 1) * 2.0; /* Get random even integer > 1 */
2159 check_ext ("pow (+0, y) == +0 for y > 0 and not an odd integer",
2160 FUNC(pow) (0.0, x), 0.0, x);
2162 x = ((rand () % 1000000) + 1) * 2.0; /* Get random even integer > 1 */
2163 check_ext ("pow (-0, y) == +0 for y > 0 and not an odd integer",
2164 FUNC(pow) (minus_zero, x), 0.0, x);
2166 check_eps ("pow (0.7, 1.2) == 0.65180...", FUNC(pow) (0.7, 1.2),
2167 0.65180494056638638188L, CHOOSE (4e-17L, 0, 0));
2170 check ("pow (-7.49321e+133, -9.80818e+16) == 0",
2171 FUNC(pow) (-7.49321e+133, -9.80818e+16), 0);
2179 check ("fdim (+0, +0) = +0", FUNC(fdim) (0, 0), 0);
2180 check ("fdim (9, 0) = 9", FUNC(fdim) (9, 0), 9);
2181 check ("fdim (0, 9) = 0", FUNC(fdim) (0, 9), 0);
2182 check ("fdim (-9, 0) = 0", FUNC(fdim) (-9, 0), 0);
2183 check ("fdim (0, -9) = 9", FUNC(fdim) (0, -9), 9);
2185 check_isinfp ("fdim (+inf, 9) = +inf", FUNC(fdim) (plus_infty, 9));
2186 check_isinfp ("fdim (+inf, -9) = +inf", FUNC(fdim) (plus_infty, -9));
2187 check ("fdim (-inf, 9) = 0", FUNC(fdim) (minus_infty, 9), 0);
2188 check ("fdim (-inf, -9) = 0", FUNC(fdim) (minus_infty, -9), 0);
2189 check_isinfp ("fdim (+9, -inf) = +inf", FUNC(fdim) (9, minus_infty));
2190 check_isinfp ("fdim (-9, -inf) = +inf", FUNC(fdim) (-9, minus_infty));
2191 check ("fdim (9, inf) = 0", FUNC(fdim) (9, plus_infty), 0);
2192 check ("fdim (-9, inf) = 0", FUNC(fdim) (-9, plus_infty), 0);
2194 check_isnan ("fdim (0, NaN) = NaN", FUNC(fdim) (0, nan_value));
2195 check_isnan ("fdim (9, NaN) = NaN", FUNC(fdim) (9, nan_value));
2196 check_isnan ("fdim (-9, NaN) = NaN", FUNC(fdim) (-9, nan_value));
2197 check_isnan ("fdim (NaN, 9) = NaN", FUNC(fdim) (nan_value, 9));
2198 check_isnan ("fdim (NaN, -9) = NaN", FUNC(fdim) (nan_value, -9));
2199 check_isnan ("fdim (+inf, NaN) = NaN", FUNC(fdim) (plus_infty, nan_value));
2200 check_isnan ("fdim (-inf, NaN) = NaN", FUNC(fdim) (minus_infty, nan_value));
2201 check_isnan ("fdim (NaN, +inf) = NaN", FUNC(fdim) (nan_value, plus_infty));
2202 check_isnan ("fdim (NaN, -inf) = NaN", FUNC(fdim) (nan_value, minus_infty));
2203 check_isnan ("fdim (NaN, NaN) = NaN", FUNC(fdim) (nan_value, nan_value));
2210 check ("fmin (+0, +0) = +0", FUNC(fmin) (0, 0), 0);
2211 check ("fmin (9, 0) = 0", FUNC(fmin) (9, 0), 0);
2212 check ("fmin (0, 9) = 0", FUNC(fmin) (0, 9), 0);
2213 check ("fmin (-9, 0) = -9", FUNC(fmin) (-9, 0), -9);
2214 check ("fmin (0, -9) = -9", FUNC(fmin) (0, -9), -9);
2216 check ("fmin (+inf, 9) = 9", FUNC(fmin) (plus_infty, 9), 9);
2217 check ("fmin (9, +inf) = 9", FUNC(fmin) (9, plus_infty), 9);
2218 check ("fmin (+inf, -9) = -9", FUNC(fmin) (plus_infty, -9), -9);
2219 check ("fmin (-9, +inf) = -9", FUNC(fmin) (-9, plus_infty), -9);
2220 check_isinfn ("fmin (-inf, 9) = -inf", FUNC(fmin) (minus_infty, 9));
2221 check_isinfn ("fmin (-inf, -9) = -inf", FUNC(fmin) (minus_infty, -9));
2222 check_isinfn ("fmin (+9, -inf) = -inf", FUNC(fmin) (9, minus_infty));
2223 check_isinfn ("fmin (-9, -inf) = -inf", FUNC(fmin) (-9, minus_infty));
2225 check ("fmin (0, NaN) = 0", FUNC(fmin) (0, nan_value), 0);
2226 check ("fmin (9, NaN) = 9", FUNC(fmin) (9, nan_value), 9);
2227 check ("fmin (-9, NaN) = 9", FUNC(fmin) (-9, nan_value), -9);
2228 check ("fmin (NaN, 0) = 0", FUNC(fmin) (nan_value, 0), 0);
2229 check ("fmin (NaN, 9) = NaN", FUNC(fmin) (nan_value, 9), 9);
2230 check ("fmin (NaN, -9) = NaN", FUNC(fmin) (nan_value, -9), -9);
2231 check_isinfp ("fmin (+inf, NaN) = +inf", FUNC(fmin) (plus_infty, nan_value));
2232 check_isinfn ("fmin (-inf, NaN) = -inf", FUNC(fmin) (minus_infty, nan_value));
2233 check_isinfp ("fmin (NaN, +inf) = +inf", FUNC(fmin) (nan_value, plus_infty));
2234 check_isinfn ("fmin (NaN, -inf) = -inf", FUNC(fmin) (nan_value, minus_infty));
2235 check_isnan ("fmin (NaN, NaN) = NaN", FUNC(fmin) (nan_value, nan_value));
2242 check ("fmax (+0, +0) = +0", FUNC(fmax) (0, 0), 0);
2243 check ("fmax (9, 0) = 9", FUNC(fmax) (9, 0), 9);
2244 check ("fmax (0, 9) = 9", FUNC(fmax) (0, 9), 9);
2245 check ("fmax (-9, 0) = 0", FUNC(fmax) (-9, 0), 0);
2246 check ("fmax (0, -9) = 0", FUNC(fmax) (0, -9), 0);
2248 check_isinfp ("fmax (+inf, 9) = +inf", FUNC(fmax) (plus_infty, 9));
2249 check_isinfp ("fmax (9, +inf) = +inf", FUNC(fmax) (0, plus_infty));
2250 check_isinfp ("fmax (-9, +inf) = +inf", FUNC(fmax) (-9, plus_infty));
2251 check_isinfp ("fmax (+inf, -9) = +inf", FUNC(fmax) (plus_infty, -9));
2252 check ("fmax (-inf, 9) = 9", FUNC(fmax) (minus_infty, 9), 9);
2253 check ("fmax (-inf, -9) = -9", FUNC(fmax) (minus_infty, -9), -9);
2254 check ("fmax (+9, -inf) = 9", FUNC(fmax) (9, minus_infty), 9);
2255 check ("fmax (-9, -inf) = -9", FUNC(fmax) (-9, minus_infty), -9);
2257 check ("fmax (0, NaN) = 0", FUNC(fmax) (0, nan_value), 0);
2258 check ("fmax (9, NaN) = 9", FUNC(fmax) (9, nan_value), 9);
2259 check ("fmax (-9, NaN) = 9", FUNC(fmax) (-9, nan_value), -9);
2260 check ("fmax (NaN, 0) = 0", FUNC(fmax) (nan_value, 0), 0);
2261 check ("fmax (NaN, 9) = NaN", FUNC(fmax) (nan_value, 9), 9);
2262 check ("fmax (NaN, -9) = NaN", FUNC(fmax) (nan_value, -9), -9);
2263 check_isinfp ("fmax (+inf, NaN) = +inf", FUNC(fmax) (plus_infty, nan_value));
2264 check_isinfn ("fmax (-inf, NaN) = -inf", FUNC(fmax) (minus_infty, nan_value));
2265 check_isinfp ("fmax (NaN, +inf) = +inf", FUNC(fmax) (nan_value, plus_infty));
2266 check_isinfn ("fmax (NaN, -inf) = -inf", FUNC(fmax) (nan_value, minus_infty));
2267 check_isnan ("fmax (NaN, NaN) = NaN", FUNC(fmax) (nan_value, nan_value));
2276 x = random_greater (0);
2277 check_ext ("fmod (+0, y) == +0 for y != 0", FUNC(fmod) (0, x), 0, x);
2279 x = random_greater (0);
2280 check_ext ("fmod (-0, y) == -0 for y != 0", FUNC(fmod) (minus_zero, x),
2283 check_isnan_exc_ext ("fmod (+inf, y) == NaN plus invalid exception",
2284 FUNC(fmod) (plus_infty, x), INVALID_EXCEPTION, x);
2285 check_isnan_exc_ext ("fmod (-inf, y) == NaN plus invalid exception",
2286 FUNC(fmod) (minus_infty, x), INVALID_EXCEPTION, x);
2287 check_isnan_exc_ext ("fmod (x, +0) == NaN plus invalid exception",
2288 FUNC(fmod) (x, 0), INVALID_EXCEPTION, x);
2289 check_isnan_exc_ext ("fmod (x, -0) == NaN plus invalid exception",
2290 FUNC(fmod) (x, minus_zero), INVALID_EXCEPTION, x);
2292 x = random_greater (0);
2293 check_ext ("fmod (x, +inf) == x for x not infinite",
2294 FUNC(fmod) (x, plus_infty), x, x);
2295 x = random_greater (0);
2296 check_ext ("fmod (x, -inf) == x for x not infinite",
2297 FUNC(fmod) (x, minus_infty), x, x);
2299 check_eps ("fmod (6.5, 2.3) == 1.9", FUNC(fmod) (6.5, 2.3), 1.9,
2300 CHOOSE (5e-16, 1e-15, 2e-7));
2301 check_eps ("fmod (-6.5, 2.3) == -1.9", FUNC(fmod) (-6.5, 2.3), -1.9,
2302 CHOOSE (5e-16, 1e-15, 2e-7));
2303 check_eps ("fmod (6.5, -2.3) == 1.9", FUNC(fmod) (6.5, -2.3), 1.9,
2304 CHOOSE (5e-16, 1e-15, 2e-7));
2305 check_eps ("fmod (-6.5, -2.3) == -1.9", FUNC(fmod) (-6.5, -2.3), -1.9,
2306 CHOOSE (5e-16, 1e-15, 2e-7));
2311 nextafter_test (void)
2315 check ("nextafter (+0, +0) = +0", FUNC(nextafter) (0, 0), 0);
2316 check ("nextafter (-0, +0) = +0", FUNC(nextafter) (minus_zero, 0), 0);
2317 check ("nextafter (+0, -0) = -0", FUNC(nextafter) (0, minus_zero),
2319 check ("nextafter (-0, -0) = -0", FUNC(nextafter) (minus_zero, minus_zero),
2322 check ("nextafter (9, 9) = 9", FUNC(nextafter) (9, 9), 9);
2323 check ("nextafter (-9, -9) = -9", FUNC(nextafter) (-9, -9), -9);
2324 check_isinfp ("nextafter (+inf, +inf) = +inf",
2325 FUNC(nextafter) (plus_infty, plus_infty));
2326 check_isinfn ("nextafter (-inf, -inf) = -inf",
2327 FUNC(nextafter) (minus_infty, minus_infty));
2330 check_isnan ("nextafter (NaN, x) = NaN", FUNC(nextafter) (nan_value, x));
2331 check_isnan ("nextafter (x, NaN) = NaN", FUNC(nextafter) (x, nan_value));
2332 check_isnan ("nextafter (NaN, NaN) = NaN", FUNC(nextafter) (nan_value,
2335 /* XXX We need the hexadecimal FP number representation here for further
2341 copysign_test (void)
2343 check ("copysign (0, 4) = 0", FUNC(copysign) (0, 4), 0);
2344 check ("copysign (0, -4) = -0", FUNC(copysign) (0, -4), minus_zero);
2345 check ("copysign (-0, 4) = 0", FUNC(copysign) (minus_zero, 4), 0);
2346 check ("copysign (-0, -4) = -0", FUNC(copysign) (minus_zero, -4),
2349 check_isinfp ("copysign (+inf, 0) = +inf", FUNC(copysign) (plus_infty, 0));
2350 check_isinfn ("copysign (+inf, -0) = -inf", FUNC(copysign) (plus_infty,
2352 check_isinfp ("copysign (-inf, 0) = +inf", FUNC(copysign) (minus_infty, 0));
2353 check_isinfn ("copysign (-inf, -0) = -inf", FUNC(copysign) (minus_infty,
2356 check ("copysign (0, +inf) = 0", FUNC(copysign) (0, plus_infty), 0);
2357 check ("copysign (0, -inf) = -0", FUNC(copysign) (0, minus_zero),
2359 check ("copysign (-0, +inf) = 0", FUNC(copysign) (minus_zero, plus_infty),
2361 check ("copysign (-0, -inf) = -0", FUNC(copysign) (minus_zero, minus_zero),
2364 /* XXX More correctly we would have to check the sign of the NaN. */
2365 check_isnan ("copysign (+NaN, 0) = +NaN", FUNC(copysign) (nan_value, 0));
2366 check_isnan ("copysign (+NaN, -0) = -NaN", FUNC(copysign) (nan_value,
2368 check_isnan ("copysign (-NaN, 0) = +NaN", FUNC(copysign) (-nan_value, 0));
2369 check_isnan ("copysign (-NaN, -0) = -NaN", FUNC(copysign) (-nan_value,
2377 check ("trunc(0) = 0", FUNC(trunc) (0), 0);
2378 check ("trunc(-0) = -0", FUNC(trunc) (minus_zero), minus_zero);
2379 check ("trunc(0.625) = 0", FUNC(trunc) (0.625), 0);
2380 check ("trunc(-0.625) = -0", FUNC(trunc) (-0.625), minus_zero);
2381 check ("trunc(1) = 1", FUNC(trunc) (1), 1);
2382 check ("trunc(-1) = -1", FUNC(trunc) (-1), -1);
2383 check ("trunc(1.625) = 1", FUNC(trunc) (1.625), 1);
2384 check ("trunc(-1.625) = -1", FUNC(trunc) (-1.625), -1);
2386 check ("trunc(1048580.625) = 1048580", FUNC(trunc) (1048580.625L),
2388 check ("trunc(-1048580.625) = -1048580", FUNC(trunc) (-1048580.625L),
2391 check ("trunc(8388610.125) = 8388610", FUNC(trunc) (8388610.125L),
2393 check ("trunc(-8388610.125) = -8388610", FUNC(trunc) (-8388610.125L),
2396 check ("trunc(4294967296.625) = 4294967296", FUNC(trunc) (4294967296.625L),
2398 check ("trunc(-4294967296.625) = -4294967296",
2399 FUNC(trunc) (-4294967296.625L), -4294967296.0L);
2401 check_isinfp ("trunc(+inf) = +inf", FUNC(trunc) (plus_infty));
2402 check_isinfn ("trunc(-inf) = -inf", FUNC(trunc) (minus_infty));
2403 check_isnan ("trunc(NaN) = NaN", FUNC(trunc) (nan_value));
2413 /* XXX Tests fuer negative x are missing */
2414 check ("sqrt (0) == 0", FUNC(sqrt) (0), 0);
2415 check_isnan ("sqrt (NaN) == NaN", FUNC(sqrt) (nan_value));
2416 check_isinfp ("sqrt (+inf) == +inf", FUNC(sqrt) (plus_infty));
2418 check ("sqrt (-0) == -0", FUNC(sqrt) (0), 0);
2420 x = random_less (0.0);
2421 check_isnan_exc_ext ("sqrt (x) == NaN plus invalid exception for x < 0",
2422 FUNC(sqrt) (x), INVALID_EXCEPTION, x);
2424 x = random_value (0, 10000);
2425 check_ext ("sqrt (x*x) == x", FUNC(sqrt) (x*x), x, x);
2426 check ("sqrt (4) == 2", FUNC(sqrt) (4), 2);
2427 check ("sqrt (2) == 1.14142...", FUNC(sqrt) (2), M_SQRT2l);
2428 check ("sqrt (0.25) == 0.5", FUNC(sqrt) (0.25), 0.5);
2429 check ("sqrt (6642.25) == 81.5", FUNC(sqrt) (6642.25), 81.5);
2430 check_eps ("sqrt (15239.903) == 123.45", FUNC(sqrt) (15239.903), 123.45,
2431 CHOOSE (3e-6L, 3e-6, 8e-6));
2432 check_eps ("sqrt (0.7) == 0.8366600265", FUNC(sqrt) (0.7),
2433 0.83666002653407554798L, CHOOSE (3e-17L, 0, 0));
2438 remainder_test (void)
2442 result = FUNC(remainder) (1, 0);
2443 check_isnan_exc ("remainder(1, +0) == NaN plus invalid exception",
2444 result, INVALID_EXCEPTION);
2446 result = FUNC(remainder) (1, minus_zero);
2447 check_isnan_exc ("remainder(1, -0) == NaN plus invalid exception",
2448 result, INVALID_EXCEPTION);
2450 result = FUNC(remainder) (plus_infty, 1);
2451 check_isnan_exc ("remainder(+inf, 1) == NaN plus invalid exception",
2452 result, INVALID_EXCEPTION);
2454 result = FUNC(remainder) (minus_infty, 1);
2455 check_isnan_exc ("remainder(-inf, 1) == NaN plus invalid exception",
2456 result, INVALID_EXCEPTION);
2458 result = FUNC(remainder) (1.625, 1.0);
2459 check ("remainder(1.625, 1.0) == -0.375", result, -0.375);
2461 result = FUNC(remainder) (-1.625, 1.0);
2462 check ("remainder(-1.625, 1.0) == 0.375", result, 0.375);
2464 result = FUNC(remainder) (1.625, -1.0);
2465 check ("remainder(1.625, -1.0) == -0.375", result, -0.375);
2467 result = FUNC(remainder) (-1.625, -1.0);
2468 check ("remainder(-1.625, -1.0) == 0.375", result, 0.375);
2470 result = FUNC(remainder) (5.0, 2.0);
2471 check ("remainder(5.0, 2.0) == 1.0", result, 1.0);
2473 result = FUNC(remainder) (3.0, 2.0);
2474 check ("remainder(3.0, 2.0) == -1.0", result, -1.0);
2484 result = FUNC(remquo) (1, 0, &quo);
2485 check_isnan_exc ("remquo(1, +0, &x) == NaN plus invalid exception",
2486 result, INVALID_EXCEPTION);
2488 result = FUNC(remquo) (1, minus_zero, &quo);
2489 check_isnan_exc ("remquo(1, -0, &x) == NaN plus invalid exception",
2490 result, INVALID_EXCEPTION);
2492 result = FUNC(remquo) (plus_infty, 1, &quo);
2493 check_isnan_exc ("remquo(+inf, 1, &x) == NaN plus invalid exception",
2494 result, INVALID_EXCEPTION);
2496 result = FUNC(remquo) (minus_infty, 1, &quo);
2497 check_isnan_exc ("remquo(-inf, 1, &x) == NaN plus invalid exception",
2498 result, INVALID_EXCEPTION);
2500 result = FUNC(remquo) (1.625, 1.0, &quo);
2501 check ("remquo(1.625, 1.0, &x) == -0.375", result, -0.375);
2502 check_long ("remquo(1.625, 1.0, &x) puts 2 in x", quo, 2);
2504 result = FUNC(remquo) (-1.625, 1.0, &quo);
2505 check ("remquo(-1.625, 1.0, &x) == 0.375", result, 0.375);
2506 check_long ("remquo(-1.625, 1.0, &x) puts -2 in x", quo, -2);
2508 result = FUNC(remquo) (1.625, -1.0, &quo);
2509 check ("remquo(1.625, -1.0, &x) == -0.375", result, -0.375);
2510 check_long ("remquo(1.625, -1.0, &x) puts -2 in x", quo, -2);
2512 result = FUNC(remquo) (-1.625, -1.0, &quo);
2513 check ("remquo(-1.625, -1.0, &x) == 0.375", result, 0.375);
2514 check_long ("remquo(-1.625, -1.0, &x) puts 2 in x", quo, 2);
2516 result = FUNC(remquo) (5.0, 2.0, &quo);
2517 check ("remquo(5.0, 2.0, &x) == 1.0", result, 1.0);
2518 check_long ("remquo (5.0, 2.0, &x) puts 2 in x", quo, 2);
2520 result = FUNC(remquo) (3.0, 2.0, &quo);
2521 check ("remquo(3.0, 2.0, &x) == -1.0", result, -1.0);
2522 check_long ("remquo (3.0, 2.0, &x) puts 2 in x", quo, 2);
2529 __complex__ MATHTYPE result;
2531 result = FUNC(cexp) (BUILD_COMPLEX (plus_zero, plus_zero));
2532 check ("real(cexp(0 + 0i)) = 1", __real__ result, 1);
2533 check ("imag(cexp(0 + 0i)) = 0", __imag__ result, 0);
2534 result = FUNC(cexp) (BUILD_COMPLEX (minus_zero, plus_zero));
2535 check ("real(cexp(-0 + 0i)) = 1", __real__ result, 1);
2536 check ("imag(cexp(-0 + 0i)) = 0", __imag__ result, 0);
2537 result = FUNC(cexp) (BUILD_COMPLEX (plus_zero, minus_zero));
2538 check ("real(cexp(0 - 0i)) = 1", __real__ result, 1);
2539 check ("imag(cexp(0 - 0i)) = -0", __imag__ result, minus_zero);
2540 result = FUNC(cexp) (BUILD_COMPLEX (minus_zero, minus_zero));
2541 check ("real(cexp(-0 - 0i)) = 1", __real__ result, 1);
2542 check ("imag(cexp(-0 - 0i)) = -0", __imag__ result, minus_zero);
2544 result = FUNC(cexp) (BUILD_COMPLEX (plus_infty, plus_zero));
2545 check_isinfp ("real(cexp(+inf + 0i)) = +inf", __real__ result);
2546 check ("imag(cexp(+inf + 0i)) = 0", __imag__ result, 0);
2547 result = FUNC(cexp) (BUILD_COMPLEX (plus_infty, minus_zero));
2548 check_isinfp ("real(cexp(+inf - 0i)) = +inf", __real__ result);
2549 check ("imag(cexp(+inf - 0i)) = -0", __imag__ result, minus_zero);
2551 result = FUNC(cexp) (BUILD_COMPLEX (minus_infty, plus_zero));
2552 check ("real(cexp(-inf + 0i)) = 0", __real__ result, 0);
2553 check ("imag(cexp(-inf + 0i)) = 0", __imag__ result, 0);
2554 result = FUNC(cexp) (BUILD_COMPLEX (minus_infty, minus_zero));
2555 check ("real(cexp(-inf - 0i)) = 0", __real__ result, 0);
2556 check ("imag(cexp(-inf - 0i)) = -0", __imag__ result, minus_zero);
2559 result = FUNC(cexp) (BUILD_COMPLEX (0.0, plus_infty));
2560 check_isnan_exc ("real(cexp(0 + i inf)) = NaN plus invalid exception",
2561 __real__ result, INVALID_EXCEPTION);
2562 check_isnan ("imag(cexp(0 + i inf)) = NaN plus invalid exception",
2565 result = FUNC(cexp) (BUILD_COMPLEX (minus_zero, plus_infty));
2566 check_isnan_exc ("real(cexp(-0 + i inf)) = NaN plus invalid exception",
2567 __real__ result, INVALID_EXCEPTION);
2568 check_isnan ("imag(cexp(-0 + i inf)) = NaN plus invalid exception",
2570 result = FUNC(cexp) (BUILD_COMPLEX (0.0, minus_infty));
2571 check_isnan_exc ("real(cexp(0 - i inf)) = NaN plus invalid exception",
2572 __real__ result, INVALID_EXCEPTION);
2573 check_isnan ("imag(cexp(0 - i inf)) = NaN plus invalid exception",
2575 result = FUNC(cexp) (BUILD_COMPLEX (minus_zero, minus_infty));
2576 check_isnan_exc ("real(cexp(-0 - i inf)) = NaN plus invalid exception",
2577 __real__ result, INVALID_EXCEPTION);
2578 check_isnan ("imag(cexp(-0 - i inf)) = NaN plus invalid exception",
2581 result = FUNC(cexp) (BUILD_COMPLEX (100.0, plus_infty));
2582 check_isnan_exc ("real(cexp(100.0 + i inf)) = NaN plus invalid exception",
2583 __real__ result, INVALID_EXCEPTION);
2584 check_isnan ("imag(cexp(100.0 + i inf)) = NaN plus invalid exception",
2586 result = FUNC(cexp) (BUILD_COMPLEX (-100.0, plus_infty));
2587 check_isnan_exc ("real(cexp(-100.0 + i inf)) = NaN plus invalid exception",
2588 __real__ result, INVALID_EXCEPTION);
2589 check_isnan ("imag(cexp(-100.0 + i inf)) = NaN plus invalid exception",
2591 result = FUNC(cexp) (BUILD_COMPLEX (100.0, minus_infty));
2592 check_isnan_exc ("real(cexp(100.0 - i inf)) = NaN plus invalid exception",
2593 __real__ result, INVALID_EXCEPTION);
2594 check_isnan ("imag(cexp(100.0 - i inf)) = NaN plus invalid exception",
2596 result = FUNC(cexp) (BUILD_COMPLEX (-100.0, minus_infty));
2597 check_isnan_exc ("real(cexp(-100.0 - i inf)) = NaN plus invalid exception",
2598 __real__ result, INVALID_EXCEPTION);
2599 check_isnan ("imag(cexp(-100.0 - i inf)) = NaN", __imag__ result);
2601 result = FUNC(cexp) (BUILD_COMPLEX (minus_infty, 2.0));
2602 check ("real(cexp(-inf + 2.0i)) = -0", __real__ result, minus_zero);
2603 check ("imag(cexp(-inf + 2.0i)) = 0", __imag__ result, 0);
2604 result = FUNC(cexp) (BUILD_COMPLEX (minus_infty, 4.0));
2605 check ("real(cexp(-inf + 4.0i)) = -0", __real__ result, minus_zero);
2606 check ("imag(cexp(-inf + 4.0i)) = -0", __imag__ result, minus_zero);
2608 result = FUNC(cexp) (BUILD_COMPLEX (plus_infty, 2.0));
2609 check_isinfn ("real(cexp(+inf + 2.0i)) = -inf", __real__ result);
2610 check_isinfp ("imag(cexp(+inf + 2.0i)) = +inf", __imag__ result);
2611 result = FUNC(cexp) (BUILD_COMPLEX (plus_infty, 4.0));
2612 check_isinfn ("real(cexp(+inf + 4.0i)) = -inf", __real__ result);
2613 check_isinfn ("imag(cexp(+inf + 4.0i)) = -inf", __imag__ result);
2615 result = FUNC(cexp) (BUILD_COMPLEX (plus_infty, plus_infty));
2616 check_isinfp_exc ("real(cexp(+inf + i inf)) = +inf plus invalid exception",
2617 __real__ result, INVALID_EXCEPTION);
2618 check_isnan ("imag(cexp(+inf + i inf)) = NaN plus invalid exception",
2620 result = FUNC(cexp) (BUILD_COMPLEX (plus_infty, minus_infty));
2621 check_isinfp_exc ("real(cexp(+inf - i inf)) = +inf plus invalid exception",
2622 __real__ result, INVALID_EXCEPTION);
2623 check_isnan ("imag(cexp(+inf - i inf)) = NaN plus invalid exception",
2626 result = FUNC(cexp) (BUILD_COMPLEX (minus_infty, plus_infty));
2627 check ("real(cexp(-inf + i inf)) = 0", __real__ result, 0);
2628 check ("imag(cexp(-inf + i inf)) = 0", __imag__ result, 0);
2629 result = FUNC(cexp) (BUILD_COMPLEX (minus_infty, minus_infty));
2630 check ("real(cexp(-inf - i inf)) = 0", __real__ result, 0);
2631 check ("imag(cexp(-inf - i inf)) = -0", __imag__ result, minus_zero);
2633 result = FUNC(cexp) (BUILD_COMPLEX (minus_infty, nan_value));
2634 check ("real(cexp(-inf + i NaN)) = 0", __real__ result, 0);
2635 check ("imag(cexp(-inf + i NaN)) = 0", fabs (__imag__ result), 0);
2637 result = FUNC(cexp) (BUILD_COMPLEX (plus_infty, nan_value));
2638 check_isinfp ("real(cexp(+inf + i NaN)) = +inf", __real__ result);
2639 check_isnan ("imag(cexp(+inf + i NaN)) = NaN", __imag__ result);
2641 result = FUNC(cexp) (BUILD_COMPLEX (nan_value, 0.0));
2642 check_isnan_maybe_exc ("real(cexp(NaN + i0)) = NaN plus maybe invalid exception",
2643 __real__ result, INVALID_EXCEPTION);
2644 check_isnan ("imag(cexp(NaN + i0)) = NaN plus maybe invalid exception",
2646 result = FUNC(cexp) (BUILD_COMPLEX (nan_value, 1.0));
2647 check_isnan_maybe_exc ("real(cexp(NaN + 1i)) = NaN plus maybe invalid exception",
2648 __real__ result, INVALID_EXCEPTION);
2649 check_isnan ("imag(cexp(NaN + 1i)) = NaN plus maybe invalid exception",
2651 result = FUNC(cexp) (BUILD_COMPLEX (nan_value, plus_infty));
2652 check_isnan_maybe_exc ("real(cexp(NaN + i inf)) = NaN plus maybe invalid exception",
2653 __real__ result, INVALID_EXCEPTION);
2654 check_isnan ("imag(cexp(NaN + i inf)) = NaN plus maybe invalid exception",
2657 result = FUNC(cexp) (BUILD_COMPLEX (0, nan_value));
2658 check_isnan_maybe_exc ("real(cexp(0 + i NaN)) = NaN plus maybe invalid exception",
2659 __real__ result, INVALID_EXCEPTION);
2660 check_isnan ("imag(cexp(0 + i NaN)) = NaN plus maybe invalid exception",
2662 result = FUNC(cexp) (BUILD_COMPLEX (1, nan_value));
2663 check_isnan_maybe_exc ("real(cexp(1 + i NaN)) = NaN plus maybe invalid exception",
2664 __real__ result, INVALID_EXCEPTION);
2665 check_isnan ("imag(cexp(1 + i NaN)) = NaN plus maybe invalid exception",
2668 result = FUNC(cexp) (BUILD_COMPLEX (nan_value, nan_value));
2669 check_isnan ("real(cexp(NaN + i NaN)) = NaN", __real__ result);
2670 check_isnan ("imag(cexp(NaN + i NaN)) = NaN", __imag__ result);
2672 result = FUNC(cexp) (BUILD_COMPLEX (0.7, 1.2));
2673 check_eps ("real(cexp(0.7 + i 1.2)) == 0.72969...", __real__ result,
2674 0.7296989091503236012L, CHOOSE (6e-17L, 2e-16, 2e-7));
2675 check_eps ("imag(cexp(0.7 + i 1.2)) == 1.87689...", __imag__ result,
2676 1.8768962328348102821L, CHOOSE (2e-16L, 4.5e-16, 3e-7));
2678 result = FUNC(cexp) (BUILD_COMPLEX (-2, -3));
2679 check_eps ("real(cexp(-2 - i 3)) == -0.13398...", __real__ result,
2680 -0.1339809149295426134L, CHOOSE (6.8e-20L, 2.8e-17, 2e-8));
2681 check_eps ("imag(cexp(-2 - i 3)) == -0.01909...", __imag__ result,
2682 -0.0190985162611351964L, CHOOSE (4e-20L, 3.5e-18, 2e-9));
2689 __complex__ MATHTYPE result;
2691 result = FUNC(csin) (BUILD_COMPLEX (0.0, 0.0));
2692 check ("real(csin(0 + 0i)) = 0", __real__ result, 0);
2693 check ("imag(csin(0 + 0i)) = 0", __imag__ result, 0);
2694 result = FUNC(csin) (BUILD_COMPLEX (minus_zero, 0.0));
2695 check ("real(csin(-0 + 0i)) = -0", __real__ result, minus_zero);
2696 check ("imag(csin(-0 + 0i)) = 0", __imag__ result, 0);
2697 result = FUNC(csin) (BUILD_COMPLEX (0.0, minus_zero));
2698 check ("real(csin(0 - 0i)) = 0", __real__ result, 0);
2699 check ("imag(csin(0 - 0i)) = -0", __imag__ result, minus_zero);
2700 result = FUNC(csin) (BUILD_COMPLEX (minus_zero, minus_zero));
2701 check ("real(csin(-0 - 0i)) = -0", __real__ result, minus_zero);
2702 check ("imag(csin(-0 - 0i)) = -0", __imag__ result, minus_zero);
2704 result = FUNC(csin) (BUILD_COMPLEX (0.0, plus_infty));
2705 check ("real(csin(0 + i Inf)) = 0", __real__ result, 0);
2706 check_isinfp ("imag(csin(0 + i Inf)) = +Inf", __imag__ result);
2707 result = FUNC(csin) (BUILD_COMPLEX (minus_zero, plus_infty));
2708 check ("real(csin(-0 + i Inf)) = -0", __real__ result, minus_zero);
2709 check_isinfp ("imag(csin(-0 + i Inf)) = +Inf", __imag__ result);
2710 result = FUNC(csin) (BUILD_COMPLEX (0.0, minus_infty));
2711 check ("real(csin(0 - i Inf)) = 0", __real__ result, 0);
2712 check_isinfn ("imag(csin(0 - i Inf)) = -Inf", __imag__ result);
2713 result = FUNC(csin) (BUILD_COMPLEX (minus_zero, minus_infty));
2714 check ("real(csin(-0 - i Inf)) = -0", __real__ result, minus_zero);
2715 check_isinfn ("imag(csin(-0 - i Inf)) = -Inf", __imag__ result);
2717 result = FUNC(csin) (BUILD_COMPLEX (plus_infty, 0.0));
2718 check_isnan_exc ("real(csin(+Inf + 0i)) = NaN plus invalid exception",
2719 __real__ result, INVALID_EXCEPTION);
2720 check ("imag(csin(+Inf + 0i)) = +-0 plus invalid exception",
2721 FUNC(fabs) (__imag__ result), 0);
2722 result = FUNC(csin) (BUILD_COMPLEX (minus_infty, 0.0));
2723 check_isnan_exc ("real(csin(-Inf + 0i)) = NaN plus invalid exception",
2724 __real__ result, INVALID_EXCEPTION);
2725 check ("imag(csin(-Inf + 0i)) = +-0 plus invalid exception",
2726 FUNC(fabs) (__imag__ result), 0);
2727 result = FUNC(csin) (BUILD_COMPLEX (plus_infty, minus_zero));
2728 check_isnan_exc ("real(csin(+Inf - 0i)) = NaN plus invalid exception",
2729 __real__ result, INVALID_EXCEPTION);
2730 check ("imag(csin(+Inf - 0i)) = +-0 plus invalid exception",
2731 FUNC(fabs) (__imag__ result), 0.0);
2732 result = FUNC(csin) (BUILD_COMPLEX (minus_infty, minus_zero));
2733 check_isnan_exc ("real(csin(-Inf - 0i)) = NaN plus invalid exception",
2734 __real__ result, INVALID_EXCEPTION);
2735 check ("imag(csin(-Inf - 0i)) = +-0 plus invalid exception",
2736 FUNC(fabs) (__imag__ result), 0.0);
2738 result = FUNC(csin) (BUILD_COMPLEX (plus_infty, plus_infty));
2739 check_isnan_exc ("real(csin(+Inf + i Inf)) = NaN plus invalid exception",
2740 __real__ result, INVALID_EXCEPTION);
2741 check_isinfp ("imag(csin(+Inf + i Inf)) = +-Inf plus invalid exception",
2742 FUNC(fabs) (__imag__ result));
2743 result = FUNC(csin) (BUILD_COMPLEX (minus_infty, plus_infty));
2744 check_isnan_exc ("real(csin(-Inf + i Inf)) = NaN plus invalid exception",
2745 __real__ result, INVALID_EXCEPTION);
2746 check_isinfp ("imag(csin(-Inf + i Inf)) = +-Inf plus invalid exception",
2747 FUNC(fabs) (__imag__ result));
2748 result = FUNC(csin) (BUILD_COMPLEX (plus_infty, minus_infty));
2749 check_isnan_exc ("real(csin(Inf - i Inf)) = NaN plus invalid exception",
2750 __real__ result, INVALID_EXCEPTION);
2751 check_isinfp ("imag(csin(Inf - i Inf)) = +-Inf plus invalid exception",
2752 FUNC(fabs) (__imag__ result));
2753 result = FUNC(csin) (BUILD_COMPLEX (minus_infty, minus_infty));
2754 check_isnan_exc ("real(csin(-Inf - i Inf)) = NaN plus invalid exception",
2755 __real__ result, INVALID_EXCEPTION);
2756 check_isinfp ("imag(csin(-Inf - i Inf)) = +-Inf plus invalid exception",
2757 FUNC(fabs) (__imag__ result));
2759 result = FUNC(csin) (BUILD_COMPLEX (plus_infty, 6.75));
2760 check_isnan_exc ("real(csin(+Inf + i 6.75)) = NaN plus invalid exception",
2761 __real__ result, INVALID_EXCEPTION);
2762 check_isnan ("imag(csin(+Inf + i6.75)) = NaN plus invalid exception",
2764 result = FUNC(csin) (BUILD_COMPLEX (plus_infty, -6.75));
2765 check_isnan_exc ("real(csin(+Inf - i 6.75)) = NaN plus invalid exception",
2766 __real__ result, INVALID_EXCEPTION);
2767 check_isnan ("imag(csin(+Inf - i6.75)) = NaN plus invalid exception",
2769 result = FUNC(csin) (BUILD_COMPLEX (minus_infty, 6.75));
2770 check_isnan_exc ("real(csin(-Inf + i6.75)) = NaN plus invalid exception",
2771 __real__ result, INVALID_EXCEPTION);
2772 check_isnan ("imag(csin(-Inf + i6.75)) = NaN plus invalid exception",
2774 result = FUNC(csin) (BUILD_COMPLEX (minus_infty, -6.75));
2775 check_isnan_exc ("real(csin(-Inf - i6.75)) = NaN plus invalid exception",
2776 __real__ result, INVALID_EXCEPTION);
2777 check_isnan ("imag(csin(-Inf - i6.75)) = NaN plus invalid exception",
2780 result = FUNC(csin) (BUILD_COMPLEX (4.625, plus_infty));
2781 check_isinfn ("real(csin(4.625 + i Inf)) = -Inf", __real__ result);
2782 check_isinfn ("imag(csin(4.625 + i Inf)) = -Inf", __imag__ result);
2783 result = FUNC(csin) (BUILD_COMPLEX (4.625, minus_infty));
2784 check_isinfn ("real(csin(4.625 - i Inf)) = -Inf", __real__ result);
2785 check_isinfp ("imag(csin(4.625 - i Inf)) = +Inf", __imag__ result);
2786 result = FUNC(csin) (BUILD_COMPLEX (-4.625, plus_infty));
2787 check_isinfp ("real(csin(-4.625 + i Inf)) = +Inf", __real__ result);
2788 check_isinfn ("imag(csin(-4.625 + i Inf)) = -Inf", __imag__ result);
2789 result = FUNC(csin) (BUILD_COMPLEX (-4.625, minus_infty));
2790 check_isinfp ("real(csin(-4.625 - i Inf)) = +Inf", __real__ result);
2791 check_isinfp ("imag(csin(-4.625 - i Inf)) = +Inf", __imag__ result);
2793 result = FUNC(csin) (BUILD_COMPLEX (nan_value, 0.0));
2794 check_isnan ("real(csin(NaN + i0)) = NaN", __real__ result);
2795 check ("imag(csin(NaN + i0)) = +-0", FUNC(fabs) (__imag__ result), 0);
2796 result = FUNC(csin) (BUILD_COMPLEX (nan_value, minus_zero));
2797 check_isnan ("real(csin(NaN - i0)) = NaN", __real__ result);
2798 check ("imag(csin(NaN - i0)) = +-0", FUNC(fabs) (__imag__ result), 0);
2800 result = FUNC(csin) (BUILD_COMPLEX (nan_value, plus_infty));
2801 check_isnan ("real(csin(NaN + i Inf)) = NaN", __real__ result);
2802 check_isinfp ("imag(csin(NaN + i Inf)) = +-Inf",
2803 FUNC(fabs) (__imag__ result));
2804 result = FUNC(csin) (BUILD_COMPLEX (nan_value, minus_infty));
2805 check_isnan ("real(csin(NaN - i Inf)) = NaN", __real__ result);
2806 check_isinfp ("real(csin(NaN - i Inf)) = +-Inf",
2807 FUNC(fabs) (__imag__ result));
2809 result = FUNC(csin) (BUILD_COMPLEX (nan_value, 9.0));
2810 check_isnan_maybe_exc ("real(csin(NaN + i9.0)) = NaN plus maybe invalid exception",
2811 __real__ result, INVALID_EXCEPTION);
2812 check_isnan ("imag(csin(NaN + i9.0)) = NaN plus maybe invalid exception",
2814 result = FUNC(csin) (BUILD_COMPLEX (nan_value, -9.0));
2815 check_isnan_maybe_exc ("real(csin(NaN - i9.0)) = NaN plus maybe invalid exception",
2816 __real__ result, INVALID_EXCEPTION);
2817 check_isnan ("imag(csin(NaN - i9.0)) = NaN plus maybe invalid exception",
2820 result = FUNC(csin) (BUILD_COMPLEX (0.0, nan_value));
2821 check ("real(csin(0 + i NaN))", __real__ result, 0.0);
2822 check_isnan ("imag(csin(0 + i NaN)) = NaN", __imag__ result);
2823 result = FUNC(csin) (BUILD_COMPLEX (minus_zero, nan_value));
2824 check ("real(csin(-0 + i NaN)) = -0", __real__ result, minus_zero);
2825 check_isnan ("imag(csin(-0 + NaN)) = NaN", __imag__ result);
2827 result = FUNC(csin) (BUILD_COMPLEX (10.0, nan_value));
2828 check_isnan_maybe_exc ("real(csin(10 + i NaN)) = NaN plus maybe invalid exception",
2829 __real__ result, INVALID_EXCEPTION);
2830 check_isnan ("imag(csin(10 + i NaN)) = NaN plus maybe invalid exception",
2832 result = FUNC(csin) (BUILD_COMPLEX (nan_value, -10.0));
2833 check_isnan_maybe_exc ("real(csin(-10 + i NaN)) = NaN plus maybe invalid exception",
2834 __real__ result, INVALID_EXCEPTION);
2835 check_isnan ("imag(csin(-10 + i NaN)) = NaN plus maybe invalid exception",
2838 result = FUNC(csin) (BUILD_COMPLEX (plus_infty, nan_value));
2839 check_isnan_maybe_exc ("real(csin(+Inf + i NaN)) = NaN plus maybe invalid exception",
2840 __real__ result, INVALID_EXCEPTION);
2841 check_isnan ("imag(csin(+Inf + i NaN)) = NaN plus maybe invalid exception",
2843 result = FUNC(csin) (BUILD_COMPLEX (minus_infty, nan_value));
2844 check_isnan_maybe_exc ("real(csin(-Inf + i NaN)) = NaN plus maybe invalid exception",
2845 __real__ result, INVALID_EXCEPTION);
2846 check_isnan ("imag(csin(-Inf + i NaN)) = NaN plus maybe invalid exception",
2849 result = FUNC(csin) (BUILD_COMPLEX (nan_value, nan_value));
2850 check_isnan ("real(csin(NaN + i NaN)) = NaN", __real__ result);
2851 check_isnan ("imag(csin(NaN + i NaN)) = NaN", __imag__ result);
2853 result = FUNC(csin) (BUILD_COMPLEX (0.7, 1.2));
2854 check_eps ("real(csin(0.7 + i 1.2)) = 1.166456341...", __real__ result,
2855 1.1664563419657581376L, CHOOSE (2e-16L, 2.3e-16, 0));
2856 check_eps ("imag(csin(0.7 + i 1.2)) = 1.154499724...", __imag__ result,
2857 1.1544997246948547371L, CHOOSE (2e-17L, 0, 2e-7));
2859 result = FUNC(csin) (BUILD_COMPLEX (-2, -3));
2860 check_eps ("real(csin(-2 - i 3)) == -9.15449...", __real__ result,
2861 -9.1544991469114295734L, CHOOSE (4e-18L, 1.8e-15, 1e-6));
2862 check_eps ("imag(csin(-2 - i 3)) == -4.16890...", __imag__ result,
2863 4.1689069599665643507L, CHOOSE (2e-17L, 0, 5e-7));
2870 __complex__ MATHTYPE result;
2872 result = FUNC(csinh) (BUILD_COMPLEX (0.0, 0.0));
2873 check ("real(csinh(0 + 0i)) = 0", __real__ result, 0);
2874 check ("imag(csinh(0 + 0i)) = 0", __imag__ result, 0);
2875 result = FUNC(csinh) (BUILD_COMPLEX (minus_zero, 0.0));
2876 check ("real(csinh(-0 + 0i)) = -0", __real__ result, minus_zero);
2877 check ("imag(csinh(-0 + 0i)) = 0", __imag__ result, 0);
2878 result = FUNC(csinh) (BUILD_COMPLEX (0.0, minus_zero));
2879 check ("real(csinh(0 - 0i)) = 0", __real__ result, 0);
2880 check ("imag(csinh(0 - 0i)) = -0", __imag__ result, minus_zero);
2881 result = FUNC(csinh) (BUILD_COMPLEX (minus_zero, minus_zero));
2882 check ("real(csinh(-0 - 0i)) = -0", __real__ result, minus_zero);
2883 check ("imag(csinh(-0 - 0i)) = -0", __imag__ result, minus_zero);
2885 result = FUNC(csinh) (BUILD_COMPLEX (0.0, plus_infty));
2886 check_exc ("real(csinh(0 + i Inf)) = +-0 plus invalid exception",
2887 FUNC(fabs) (__real__ result), 0, INVALID_EXCEPTION);
2888 check_isnan ("imag(csinh(0 + i Inf)) = NaN plus invalid exception",
2890 result = FUNC(csinh) (BUILD_COMPLEX (minus_zero, plus_infty));
2891 check_exc ("real(csinh(-0 + i Inf)) = +-0 plus invalid exception",
2892 FUNC(fabs) (__real__ result), 0, INVALID_EXCEPTION);
2893 check_isnan ("imag(csinh(-0 + i Inf)) = NaN plus invalid exception",
2895 result = FUNC(csinh) (BUILD_COMPLEX (0.0, minus_infty));
2896 check_exc ("real(csinh(0 - i Inf)) = +-0 plus invalid exception",
2897 FUNC(fabs) (__real__ result), 0, INVALID_EXCEPTION);
2898 check_isnan ("imag(csinh(0 - i Inf)) = NaN plus invalid exception",
2900 result = FUNC(csinh) (BUILD_COMPLEX (minus_zero, minus_infty));
2901 check_exc ("real(csinh(-0 - i Inf)) = +-0 plus invalid exception",
2902 FUNC(fabs) (__real__ result), 0, INVALID_EXCEPTION);
2903 check_isnan ("imag(csinh(-0 - i Inf)) = NaN plus invalid exception",
2906 result = FUNC(csinh) (BUILD_COMPLEX (plus_infty, 0.0));
2907 check_isinfp ("real(csinh(+Inf + 0i)) = +Inf", __real__ result);
2908 check ("imag(csinh(+Inf + 0i)) = 0", __imag__ result, 0);
2909 result = FUNC(csinh) (BUILD_COMPLEX (minus_infty, 0.0));
2910 check_isinfn ("real(csinh(-Inf + 0i)) = -Inf", __real__ result);
2911 check ("imag(csinh(-Inf + 0i)) = 0", __imag__ result, 0);
2912 result = FUNC(csinh) (BUILD_COMPLEX (plus_infty, minus_zero));
2913 check_isinfp ("real(csinh(+Inf - 0i)) = +Inf", __real__ result);
2914 check ("imag(csinh(+Inf - 0i)) = -0", __imag__ result, minus_zero);
2915 result = FUNC(csinh) (BUILD_COMPLEX (minus_infty, minus_zero));
2916 check_isinfn ("real(csinh(-Inf - 0i)) = -Inf", __real__ result);
2917 check ("imag(csinh(-Inf - 0i)) = -0", __imag__ result, minus_zero);
2919 result = FUNC(csinh) (BUILD_COMPLEX (plus_infty, plus_infty));
2920 check_isinfp_exc ("real(csinh(+Inf + i Inf)) = +-Inf plus invalid exception",
2921 FUNC(fabs) (__real__ result), INVALID_EXCEPTION);
2922 check_isnan ("imag(csinh(+Inf + i Inf)) = NaN plus invalid exception",
2924 result = FUNC(csinh) (BUILD_COMPLEX (minus_infty, plus_infty));
2925 check_isinfp_exc ("real(csinh(-Inf + i Inf)) = +-Inf plus invalid exception",
2926 FUNC(fabs) (__real__ result), INVALID_EXCEPTION);
2927 check_isnan ("imag(csinh(-Inf + i Inf)) = NaN plus invalid exception",
2929 result = FUNC(csinh) (BUILD_COMPLEX (plus_infty, minus_infty));
2930 check_isinfp_exc ("real(csinh(Inf - i Inf)) = +-Inf plus invalid exception",
2931 FUNC(fabs) (__real__ result), INVALID_EXCEPTION);
2932 check_isnan ("imag(csinh(Inf - i Inf)) = NaN plus invalid exception",
2934 result = FUNC(csinh) (BUILD_COMPLEX (minus_infty, minus_infty));
2935 check_isinfp_exc ("real(csinh(-Inf - i Inf)) = +-Inf plus invalid exception",
2936 FUNC(fabs) (__real__ result), INVALID_EXCEPTION);
2937 check_isnan ("imag(csinh(-Inf - i Inf)) = NaN plus invalid exception",
2940 result = FUNC(csinh) (BUILD_COMPLEX (plus_infty, 4.625));
2941 check_isinfn ("real(csinh(+Inf + i4.625)) = -Inf", __real__ result);
2942 check_isinfn ("imag(csinh(+Inf + i4.625)) = -Inf", __imag__ result);
2943 result = FUNC(csinh) (BUILD_COMPLEX (minus_infty, 4.625));
2944 check_isinfp ("real(csinh(-Inf + i4.625)) = +Inf", __real__ result);
2945 check_isinfn ("imag(csinh(-Inf + i4.625)) = -Inf", __imag__ result);
2946 result = FUNC(csinh) (BUILD_COMPLEX (plus_infty, -4.625));
2947 check_isinfn ("real(csinh(+Inf - i4.625)) = -Inf", __real__ result);
2948 check_isinfp ("imag(csinh(+Inf - i4.625)) = +Inf", __imag__ result);
2949 result = FUNC(csinh) (BUILD_COMPLEX (minus_infty, -4.625));
2950 check_isinfp ("real(csinh(-Inf - i4.625)) = +Inf", __real__ result);
2951 check_isinfp ("imag(csinh(-Inf - i4.625)) = +Inf", __imag__ result);
2953 result = FUNC(csinh) (BUILD_COMPLEX (6.75, plus_infty));
2954 check_isnan_exc ("real(csinh(6.75 + i Inf)) = NaN plus invalid exception",
2955 __real__ result, INVALID_EXCEPTION);
2956 check_isnan ("imag(csinh(6.75 + i Inf)) = NaN plus invalid exception",
2958 result = FUNC(csinh) (BUILD_COMPLEX (-6.75, plus_infty));
2959 check_isnan_exc ("real(csinh(-6.75 + i Inf)) = NaN plus invalid exception",
2960 __real__ result, INVALID_EXCEPTION);
2961 check_isnan ("imag(csinh(-6.75 + i Inf)) = NaN plus invalid exception",
2963 result = FUNC(csinh) (BUILD_COMPLEX (6.75, minus_infty));
2964 check_isnan_exc ("real(csinh(6.75 - i Inf)) = NaN plus invalid exception",
2965 __real__ result, INVALID_EXCEPTION);
2966 check_isnan ("imag(csinh(6.75 - i Inf)) = NaN plus invalid exception",
2968 result = FUNC(csinh) (BUILD_COMPLEX (-6.75, minus_infty));
2969 check_isnan_exc ("real(csinh(-6.75 - i Inf)) = NaN plus invalid exception",
2970 __real__ result, INVALID_EXCEPTION);
2971 check_isnan ("imag(csinh(-6.75 - i Inf)) = NaN plus invalid exception",
2974 result = FUNC(csinh) (BUILD_COMPLEX (0.0, nan_value));
2975 check ("real(csinh(0 + i NaN)) = +-0", FUNC(fabs) (__real__ result), 0);
2976 check_isnan ("imag(csinh(0 + i NaN)) = NaN", __imag__ result);
2977 result = FUNC(csinh) (BUILD_COMPLEX (minus_zero, nan_value));
2978 check ("real(csinh(-0 + i NaN)) = +-0", FUNC(fabs) (__real__ result), 0);
2979 check_isnan ("imag(csinh(-0 + i NaN)) = NaN", __imag__ result);
2981 result = FUNC(csinh) (BUILD_COMPLEX (plus_infty, nan_value));
2982 check_isinfp ("real(csinh(+Inf + i NaN)) = +-Inf",
2983 FUNC(fabs) (__real__ result));
2984 check_isnan ("imag(csinh(+Inf + i NaN)) = NaN", __imag__ result);
2985 result = FUNC(csinh) (BUILD_COMPLEX (minus_infty, nan_value));
2986 check_isinfp ("real(csinh(-Inf + i NaN)) = +-Inf",
2987 FUNC(fabs) (__real__ result));
2988 check_isnan ("imag(csinh(-Inf + i NaN)) = NaN", __imag__ result);
2990 result = FUNC(csinh) (BUILD_COMPLEX (9.0, nan_value));
2991 check_isnan_maybe_exc ("real(csinh(9.0 + i NaN)) = NaN plus maybe invalid exception",
2992 __real__ result, INVALID_EXCEPTION);
2993 check_isnan ("imag(csinh(9.0 + i NaN)) = NaN plus maybe invalid exception",
2995 result = FUNC(csinh) (BUILD_COMPLEX (-9.0, nan_value));
2996 check_isnan_maybe_exc ("real(csinh(-9.0 + i NaN)) = NaN plus maybe invalid exception",
2997 __real__ result, INVALID_EXCEPTION);
2998 check_isnan ("imag(csinh(-9.0 + i NaN)) = NaN plus maybe invalid exception",
3001 result = FUNC(csinh) (BUILD_COMPLEX (nan_value, 0.0));
3002 check_isnan ("real(csinh(NaN + i0)) = NaN", __real__ result);
3003 check ("imag(csinh(NaN + i0)) = 0", __imag__ result, 0.0);
3004 result = FUNC(csinh) (BUILD_COMPLEX (nan_value, minus_zero));
3005 check_isnan ("real(csinh(NaN - i0)) = NaN", __real__ result);
3006 check ("imag(csinh(NaN - i0)) = -0", __imag__ result, minus_zero);
3008 result = FUNC(csinh) (BUILD_COMPLEX (nan_value, 10.0));
3009 check_isnan_maybe_exc ("real(csinh(NaN + i10)) = NaN plus maybe invalid exception",
3010 __real__ result, INVALID_EXCEPTION);
3011 check_isnan ("imag(csinh(NaN + i10)) = NaN plus maybe invalid exception",
3013 result = FUNC(csinh) (BUILD_COMPLEX (nan_value, -10.0));
3014 check_isnan_maybe_exc ("real(csinh(NaN - i10)) = NaN plus maybe invalid exception",
3015 __real__ result, INVALID_EXCEPTION);
3016 check_isnan ("imag(csinh(NaN - i10)) = NaN plus maybe invalid exception",
3019 result = FUNC(csinh) (BUILD_COMPLEX (nan_value, plus_infty));
3020 check_isnan_maybe_exc ("real(csinh(NaN + i Inf)) = NaN plus maybe invalid exception",
3021 __real__ result, INVALID_EXCEPTION);
3022 check_isnan ("imag(csinh(NaN + i Inf)) = NaN plus maybe invalid exception",
3024 result = FUNC(csinh) (BUILD_COMPLEX (nan_value, minus_infty));
3025 check_isnan_maybe_exc ("real(csinh(NaN - i Inf)) = NaN plus maybe invalid exception",
3026 __real__ result, INVALID_EXCEPTION);
3027 check_isnan ("imag(csinh(NaN - i Inf)) = NaN plus maybe invalid exception",
3030 result = FUNC(csinh) (BUILD_COMPLEX (nan_value, nan_value));
3031 check_isnan ("real(csinh(NaN + i NaN)) = NaN", __real__ result);
3032 check_isnan ("imag(csinh(NaN + i NaN)) = NaN", __imag__ result);
3034 result = FUNC(csinh) (BUILD_COMPLEX (0.7, 1.2));
3035 check_eps ("real(csinh(0.7 + i 1.2)) = 0.274878686...", __real__ result,
3036 0.27487868678117583582L, CHOOSE (2e-17L, 6e-17, 3e-8));
3037 check_eps ("imag(csinh(0.7 + i 1.2)) = 1.169866572...", __imag__ result,
3038 1.1698665727426565139L, CHOOSE (6e-17L, 2.3e-16, 2e-7));
3040 result = FUNC(csinh) (BUILD_COMPLEX (-2, -3));
3041 check_eps ("real(csinh(-2 - i 3)) == -3.59056...", __real__ result,
3042 3.5905645899857799520L, CHOOSE (7e-19L, 5e-16, 3e-7));
3043 check_eps ("imag(csinh(-2 - i 3)) == -0.53092...", __imag__ result,
3044 -0.5309210862485198052L, CHOOSE (3e-19L, 2e-16, 6e-8));
3051 __complex__ MATHTYPE result;
3053 result = FUNC(ccos) (BUILD_COMPLEX (0.0, 0.0));
3054 check ("real(ccos(0 + 0i)) = 1.0", __real__ result, 1.0);
3055 check ("imag(ccos(0 + 0i)) = -0", __imag__ result, minus_zero);
3056 result = FUNC(ccos) (BUILD_COMPLEX (minus_zero, 0.0));
3057 check ("real(ccos(-0 + 0i)) = 1.0", __real__ result, 1.0);
3058 check ("imag(ccos(-0 + 0i)) = 0", __imag__ result, 0.0);
3059 result = FUNC(ccos) (BUILD_COMPLEX (0.0, minus_zero));
3060 check ("real(ccos(0 - 0i)) = 1.0", __real__ result, 1.0);
3061 check ("imag(ccos(0 - 0i)) = 0", __imag__ result, 0.0);
3062 result = FUNC(ccos) (BUILD_COMPLEX (minus_zero, minus_zero));
3063 check ("real(ccos(-0 - 0i)) = 1.0", __real__ result, 1.0);
3064 check ("imag(ccos(-0 - 0i)) = -0", __imag__ result, minus_zero);
3066 result = FUNC(ccos) (BUILD_COMPLEX (plus_infty, 0.0));
3067 check_isnan_exc ("real(ccos(+Inf + i0)) = NaN plus invalid exception",
3068 __real__ result, INVALID_EXCEPTION);
3069 check ("imag(ccos(Inf + i0)) = +-0 plus invalid exception",
3070 FUNC(fabs) (__imag__ result), 0);
3071 result = FUNC(ccos) (BUILD_COMPLEX (plus_infty, minus_zero));
3072 check_isnan_exc ("real(ccos(Inf - i0)) = NaN plus invalid exception",
3073 __real__ result, INVALID_EXCEPTION);
3074 check ("imag(ccos(Inf - i0)) = +-0 plus invalid exception",
3075 FUNC(fabs) (__imag__ result), 0);
3076 result = FUNC(ccos) (BUILD_COMPLEX (minus_infty, 0.0));
3077 check_isnan_exc ("real(ccos(-Inf + i0)) = NaN plus invalid exception",
3078 __real__ result, INVALID_EXCEPTION);
3079 check ("imag(ccos(-Inf + i0)) = +-0 plus invalid exception",
3080 FUNC(fabs) (__imag__ result), 0);
3081 result = FUNC(ccos) (BUILD_COMPLEX (minus_infty, minus_zero));
3082 check_isnan_exc ("real(ccos(-Inf - i0)) = NaN plus invalid exception",
3083 __real__ result, INVALID_EXCEPTION);
3084 check ("imag(ccos(-Inf - i0)) = +-0 plus invalid exception",
3085 FUNC(fabs) (__imag__ result), 0);
3087 result = FUNC(ccos) (BUILD_COMPLEX (0.0, plus_infty));
3088 check_isinfp ("real(ccos(0 + i Inf)) = +Inf", __real__ result);
3089 check ("imag(ccos(0 + i Inf)) = -0", __imag__ result, minus_zero);
3090 result = FUNC(ccos) (BUILD_COMPLEX (0.0, minus_infty));
3091 check_isinfp ("real(ccos(0 - i Inf)) = +Inf", __real__ result);
3092 check ("imag(ccos(0 - i Inf)) = 0", __imag__ result, 0);
3093 result = FUNC(ccos) (BUILD_COMPLEX (minus_zero, plus_infty));
3094 check_isinfp ("real(ccos(-0 + i Inf)) = +Inf", __real__ result);
3095 check ("imag(ccos(-0 + i Inf)) = 0", __imag__ result, 0.0);
3096 result = FUNC(ccos) (BUILD_COMPLEX (minus_zero, minus_infty));
3097 check_isinfp ("real(ccos(-0 - i Inf)) = +Inf", __real__ result);
3098 check ("imag(ccos(-0 - i Inf)) = -0", __imag__ result, minus_zero);
3100 result = FUNC(ccos) (BUILD_COMPLEX (plus_infty, plus_infty));
3101 check_isinfp_exc ("real(ccos(+Inf + i Inf)) = +Inf plus invalid exception",
3102 __real__ result, INVALID_EXCEPTION);
3103 check_isnan ("imag(ccos(+Inf + i Inf)) = NaN plus invalid exception",
3105 result = FUNC(ccos) (BUILD_COMPLEX (minus_infty, plus_infty));
3106 check_isinfp_exc ("real(ccos(-Inf + i Inf)) = +Inf plus invalid exception",
3107 __real__ result, INVALID_EXCEPTION);
3108 check_isnan ("imag(ccos(-Inf + i Inf)) = NaN plus invalid exception",
3110 result = FUNC(ccos) (BUILD_COMPLEX (plus_infty, minus_infty));
3111 check_isinfp_exc ("real(ccos(Inf - i Inf)) = +Inf plus invalid exception",
3112 __real__ result, INVALID_EXCEPTION);
3113 check_isnan ("imag(ccos(Inf - i Inf)) = NaN plus invalid exception",
3115 result = FUNC(ccos) (BUILD_COMPLEX (minus_infty, minus_infty));
3116 check_isinfp_exc ("real(ccos(-Inf - i Inf)) = +Inf plus invalid exception",
3117 __real__ result, INVALID_EXCEPTION);
3118 check_isnan ("imag(ccos(-Inf - i Inf)) = NaN plus invalid exception",
3121 result = FUNC(ccos) (BUILD_COMPLEX (4.625, plus_infty));
3122 check_isinfn ("real(ccos(4.625 + i Inf)) = -Inf", __real__ result);
3123 check_isinfp ("imag(ccos(4.625 + i Inf)) = +Inf", __imag__ result);
3124 result = FUNC(ccos) (BUILD_COMPLEX (4.625, minus_infty));
3125 check_isinfn ("real(ccos(4.625 - i Inf)) = -Inf", __real__ result);
3126 check_isinfn ("imag(ccos(4.625 - i Inf)) = -Inf", __imag__ result);
3127 result = FUNC(ccos) (BUILD_COMPLEX (-4.625, plus_infty));
3128 check_isinfn ("real(ccos(-4.625 + i Inf)) = -Inf", __real__ result);
3129 check_isinfn ("imag(ccos(-4.625 + i Inf)) = -Inf", __imag__ result);
3130 result = FUNC(ccos) (BUILD_COMPLEX (-4.625, minus_infty));
3131 check_isinfn ("real(ccos(-4.625 - i Inf)) = -Inf", __real__ result);
3132 check_isinfp ("imag(ccos(-4.625 - i Inf)) = +Inf", __imag__ result);
3134 result = FUNC(ccos) (BUILD_COMPLEX (plus_infty, 6.75));
3135 check_isnan_exc ("real(ccos(+Inf + i6.75)) = NaN plus invalid exception",
3136 __real__ result, INVALID_EXCEPTION);
3137 check_isnan ("imag(ccos(+Inf + i6.75)) = NaN plus invalid exception",
3139 result = FUNC(ccos) (BUILD_COMPLEX (plus_infty, -6.75));
3140 check_isnan_exc ("real(ccos(+Inf - i6.75)) = NaN plus invalid exception",
3141 __real__ result, INVALID_EXCEPTION);
3142 check_isnan ("imag(ccos(+Inf - i6.75)) = NaN plus invalid exception",
3144 result = FUNC(ccos) (BUILD_COMPLEX (minus_infty, 6.75));
3145 check_isnan_exc ("real(ccos(-Inf + i6.75)) = NaN plus invalid exception",
3146 __real__ result, INVALID_EXCEPTION);
3147 check_isnan ("imag(ccos(-Inf + i6.75)) = NaN plus invalid exception",
3149 result = FUNC(ccos) (BUILD_COMPLEX (minus_infty, -6.75));
3150 check_isnan_exc ("real(ccos(-Inf - i6.75)) = NaN plus invalid exception",
3151 __real__ result, INVALID_EXCEPTION);
3152 check_isnan ("imag(ccos(-Inf - i6.75)) = NaN plus invalid exception",
3155 result = FUNC(ccos) (BUILD_COMPLEX (nan_value, 0.0));
3156 check_isnan ("real(ccos(NaN + i0)) = NaN", __real__ result);
3157 check ("imag(ccos(NaN + i0)) = +-0", FUNC(fabs) (__imag__ result), 0);
3158 result = FUNC(ccos) (BUILD_COMPLEX (nan_value, minus_zero));
3159 check_isnan ("real(ccos(NaN - i0)) = NaN", __real__ result);
3160 check ("imag(ccos(NaN - i0)) = +-0", FUNC(fabs) (__imag__ result), 0);
3162 result = FUNC(ccos) (BUILD_COMPLEX (nan_value, plus_infty));
3163 check_isinfp ("real(ccos(NaN + i Inf)) = +Inf", __real__ result);
3164 check_isnan ("imag(ccos(NaN + i Inf)) = NaN", __imag__ result);
3165 result = FUNC(ccos) (BUILD_COMPLEX (nan_value, minus_infty));
3166 check_isinfp ("real(ccos(NaN - i Inf)) = +Inf", __real__ result);
3167 check_isnan ("imag(ccos(NaN - i Inf)) = NaN", __imag__ result);
3169 result = FUNC(ccos) (BUILD_COMPLEX (nan_value, 9.0));
3170 check_isnan_maybe_exc ("real(ccos(NaN + i9.0)) = NaN plus maybe invalid exception",
3171 __real__ result, INVALID_EXCEPTION);
3172 check_isnan ("imag(ccos(NaN + i9.0)) = NaN plus maybe invalid exception",
3174 result = FUNC(ccos) (BUILD_COMPLEX (nan_value, -9.0));
3175 check_isnan_maybe_exc ("real(ccos(NaN - i9.0)) = NaN plus maybe invalid exception",
3176 __real__ result, INVALID_EXCEPTION);
3177 check_isnan ("imag(ccos(NaN - i9.0)) = NaN plus maybe invalid exception",
3180 result = FUNC(ccos) (BUILD_COMPLEX (0.0, nan_value));
3181 check_isnan ("real(ccos(0 + i NaN)) = NaN", __real__ result);
3182 check ("imag(ccos(0 + i NaN)) = +-0", FUNC(fabs) (__imag__ result), 0.0);
3183 result = FUNC(ccos) (BUILD_COMPLEX (minus_zero, nan_value));
3184 check_isnan ("real(ccos(-0 + i NaN)) = NaN", __real__ result);
3185 check ("imag(ccos(-0 + i NaN)) = +-0", FUNC(fabs) (__imag__ result), 0.0);
3187 result = FUNC(ccos) (BUILD_COMPLEX (10.0, nan_value));
3188 check_isnan_maybe_exc ("real(ccos(10 + i NaN)) = NaN plus maybe invalid exception",
3189 __real__ result, INVALID_EXCEPTION);
3190 check_isnan ("imag(ccos(10 + i NaN)) = NaN plus maybe invalid exception",
3192 result = FUNC(ccos) (BUILD_COMPLEX (-10.0, nan_value));
3193 check_isnan_maybe_exc ("real(ccos(-10 + i NaN)) = NaN plus maybe invalid exception",
3194 __real__ result, INVALID_EXCEPTION);
3195 check_isnan ("imag(ccos(-10 + i NaN)) = NaN plus maybe invalid exception",
3198 result = FUNC(ccos) (BUILD_COMPLEX (plus_infty, nan_value));
3199 check_isnan_maybe_exc ("real(ccos(+Inf + i NaN)) = NaN plus maybe invalid exception",
3200 __real__ result, INVALID_EXCEPTION);
3201 check_isnan ("imag(ccos(+Inf + i NaN)) = NaN plus maybe invalid exception",
3203 result = FUNC(ccos) (BUILD_COMPLEX (minus_infty, nan_value));
3204 check_isnan_maybe_exc ("real(ccos(-Inf + i NaN)) = NaN plus maybe invalid exception",
3205 __real__ result, INVALID_EXCEPTION);
3206 check_isnan ("imag(ccos(-Inf + i NaN)) = NaN plus maybe invalid exception",
3209 result = FUNC(ccos) (BUILD_COMPLEX (nan_value, nan_value));
3210 check_isnan ("real(ccos(NaN + i NaN)) = NaN", __real__ result);
3211 check_isnan ("imag(ccos(NaN + i NaN)) = NaN", __imag__ result);
3213 result = FUNC(ccos) (BUILD_COMPLEX (0.7, 1.2));
3214 check_eps ("real(ccos(0.7 + i 1.2)) = 1.384865764...", __real__ result,
3215 1.3848657645312111080L, CHOOSE (4e-18L, 3e-16, 2e-7));
3216 check_eps ("imag(ccos(0.7 + i 1.2)) = -0.972421703...", __imag__ result,
3217 -0.97242170335830028619L, CHOOSE (2e-16L, 2e-16, 0));
3219 result = FUNC(ccos) (BUILD_COMPLEX (-2, -3));
3220 check_eps ("real(ccos(-2 - i 3)) == -4.18962...", __real__ result,
3221 -4.1896256909688072301L, CHOOSE (2e-17L, 8.9e-16, 5e-7));
3222 check_eps ("imag(ccos(-2 - i 3)) == -9.10922...", __imag__ result,
3223 -9.1092278937553365979L, CHOOSE (3e-18L, 0, 1e-6));
3230 __complex__ MATHTYPE result;
3232 result = FUNC(ccosh) (BUILD_COMPLEX (0.0, 0.0));
3233 check ("real(ccosh(0 + 0i)) = 1.0", __real__ result, 1.0);
3234 check ("imag(ccosh(0 + 0i)) = 0", __imag__ result, 0);
3235 result = FUNC(ccosh) (BUILD_COMPLEX (minus_zero, 0.0));
3236 check ("real(ccosh(-0 + 0i)) = 1.0", __real__ result, 1.0);
3237 check ("imag(ccosh(-0 + 0i)) = -0", __imag__ result, minus_zero);
3238 result = FUNC(ccosh) (BUILD_COMPLEX (0.0, minus_zero));
3239 check ("real(ccosh(0 - 0i)) = 1.0", __real__ result, 1.0);
3240 check ("imag(ccosh(0 - 0i)) = -0", __imag__ result, minus_zero);
3241 result = FUNC(ccosh) (BUILD_COMPLEX (minus_zero, minus_zero));
3242 check ("real(ccosh(-0 - 0i)) = 1.0", __real__ result, 1.0);
3243 check ("imag(ccosh(-0 - 0i)) = 0", __imag__ result, 0.0);
3245 result = FUNC(ccosh) (BUILD_COMPLEX (0.0, plus_infty));
3246 check_isnan_exc ("real(ccosh(0 + i Inf)) = NaN plus invalid exception",
3247 __real__ result, INVALID_EXCEPTION);
3248 check ("imag(ccosh(0 + i Inf)) = +-0 plus invalid exception",
3249 FUNC(fabs) (__imag__ result), 0);
3250 result = FUNC(ccosh) (BUILD_COMPLEX (minus_zero, plus_infty));
3251 check_isnan_exc ("real(ccosh(-0 + i Inf)) = NaN plus invalid exception",
3252 __real__ result, INVALID_EXCEPTION);
3253 check ("imag(ccosh(-0 + i Inf)) = +-0 plus invalid exception",
3254 FUNC(fabs) (__imag__ result), 0);
3255 result = FUNC(ccosh) (BUILD_COMPLEX (0.0, minus_infty));
3256 check_isnan_exc ("real(ccosh(0 - i Inf)) = NaN plus invalid exception",
3257 __real__ result, INVALID_EXCEPTION);
3258 check ("imag(ccosh(0 - i Inf)) = +-0 plus invalid exception",
3259 FUNC(fabs) (__imag__ result), 0);
3260 result = FUNC(ccosh) (BUILD_COMPLEX (minus_zero, minus_infty));
3261 check_isnan_exc ("real(ccosh(-0 - i Inf)) = NaN plus invalid exception",
3262 __real__ result, INVALID_EXCEPTION);
3263 check ("imag(ccosh(-0 - i Inf)) = +-0 plus invalid exception",
3264 FUNC(fabs) (__imag__ result), 0);
3266 result = FUNC(ccosh) (BUILD_COMPLEX (plus_infty, 0.0));
3267 check_isinfp ("real(ccosh(+Inf + 0i)) = +Inf", __real__ result);
3268 check ("imag(ccosh(+Inf + 0i)) = 0", __imag__ result, 0);
3269 result = FUNC(ccosh) (BUILD_COMPLEX (minus_infty, 0.0));
3270 check_isinfp ("real(ccosh(-Inf + 0i)) = +Inf", __real__ result);
3271 check ("imag(ccosh(-Inf + 0i)) = -0", __imag__ result, minus_zero);
3272 result = FUNC(ccosh) (BUILD_COMPLEX (plus_infty, minus_zero));
3273 check_isinfp ("real(ccosh(+Inf - 0i)) = +Inf", __real__ result);
3274 check ("imag(ccosh(+Inf - 0i)) = -0", __imag__ result, minus_zero);
3275 result = FUNC(ccosh) (BUILD_COMPLEX (minus_infty, minus_zero));
3276 check_isinfp ("real(ccosh(-Inf - 0i)) = +Inf", __real__ result);
3277 check ("imag(ccosh(-Inf - 0i)) = 0", __imag__ result, 0.0);
3279 result = FUNC(ccosh) (BUILD_COMPLEX (plus_infty, plus_infty));
3280 check_isinfp_exc ("real(ccosh(+Inf + i Inf)) = +Inf plus invalid exception",
3281 __real__ result, INVALID_EXCEPTION);
3282 check_isnan ("imag(ccosh(+Inf + i Inf)) = NaN plus invalid exception",
3284 result = FUNC(ccosh) (BUILD_COMPLEX (minus_infty, plus_infty));
3285 check_isinfp_exc ("real(ccosh(-Inf + i Inf)) = +Inf plus invalid exception",
3286 __real__ result, INVALID_EXCEPTION);
3287 check_isnan ("imag(ccosh(-Inf + i Inf)) = NaN plus invalid exception",
3289 result = FUNC(ccosh) (BUILD_COMPLEX (plus_infty, minus_infty));
3290 check_isinfp_exc ("real(ccosh(Inf - i Inf)) = +Inf plus invalid exception",
3291 __real__ result, INVALID_EXCEPTION);
3292 check_isnan ("imag(ccosh(Inf - i Inf)) = NaN plus invalid exception",
3294 result = FUNC(ccosh) (BUILD_COMPLEX (minus_infty, minus_infty));
3295 check_isinfp_exc ("real(ccosh(-Inf - i Inf)) = +Inf plus invalid exception",
3296 __real__ result, INVALID_EXCEPTION);
3297 check_isnan ("imag(ccosh(-Inf - i Inf)) = NaN plus invalid exception",
3300 result = FUNC(ccosh) (BUILD_COMPLEX (plus_infty, 4.625));
3301 check_isinfn ("real(ccosh(+Inf + i4.625)) = -Inf", __real__ result);
3302 check_isinfn ("imag(ccosh(+Inf + i4.625)) = -Inf", __imag__ result);
3303 result = FUNC(ccosh) (BUILD_COMPLEX (minus_infty, 4.625));
3304 check_isinfn ("real(ccosh(-Inf + i4.625)) = -Inf", __real__ result);
3305 check_isinfp ("imag(ccosh(-Inf + i4.625)) = Inf", __imag__ result);
3306 result = FUNC(ccosh) (BUILD_COMPLEX (plus_infty, -4.625));
3307 check_isinfn ("real(ccosh(+Inf - i4.625)) = -Inf", __real__ result);
3308 check_isinfp ("imag(ccosh(+Inf - i4.625)) = +Inf", __imag__ result);
3309 result = FUNC(ccosh) (BUILD_COMPLEX (minus_infty, -4.625));
3310 check_isinfn ("real(ccosh(-Inf - i4.625)) = -Inf", __real__ result);
3311 check_isinfn ("imag(ccosh(-Inf - i4.625)) = -Inf", __imag__ result);
3313 result = FUNC(ccosh) (BUILD_COMPLEX (6.75, plus_infty));
3314 check_isnan_exc ("real(ccosh(6.75 + i Inf)) = NaN plus invalid exception",
3315 __real__ result, INVALID_EXCEPTION);
3316 check_isnan ("imag(ccosh(6.75 + i Inf)) = NaN plus invalid exception",
3318 result = FUNC(ccosh) (BUILD_COMPLEX (-6.75, plus_infty));
3319 check_isnan_exc ("real(ccosh(-6.75 + i Inf)) = NaN plus invalid exception",
3320 __real__ result, INVALID_EXCEPTION);
3321 check_isnan ("imag(ccosh(-6.75 + i Inf)) = NaN plus invalid exception",
3323 result = FUNC(ccosh) (BUILD_COMPLEX (6.75, minus_infty));
3324 check_isnan_exc ("real(ccosh(6.75 - i Inf)) = NaN plus invalid exception",
3325 __real__ result, INVALID_EXCEPTION);
3326 check_isnan ("imag(ccosh(6.75 - i Inf)) = NaN plus invalid exception",
3328 result = FUNC(ccosh) (BUILD_COMPLEX (-6.75, minus_infty));
3329 check_isnan_exc ("real(ccosh(-6.75 - i Inf)) = NaN plus invalid exception",
3330 __real__ result, INVALID_EXCEPTION);
3331 check_isnan ("imag(ccosh(-6.75 - i Inf)) = NaN plus invalid exception",
3334 result = FUNC(ccosh) (BUILD_COMPLEX (0.0, nan_value));
3335 check_isnan ("real(ccosh(0 + i NaN)) = NaN", __real__ result);
3336 check ("imag(ccosh(0 + i NaN)) = +-0", FUNC(fabs) (__imag__ result), 0);
3337 result = FUNC(ccosh) (BUILD_COMPLEX (minus_zero, nan_value));
3338 check_isnan ("real(ccosh(-0 + i NaN)) = NaN", __real__ result);
3339 check ("imag(ccosh(-0 + i NaN)) = +-0", FUNC(fabs) (__imag__ result), 0);
3341 result = FUNC(ccosh) (BUILD_COMPLEX (plus_infty, nan_value));
3342 check_isinfp ("real(ccosh(+Inf + i NaN)) = +Inf", __real__ result);
3343 check_isnan ("imag(ccosh(+Inf + i NaN)) = NaN", __imag__ result);
3344 result = FUNC(ccosh) (BUILD_COMPLEX (minus_infty, nan_value));
3345 check_isinfp ("real(ccosh(-Inf + i NaN)) = +Inf", __real__ result);
3346 check_isnan ("imag(ccosh(-Inf + i NaN)) = NaN", __imag__ result);
3348 result = FUNC(ccosh) (BUILD_COMPLEX (9.0, nan_value));
3349 check_isnan_maybe_exc ("real(ccosh(9.0 + i NaN)) = NaN plus maybe invalid exception",
3350 __real__ result, INVALID_EXCEPTION);
3351 check_isnan ("imag(ccosh(9.0 + i NaN)) = NaN plus maybe invalid exception",
3353 result = FUNC(ccosh) (BUILD_COMPLEX (-9.0, nan_value));
3354 check_isnan_maybe_exc ("real(ccosh(-9.0 + i NaN)) = NaN plus maybe invalid exception",
3355 __real__ result, INVALID_EXCEPTION);
3356 check_isnan ("imag(ccosh(-9.0 + i NaN)) = NaN plus maybe invalid exception",
3359 result = FUNC(ccosh) (BUILD_COMPLEX (nan_value, 0.0));
3360 check_isnan ("real(ccosh(NaN + i0)) = NaN", __real__ result);
3361 check ("imag(ccosh(NaN + i0)) = +-0", FUNC(fabs) (__imag__ result), 0.0);
3362 result = FUNC(ccosh) (BUILD_COMPLEX (nan_value, minus_zero));
3363 check_isnan ("real(ccosh(NaN - i0)) = NaN", __real__ result);
3364 check ("imag(ccosh(NaN - i0)) = +-0", FUNC(fabs) (__imag__ result), 0.0);
3366 result = FUNC(ccosh) (BUILD_COMPLEX (nan_value, 10.0));
3367 check_isnan_maybe_exc ("real(ccosh(NaN + i10)) = NaN plus maybe invalid exception",
3368 __real__ result, INVALID_EXCEPTION);
3369 check_isnan ("imag(ccosh(NaN + i10)) = NaN plus maybe invalid exception",
3371 result = FUNC(ccosh) (BUILD_COMPLEX (nan_value, -10.0));
3372 check_isnan_maybe_exc ("real(ccosh(NaN - i10)) = NaN plus maybe invalid exception",
3373 __real__ result, INVALID_EXCEPTION);
3374 check_isnan ("imag(ccosh(NaN - i10)) = NaN plus maybe invalid exception",
3377 result = FUNC(ccosh) (BUILD_COMPLEX (nan_value, plus_infty));
3378 check_isnan_maybe_exc ("real(ccosh(NaN + i Inf)) = NaN plus maybe invalid exception",
3379 __real__ result, INVALID_EXCEPTION);
3380 check_isnan ("imag(ccosh(NaN + i Inf)) = NaN plus maybe invalid exception",
3382 result = FUNC(ccosh) (BUILD_COMPLEX (nan_value, minus_infty));
3383 check_isnan_maybe_exc ("real(ccosh(NaN - i Inf)) = NaN plus maybe invalid exception",
3384 __real__ result, INVALID_EXCEPTION);
3385 check_isnan ("imag(ccosh(NaN - i Inf)) = NaN plus maybe invalid exception",
3388 result = FUNC(ccosh) (BUILD_COMPLEX (nan_value, nan_value));
3389 check_isnan ("real(ccosh(NaN + i NaN)) = NaN", __real__ result);
3390 check_isnan ("imag(ccosh(NaN + i NaN)) = NaN", __imag__ result);
3392 result = FUNC(ccosh) (BUILD_COMPLEX (0.7, 1.2));
3393 check_eps ("real(ccosh(0.7 + i 1.2)) == 0.45482...", __real__ result,
3394 0.4548202223691477654L, CHOOSE (5e-17L, 6e-17, 9e-8));
3395 check_eps ("imag(ccosh(0.7 + i 1.2)) == 0.70702...", __imag__ result,
3396 0.7070296600921537682L, CHOOSE (7e-17L, 2e-16, 0));
3398 result = FUNC(ccosh) (BUILD_COMPLEX (-2, -3));
3399 check_eps ("real(ccosh(-2 - i 3)) == -3.72454...", __real__ result,
3400 -3.7245455049153225654L, CHOOSE (7e-19L, 4.5e-16, 3e-7));
3401 check_eps ("imag(ccosh(-2 - i 3)) == -0.51182...", __imag__ result,
3402 0.5118225699873846088L, CHOOSE (3e-19L, 2e-16, 6e-8));
3409 __complex__ MATHTYPE result;
3411 result = FUNC(cacos) (BUILD_COMPLEX (0, 0));
3412 check ("real(cacos(0 + i0)) = pi/2", __real__ result, M_PI_2l);
3413 check ("imag(cacos(0 + i0)) = -0", __imag__ result, minus_zero);
3414 result = FUNC(cacos) (BUILD_COMPLEX (minus_zero, 0));
3415 check ("real(cacos(-0 + i0)) = pi/2", __real__ result, M_PI_2l);
3416 check ("imag(cacos(-0 + i0)) = -0", __imag__ result, minus_zero);
3417 result = FUNC(cacos) (BUILD_COMPLEX (0, minus_zero));
3418 check ("real(cacos(0 - i0)) = pi/2", __real__ result, M_PI_2l);
3419 check ("imag(cacos(0 - i0)) = 0", __imag__ result, 0);
3420 result = FUNC(cacos) (BUILD_COMPLEX (minus_zero, minus_zero));
3421 check ("real(cacos(-0 - i0)) = pi/2", __real__ result, M_PI_2l);
3422 check ("imag(cacos(-0 - i0)) = 0", __imag__ result, 0);
3424 result = FUNC(cacos) (BUILD_COMPLEX (minus_infty, plus_infty));
3425 check ("real(cacos(-Inf + i Inf)) = 3*pi/4", __real__ result,
3427 check_isinfn ("imag(cacos(-Inf + i Inf)) = -Inf", __imag__ result);
3428 result = FUNC(cacos) (BUILD_COMPLEX (minus_infty, minus_infty));
3429 check ("real(cacos(-Inf - i Inf)) = 3*pi/4", __real__ result,
3431 check_isinfp ("imag(cacos(-Inf - i Inf)) = +Inf", __imag__ result);
3433 result = FUNC(cacos) (BUILD_COMPLEX (plus_infty, plus_infty));
3434 check ("real(cacos(+Inf + i Inf)) = pi/4", __real__ result, M_PI_4l);
3435 check_isinfn ("imag(cacos(+Inf + i Inf)) = -Inf", __imag__ result);
3436 result = FUNC(cacos) (BUILD_COMPLEX (plus_infty, minus_infty));
3437 check ("real(cacos(+Inf - i Inf)) = pi/4", __real__ result, M_PI_4l);
3438 check_isinfp ("imag(cacos(+Inf - i Inf)) = +Inf", __imag__ result);
3440 result = FUNC(cacos) (BUILD_COMPLEX (-10.0, plus_infty));
3441 check ("real(cacos(-10.0 + i Inf)) = pi/2", __real__ result, M_PI_2l);
3442 check_isinfn ("imag(cacos(-10.0 + i Inf)) = -Inf", __imag__ result);
3443 result = FUNC(cacos) (BUILD_COMPLEX (-10.0, minus_infty));
3444 check ("real(cacos(-10.0 - i Inf)) = pi/2", __real__ result, M_PI_2l);
3445 check_isinfp ("imag(cacos(-10.0 - i Inf)) = +Inf", __imag__ result);
3446 result = FUNC(cacos) (BUILD_COMPLEX (0, plus_infty));
3447 check ("real(cacos(0 + i Inf)) = pi/2", __real__ result, M_PI_2l);
3448 check_isinfn ("imag(cacos(0 + i Inf)) = -Inf", __imag__ result);
3449 result = FUNC(cacos) (BUILD_COMPLEX (0, minus_infty));
3450 check ("real(cacos(0 - i Inf)) = pi/2", __real__ result, M_PI_2l);
3451 check_isinfp ("imag(cacos(0 - i Inf)) = +Inf", __imag__ result);
3452 result = FUNC(cacos) (BUILD_COMPLEX (0.1, plus_infty));
3453 check ("real(cacos(0.1 + i Inf)) = pi/2", __real__ result, M_PI_2l);
3454 check_isinfn ("imag(cacos(0.1 + i Inf)) = -Inf", __imag__ result);
3455 result = FUNC(cacos) (BUILD_COMPLEX (0.1, minus_infty));
3456 check ("real(cacos(0.1 - i Inf)) = pi/2", __real__ result, M_PI_2l);
3457 check_isinfp ("imag(cacos(0.1 - i Inf)) = +Inf", __imag__ result);
3459 result = FUNC(cacos) (BUILD_COMPLEX (minus_infty, 0));
3460 check ("real(cacos(-Inf + i0)) = pi", __real__ result, M_PIl);
3461 check_isinfn ("imag(cacos(-Inf + i0)) = -Inf", __imag__ result);
3462 result = FUNC(cacos) (BUILD_COMPLEX (minus_infty, minus_zero));
3463 check ("real(cacos(-Inf - i0)) = pi", __real__ result, M_PIl);
3464 check_isinfp ("imag(cacos(-Inf - i0)) = +Inf", __imag__ result);
3465 result = FUNC(cacos) (BUILD_COMPLEX (minus_infty, 100));
3466 check ("real(cacos(-Inf + i100)) = pi", __real__ result, M_PIl);
3467 check_isinfn ("imag(cacos(-Inf + i100)) = -Inf", __imag__ result);
3468 result = FUNC(cacos) (BUILD_COMPLEX (minus_infty, -100));
3469 check ("real(cacos(-Inf - i100)) = pi", __real__ result, M_PIl);
3470 check_isinfp ("imag(cacos(-Inf - i100)) = +Inf", __imag__ result);
3472 result = FUNC(cacos) (BUILD_COMPLEX (plus_infty, 0));
3473 check ("real(cacos(+Inf + i0)) = 0", __real__ result, 0);
3474 check_isinfn ("imag(cacos(+Inf + i0)) = -Inf", __imag__ result);
3475 result = FUNC(cacos) (BUILD_COMPLEX (plus_infty, minus_zero));
3476 check ("real(cacos(+Inf - i0)) = 0", __real__ result, 0);
3477 check_isinfp ("imag(cacos(+Inf - i0)) = +Inf", __imag__ result);
3478 result = FUNC(cacos) (BUILD_COMPLEX (plus_infty, 0.5));
3479 check ("real(cacos(+Inf + i0.5)) = 0", __real__ result, 0);
3480 check_isinfn ("imag(cacos(+Inf + i0.5)) = -Inf", __imag__ result);
3481 result = FUNC(cacos) (BUILD_COMPLEX (plus_infty, -0.5));
3482 check ("real(cacos(+Inf - i0.5)) = 0", __real__ result, 0);
3483 check_isinfp ("imag(cacos(+Inf - i0.5)) = +Inf", __imag__ result);
3485 result = FUNC(cacos) (BUILD_COMPLEX (plus_infty, nan_value));
3486 check_isnan ("real(cacos(+Inf + i NaN)) = NaN", __real__ result);
3487 check_isinfp ("imag(cacos(+Inf + i NaN)) = +-Inf",
3488 FUNC(fabs) (__imag__ result));