1 /* Copyright (C) 1997, 1998 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. */
22 Part of testsuite for libm.
24 This file has to be included by a master file that defines:
27 FUNC(function): converts general function name (like cos) to
28 name with correct suffix (e.g. cosl or cosf)
29 MATHCONST(x): like FUNC but for constants (e.g convert 0.0 to 0.0L)
30 MATHTYPE: floating point type to test
31 TEST_MSG: informal message to be displayed
32 CHOOSE(Clongdouble,Cdouble,Cfloat):
33 chooses one of the parameters as epsilon for testing
35 PRINTF_EXPR Floating point conversion specification to print a variable
36 of type MATHTYPE with printf. PRINTF_EXPR just contains
37 the specifier, not the percent and width arguments,
39 PRINTF_XEXPR Like PRINTF_EXPR, but print in hexadecimal format.
42 /* This program isn't finished yet.
44 acos, acosh, asin, asinh, atan, atan2, atanh,
45 cbrt, ceil, copysign, cos, cosh, erf, erfc, exp, exp10, exp2, expm1,
46 fabs, fdim, floor, fma, fmax, fmin, fmod, fpclassify,
48 ilogb, isfinite, isinf, isnan, isnormal,
49 isless, islessequal, isgreater, isgreaterequal, islessgreater, isunordered,
50 ldexp, lgamma, log, log10, log1p, log2, logb,
51 modf, nearbyint, nextafter,
52 pow, remainder, remquo, rint, lrint, llrint,
53 round, lround, llround,
54 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 OB conj, cproj, cimag, creal, drem,
62 j0, j1, jn, y0, y1, yn,
66 The routines using random variables are still under construction. I don't
67 like it the way it's working now and will change it.
69 Parameter handling is primitive in the moment:
70 --verbose=[0..4] for different levels of output:
72 1: basic report on failed tests (default)
73 2: full report on failed tests
74 3: full report on failed and passed tests
75 4: additional report on exceptions
76 -v for full output (equals --verbose=4)
77 -s,--silent outputs only the error count (equals --verbose=0)
82 This suite tests some aspects of the correct implementation of
83 mathematical functions in libm. Some simple, specific parameters
84 are tested for correctness but there's no exhaustive
85 testing. Handling of specific inputs (e.g. infinity, not-a-number)
86 is also tested. Correct handling of exceptions is checked
87 against. These implemented tests should check all cases that are
88 specified in ISO C 9X.
90 Exception testing: At the moment only divide-by-zero and invalid
91 exceptions are tested. Overflow/underflow and inexact exceptions
92 aren't checked at the moment.
94 NaN values: There exist signalling and quiet NaNs. This implementation
95 only uses signalling NaN as parameter but does not differenciate
96 between the two kinds of NaNs as result.
98 Inline functions: Inlining functions should give an improvement in
99 speed - but not in precission. The inlined functions return
100 reasonable values for a reasonable range of input values. The
101 result is not necessarily correct for all values and exceptions are
102 not correctly raised in all cases. Problematic input and return
103 values are infinity, not-a-number and minus zero. This suite
104 therefore does not check these specific inputs and the exception
105 handling for inlined mathematical functions - just the "reasonable"
108 Beware: The tests might fail for any of the following reasons:
110 - Functions are wrong
111 - Floating Point Unit not working properly
112 - Compiler has errors
114 With e.g. gcc 2.7.2.2 the test for cexp fails because of a compiler error.
132 /* Possible exceptions */
133 #define NO_EXCEPTION 0x0
134 #define INVALID_EXCEPTION 0x1
135 #define DIVIDE_BY_ZERO_EXCEPTION 0x2
140 /* Various constants (we must supply them precalculated for accuracy). */
141 #define M_PI_6l .52359877559829887308L
142 #define M_E2l 7.389056098930650227230L
143 #define M_E3l 20.08553692318766774093L
145 static int noErrors; /* number of errors */
146 static int noTests; /* number of tests (without testing exceptions) */
147 static int noExcTests; /* number of tests for exception flags */
149 static int verbose = 3;
150 static MATHTYPE minus_zero, plus_zero;
151 static MATHTYPE plus_infty, minus_infty, nan_value;
153 typedef MATHTYPE (*mathfunc) (MATHTYPE);
155 #define BUILD_COMPLEX(real, imag) \
156 ({ __complex__ MATHTYPE __retval; \
157 __real__ __retval = (real); \
158 __imag__ __retval = (imag); \
163 (sizeof (x) == sizeof (float) ? \
165 : sizeof (x) == sizeof (double) ? \
166 isinf (x) : isinfl (x))
170 Test if Floating-Point stack hasn't changed
173 fpstack_test (const char *test_name)
176 static int old_stack;
178 asm ("fnstsw":"=a" (sw));
183 printf ("FP-Stack wrong after test %s\n", test_name);
185 printf ("=======> stack = %d\n", sw);
194 Get a random value x with min_value < x < max_value
195 and min_value, max_value finite,
196 max_value and min_value shouldn't be too close together
199 random_value (MATHTYPE min_value, MATHTYPE max_value)
206 x = (max_value - min_value) / RAND_MAX * (MATHTYPE) r + min_value;
208 if ((x <= min_value) || (x >= max_value) || !isfinite (x))
209 x = (max_value - min_value) / 2 + min_value;
211 /* Make sure the RNG has no influence on the exceptions. */
212 feclearexcept (FE_ALL_EXCEPT);
217 /* Get a random value x with x > min_value. */
219 random_greater (MATHTYPE min_value)
221 return random_value (min_value, 1e6); /* CHOOSE (LDBL_MAX, DBL_MAX, FLT_MAX) */
224 /* Get a random value x with x < max_value. */
226 random_less (MATHTYPE max_value)
228 return random_value (-1e6, max_value);
233 output_new_test (const char *test_name)
236 printf ("\nTesting: %s\n", test_name);
241 output_pass_value (void)
244 printf ("Pass: Value Ok.\n");
249 output_fail_value (const char * test_name)
251 if (verbose > 0 && verbose < 3)
252 printf ("Fail: %s\n", test_name);
258 /* Test whether a given exception was raised. */
260 test_single_exception (const char *test_name,
264 const char *flag_name)
267 if (exception & exc_flag)
269 if (fetestexcept (fe_flag))
272 printf ("Pass: Exception \"%s\" set\n", flag_name);
276 if (verbose && verbose < 3)
277 printf ("Fail: %s: Exception \"%s\" not set\n",
278 test_name, flag_name);
280 printf ("Fail: Exception \"%s\" not set\n",
287 if (fetestexcept (fe_flag))
289 if (verbose && verbose < 3)
290 printf ("Fail: %s: Exception \"%s\" set\n",
291 test_name, flag_name);
293 printf ("Fail: Exception \"%s\" set\n",
300 printf ("Pass: Exception \"%s\" not set\n",
308 /* Test whether exception given by EXCEPTION are raised. */
310 test_not_exception (const char *test_name, short int exception)
314 if ((exception & DIVIDE_BY_ZERO_EXCEPTION) == 0)
315 test_single_exception (test_name, exception,
316 DIVIDE_BY_ZERO_EXCEPTION, FE_DIVBYZERO,
320 if ((exception & INVALID_EXCEPTION) == 0)
321 test_single_exception (test_name, exception, INVALID_EXCEPTION, FE_INVALID,
322 "Invalid operation");
324 feclearexcept (FE_ALL_EXCEPT);
328 /* Test whether exceptions given by EXCEPTION are raised. */
330 test_exceptions (const char *test_name, short int exception)
334 test_single_exception (test_name, exception,
335 DIVIDE_BY_ZERO_EXCEPTION, FE_DIVBYZERO,
339 test_single_exception (test_name, exception, INVALID_EXCEPTION, FE_INVALID,
340 "Invalid operation");
342 feclearexcept (FE_ALL_EXCEPT);
346 /* Test if two floating point numbers are equal. */
348 check_equal (MATHTYPE computed, MATHTYPE supplied, MATHTYPE eps, MATHTYPE * diff)
352 /* Both plus Infinity or both minus infinity. */
353 if (ISINF (computed) && (ISINF (computed) == ISINF (supplied)))
356 if (isnan (computed) && isnan (supplied)) /* isnan works for all types */
359 *diff = FUNC(fabs) (computed - supplied);
362 ret_value = (*diff <= eps &&
363 (signbit (computed) == signbit (supplied) || eps != 0.0));
365 /* Make sure the subtraction/comparison have no influence on the exceptions. */
366 feclearexcept (FE_ALL_EXCEPT);
374 output_result_bool (const char *test_name, int result)
379 output_pass_value ();
383 output_fail_value (test_name);
385 printf (" Value: %d\n", result);
389 fpstack_test (test_name);
394 output_isvalue (const char *test_name, int result,
400 output_pass_value ();
404 output_fail_value (test_name);
406 printf (" Value: % .20" PRINTF_EXPR " % .20" PRINTF_XEXPR "\n",
411 fpstack_test (test_name);
416 output_isvalue_ext (const char *test_name, int result,
417 MATHTYPE value, MATHTYPE parameter)
422 output_pass_value ();
426 output_fail_value (test_name);
429 printf (" Value: % .20" PRINTF_EXPR " % .20" PRINTF_XEXPR "\n",
431 printf (" Parameter: % .20" PRINTF_EXPR " % .20" PRINTF_XEXPR "\n",
432 parameter, parameter);
437 fpstack_test (test_name);
442 output_result (const char *test_name, int result,
443 MATHTYPE computed, MATHTYPE expected,
445 int print_values, int print_diff)
450 output_pass_value ();
454 output_fail_value (test_name);
455 if (verbose > 1 && print_values)
457 printf ("Result:\n");
458 printf (" is: % .20" PRINTF_EXPR " % .20" PRINTF_XEXPR "\n",
460 printf (" should be: % .20" PRINTF_EXPR " % .20" PRINTF_XEXPR "\n",
463 printf (" difference: % .20" PRINTF_EXPR " % .20" PRINTF_XEXPR
464 "\n", difference, difference);
469 fpstack_test (test_name);
474 output_result_ext (const char *test_name, int result,
475 MATHTYPE computed, MATHTYPE expected,
478 int print_values, int print_diff)
483 output_pass_value ();
487 output_fail_value (test_name);
488 if (verbose > 1 && print_values)
490 printf ("Result:\n");
491 printf (" is: % .20" PRINTF_EXPR " % .20" PRINTF_XEXPR "\n",
493 printf (" should be: % .20" PRINTF_EXPR " % .20" PRINTF_XEXPR "\n",
496 printf (" difference: % .20" PRINTF_EXPR " % .20" PRINTF_XEXPR
497 "\n", difference, difference);
498 printf ("Parameter: % .20" PRINTF_EXPR " % .20" PRINTF_XEXPR "\n",
499 parameter, parameter);
504 fpstack_test (test_name);
508 check that computed and expected values are the same
511 check (const char *test_name, MATHTYPE computed, MATHTYPE expected)
516 output_new_test (test_name);
517 test_exceptions (test_name, NO_EXCEPTION);
518 result = check_equal (computed, expected, 0, &diff);
519 output_result (test_name, result,
520 computed, expected, diff, PRINT, PRINT);
525 check that computed and expected values are the same,
526 outputs the parameter to the function
529 check_ext (const char *test_name, MATHTYPE computed, MATHTYPE expected,
535 output_new_test (test_name);
536 test_exceptions (test_name, NO_EXCEPTION);
537 result = check_equal (computed, expected, 0, &diff);
538 output_result_ext (test_name, result,
539 computed, expected, diff, parameter, PRINT, PRINT);
544 check that computed and expected values are the same and
545 checks also for exception flags
548 check_exc (const char *test_name, MATHTYPE computed, MATHTYPE expected,
554 output_new_test (test_name);
555 test_exceptions (test_name, exception);
556 result = check_equal (computed, expected, 0, &diff);
557 output_result (test_name, result,
558 computed, expected, diff, PRINT, PRINT);
562 check that computed and expected values are close enough
565 check_eps (const char *test_name, MATHTYPE computed, MATHTYPE expected,
571 output_new_test (test_name);
572 test_exceptions (test_name, NO_EXCEPTION);
573 result = check_equal (computed, expected, epsilon, &diff);
574 output_result (test_name, result,
575 computed, expected, diff, PRINT, PRINT);
579 check a boolean condition
582 check_bool (const char *test_name, int computed)
584 output_new_test (test_name);
585 test_exceptions (test_name, NO_EXCEPTION);
586 output_result_bool (test_name, computed);
592 check that computed and expected values are equal (int values)
595 check_int (const char *test_name, int computed, int expected)
597 int diff = computed - expected;
598 int result = diff == 0;
600 output_new_test (test_name);
601 test_exceptions (test_name, NO_EXCEPTION);
605 output_pass_value ();
609 output_fail_value (test_name);
612 printf ("Result:\n");
613 printf (" is: %d\n", computed);
614 printf (" should be: %d\n", expected);
619 fpstack_test (test_name);
624 check that computed and expected values are equal (long int values)
627 check_long (const char *test_name, long int computed, long int expected)
629 long int diff = computed - expected;
630 int result = diff == 0;
633 output_new_test (test_name);
634 test_exceptions (test_name, NO_EXCEPTION);
638 output_pass_value ();
642 output_fail_value (test_name);
645 printf ("Result:\n");
646 printf (" is: %ld\n", computed);
647 printf (" should be: %ld\n", expected);
652 fpstack_test (test_name);
656 check that computed and expected values are equal (long long int values)
659 check_longlong (const char *test_name, long long int computed,
660 long long int expected)
662 long long int diff = computed - expected;
663 int result = diff == 0;
666 output_new_test (test_name);
667 test_exceptions (test_name, NO_EXCEPTION);
671 output_pass_value ();
675 output_fail_value (test_name);
678 printf ("Result:\n");
679 printf (" is: %lld\n", computed);
680 printf (" should be: %lld\n", expected);
685 fpstack_test (test_name);
689 check that computed value is not-a-number
692 check_isnan (const char *test_name, MATHTYPE computed)
694 output_new_test (test_name);
695 test_exceptions (test_name, NO_EXCEPTION);
696 output_isvalue (test_name, isnan (computed), computed);
701 check that computed value is not-a-number and test for exceptions
704 check_isnan_exc (const char *test_name, MATHTYPE computed,
707 output_new_test (test_name);
708 test_exceptions (test_name, exception);
709 output_isvalue (test_name, isnan (computed), computed);
714 check that computed value is not-a-number and test for exceptions
717 check_isnan_maybe_exc (const char *test_name, MATHTYPE computed,
720 output_new_test (test_name);
721 test_not_exception (test_name, exception);
722 output_isvalue (test_name, isnan (computed), computed);
726 check that computed value is not-a-number and supply parameter
730 check_isnan_ext (const char *test_name, MATHTYPE computed,
733 output_new_test (test_name);
734 test_exceptions (test_name, NO_EXCEPTION);
735 output_isvalue_ext (test_name, isnan (computed), computed, parameter);
740 check that computed value is not-a-number, test for exceptions
744 check_isnan_exc_ext (const char *test_name, MATHTYPE computed,
745 short exception, MATHTYPE parameter)
747 output_new_test (test_name);
748 test_exceptions (test_name,exception);
749 output_isvalue_ext (test_name, isnan (computed), computed, parameter);
753 /* Tests if computed is +Inf */
755 check_isinfp (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);
764 check_isinfp_ext (const char *test_name, MATHTYPE computed,
767 output_new_test (test_name);
768 test_exceptions (test_name, NO_EXCEPTION);
769 output_isvalue_ext (test_name, (ISINF (computed) == +1), computed, parameter);
773 /* Tests if computed is +Inf */
775 check_isinfp_exc (const char *test_name, MATHTYPE computed,
778 output_new_test (test_name);
779 test_exceptions (test_name, exception);
780 output_isvalue (test_name, (ISINF (computed) == +1), computed);
783 /* Tests if computed is -Inf */
785 check_isinfn (const char *test_name, MATHTYPE computed)
787 output_new_test (test_name);
788 test_exceptions (test_name, NO_EXCEPTION);
789 output_isvalue (test_name, (ISINF (computed) == -1), computed);
795 check_isinfn_ext (const char *test_name, MATHTYPE computed,
798 output_new_test (test_name);
799 test_exceptions (test_name, NO_EXCEPTION);
800 output_isvalue_ext (test_name, (ISINF (computed) == -1), computed, parameter);
805 /* Tests if computed is -Inf */
807 check_isinfn_exc (const char *test_name, MATHTYPE computed,
810 output_new_test (test_name);
811 test_exceptions (test_name, exception);
812 output_isvalue (test_name, (ISINF (computed) == -1), computed);
816 /* This is to prevent messages from the SVID libm emulation. */
818 matherr (struct exception *x __attribute__ ((unused)))
824 /****************************************************************************
825 Test for single functions of libm
826 ****************************************************************************/
834 x = random_greater (1);
835 check_isnan_exc ("acos (x) == NaN plus invalid exception for |x| > 1",
840 check_isnan_exc ("acos (x) == NaN plus invalid exception for |x| > 1",
844 check ("acos (0) == pi/2", FUNC(acos) (0), M_PI_2l);
845 check ("acos (-0) == pi/2", FUNC(acos) (minus_zero), M_PI_2l);
847 check ("acos (1) == 0", FUNC(acos) (1), 0);
848 check ("acos (-1) == pi", FUNC(acos) (-1), M_PIl);
850 check_eps ("acos (0.5) == pi/3", FUNC(acos) (0.5), M_PI_6l * 2.0,
851 CHOOSE (1e-18, 0, 0));
852 check_eps ("acos (-0.5) == 2*pi/3", FUNC(acos) (-0.5), M_PI_6l * 4.0,
853 CHOOSE (1e-17, 0, 0));
855 check_eps ("acos (0.7) == 0.795398830...", FUNC(acos) (0.7),
856 0.7953988301841435554L, CHOOSE(7e-17L, 0, 0));
867 check_isinfp ("acosh(+inf) == +inf", FUNC(acosh) (plus_infty));
870 check_isnan_exc ("acosh(x) == NaN plus invalid exception if x < 1",
871 FUNC(acosh) (x), INVALID_EXCEPTION);
874 check ("acosh(1) == 0", FUNC(acosh) (1), 0);
875 check_eps ("acosh(7) == 2.633915793...", FUNC(acosh) (7),
876 2.6339157938496334172L, CHOOSE (3e-19, 0, 0));
886 x = random_greater (1);
887 check_isnan_exc ("asin x == NaN plus invalid exception for |x| > 1",
892 check_isnan_exc ("asin x == NaN plus invalid exception for |x| > 1",
897 check ("asin (0) == 0", FUNC(asin) (0), 0);
898 check ("asin (-0) == -0", FUNC(asin) (minus_zero), minus_zero);
899 check_eps ("asin (0.5) == pi/6", FUNC(asin) (0.5), M_PI_6l,
900 CHOOSE(3.5e-18, 0, 2e-7));
901 check_eps ("asin (-0.5) == -pi/6", FUNC(asin) (-0.5), -M_PI_6l,
902 CHOOSE(3.5e-18, 0, 2e-7));
903 check ("asin (1.0) == pi/2", FUNC(asin) (1.0), M_PI_2l);
904 check ("asin (-1.0) == -pi/2", FUNC(asin) (-1.0), -M_PI_2l);
905 check_eps ("asin (0.7) == 0.775397496...", FUNC(asin) (0.7),
906 0.7753974966107530637L, CHOOSE(7e-17L, 2e-16, 2e-7));
914 check ("asinh(+0) == +0", FUNC(asinh) (0), 0);
916 check ("asinh(-0) == -0", FUNC(asinh) (minus_zero), minus_zero);
917 check_isinfp ("asinh(+inf) == +inf", FUNC(asinh) (plus_infty));
918 check_isinfn ("asinh(-inf) == -inf", FUNC(asinh) (minus_infty));
920 check_eps ("asinh(0.7) == 0.652666566...", FUNC(asinh) (0.7),
921 0.652666566082355786L, CHOOSE(4e-17L, 0, 6e-8));
929 check ("atan (0) == 0", FUNC(atan) (0), 0);
930 check ("atan (-0) == -0", FUNC(atan) (minus_zero), minus_zero);
932 check ("atan (+inf) == pi/2", FUNC(atan) (plus_infty), M_PI_2l);
933 check ("atan (-inf) == -pi/2", FUNC(atan) (minus_infty), -M_PI_2l);
935 check_eps ("atan (1) == pi/4", FUNC(atan) (1), M_PI_4l,
936 CHOOSE (1e-18, 0, 0));
937 check_eps ("atan (-1) == -pi/4", FUNC(atan) (1), M_PI_4l,
938 CHOOSE (1e-18, 0, 0));
940 check_eps ("atan (0.7) == 0.610725964...", FUNC(atan) (0.7),
941 0.6107259643892086165L, CHOOSE(3e-17L, 0, 0));
950 x = random_greater (0);
951 check ("atan2 (0,x) == 0 for x > 0",
952 FUNC(atan2) (0, x), 0);
953 x = random_greater (0);
954 check ("atan2 (-0,x) == -0 for x > 0",
955 FUNC(atan2) (minus_zero, x), minus_zero);
957 check ("atan2 (+0,+0) == +0", FUNC(atan2) (0, 0), 0);
958 check ("atan2 (-0,+0) == -0", FUNC(atan2) (minus_zero, 0), minus_zero);
960 x = -random_greater (0);
961 check ("atan2 (+0,x) == +pi for x < 0", FUNC(atan2) (0, x), M_PIl);
963 x = -random_greater (0);
964 check ("atan2 (-0,x) == -pi for x < 0", FUNC(atan2) (minus_zero, x), -M_PIl);
966 check ("atan2 (+0,-0) == +pi", FUNC(atan2) (0, minus_zero), M_PIl);
967 check ("atan2 (-0,-0) == -pi", FUNC(atan2) (minus_zero, minus_zero), -M_PIl);
969 x = random_greater (0);
970 check ("atan2 (y,+0) == pi/2 for y > 0", FUNC(atan2) (x, 0), M_PI_2l);
972 x = random_greater (0);
973 check ("atan2 (y,-0) == pi/2 for y > 0", FUNC(atan2) (x, minus_zero),
977 check ("atan2 (y,+0) == -pi/2 for y < 0", FUNC(atan2) (x, 0), -M_PI_2l);
980 check ("atan2 (y,-0) == -pi/2 for y < 0", FUNC(atan2) (x, minus_zero),
983 x = random_greater (0);
984 check ("atan2 (y,inf) == +0 for finite y > 0",
985 FUNC(atan2) (x, plus_infty), 0);
987 x = -random_greater (0);
988 check ("atan2 (y,inf) == -0 for finite y < 0",
989 FUNC(atan2) (x, plus_infty), minus_zero);
991 x = random_value (-1e4, 1e4);
992 check ("atan2(+inf, x) == pi/2 for finite x",
993 FUNC(atan2) (plus_infty, x), M_PI_2l);
995 x = random_value (-1e4, 1e4);
996 check ("atan2(-inf, x) == -pi/2 for finite x",
997 FUNC(atan2) (minus_infty, x), -M_PI_2l);
999 x = random_greater (0);
1000 check ("atan2 (y,-inf) == +pi for finite y > 0",
1001 FUNC(atan2) (x, minus_infty), M_PIl);
1003 x = -random_greater (0);
1004 check ("atan2 (y,-inf) == -pi for finite y < 0",
1005 FUNC(atan2) (x, minus_infty), -M_PIl);
1007 check ("atan2 (+inf,+inf) == +pi/4",
1008 FUNC(atan2) (plus_infty, plus_infty), M_PI_4l);
1010 check ("atan2 (-inf,+inf) == -pi/4",
1011 FUNC(atan2) (minus_infty, plus_infty), -M_PI_4l);
1013 check ("atan2 (+inf,-inf) == +3*pi/4",
1014 FUNC(atan2) (plus_infty, minus_infty), 3 * M_PI_4l);
1016 check ("atan2 (-inf,-inf) == -3*pi/4",
1017 FUNC(atan2) (minus_infty, minus_infty), -3 * M_PI_4l);
1019 /* FIXME: Add some specific tests */
1020 check_eps ("atan2 (0.7,1) == 0.61072...", FUNC(atan2) (0.7,1),
1021 0.6107259643892086165L, CHOOSE(3e-17L, 0, 0));
1022 check_eps ("atan2 (0.4,0.0003) == 1.57004...", FUNC(atan2) (0.4, 0.0003),
1023 1.5700463269355215718L, CHOOSE(2e-19L, 0, 1.2e-7));
1035 check ("atanh(+0) == +0", FUNC(atanh) (0), 0);
1037 check ("atanh(-0) == -0", FUNC(atanh) (minus_zero), minus_zero);
1039 check_isinfp_exc ("atanh(+1) == +inf plus divide-by-zero exception",
1040 FUNC(atanh) (1), DIVIDE_BY_ZERO_EXCEPTION);
1041 check_isinfn_exc ("atanh(-1) == -inf plus divide-by-zero exception",
1042 FUNC(atanh) (-1), DIVIDE_BY_ZERO_EXCEPTION);
1044 x = random_greater (1.0);
1045 check_isnan_exc_ext ("atanh (x) == NaN plus invalid exception if |x| > 1",
1046 FUNC(atanh) (x), INVALID_EXCEPTION, x);
1048 x = random_less (1.0);
1049 check_isnan_exc_ext ("atanh (x) == NaN plus invalid exception if |x| > 1",
1050 FUNC(atanh) (x), INVALID_EXCEPTION, x);
1053 check_eps ("atanh(0.7) == 0.867300527...", FUNC(atanh) (0.7),
1054 0.8673005276940531944L, CHOOSE(9e-17L, 2e-16, 0));
1061 check ("cbrt (+0) == +0", FUNC(cbrt) (0.0), 0.0);
1062 check ("cbrt (-0) == -0", FUNC(cbrt) (minus_zero), minus_zero);
1065 check_isinfp ("cbrt (+inf) == +inf", FUNC(cbrt) (plus_infty));
1066 check_isinfn ("cbrt (-inf) == -inf", FUNC(cbrt) (minus_infty));
1067 check_isnan ("cbrt (NaN) == NaN", FUNC(cbrt) (nan_value));
1069 check_eps ("cbrt (-0.001) == -0.1", FUNC(cbrt) (-0.001), -0.1,
1070 CHOOSE (5e-18L, 0, 0));
1071 check_eps ("cbrt (8) == 2", FUNC(cbrt) (8), 2, CHOOSE (5e-17L, 0, 0));
1072 check_eps ("cbrt (-27) == -3", FUNC(cbrt) (-27.0), -3.0,
1073 CHOOSE (3e-16L, 5e-16, 0));
1074 check_eps ("cbrt (0.970299) == 0.99", FUNC(cbrt) (0.970299), 0.99,
1075 CHOOSE (2e-17L, 2e-16, 0));
1076 check_eps ("cbrt (0.7) == .8879040017...", FUNC(cbrt) (0.7),
1077 0.8879040017426007084L, CHOOSE(2e-17L, 6e-16, 0));
1085 check ("ceil (+0) == +0", FUNC(ceil) (0.0), 0.0);
1086 check ("ceil (-0) == -0", FUNC(ceil) (minus_zero), minus_zero);
1087 check_isinfp ("ceil (+inf) == +inf", FUNC(ceil) (plus_infty));
1088 check_isinfn ("ceil (-inf) == -inf", FUNC(ceil) (minus_infty));
1090 check ("ceil (pi) == 4", FUNC(ceil) (M_PIl), 4.0);
1091 check ("ceil (-pi) == -3", FUNC(ceil) (-M_PIl), -3.0);
1099 check ("cos (+0) == 1", FUNC(cos) (0), 1);
1100 check ("cos (-0) == 1", FUNC(cos) (minus_zero), 1);
1101 check_isnan_exc ("cos (+inf) == NaN plus invalid exception",
1102 FUNC(cos) (plus_infty),
1104 check_isnan_exc ("cos (-inf) == NaN plus invalid exception",
1105 FUNC(cos) (minus_infty),
1108 check_eps ("cos (pi/3) == 0.5", FUNC(cos) (M_PI_6l * 2.0),
1109 0.5, CHOOSE (4e-18L, 1e-15L, 1e-7L));
1110 check_eps ("cos (2*pi/3) == -0.5", FUNC(cos) (M_PI_6l * 4.0),
1111 -0.5, CHOOSE (4e-18L, 1e-15L, 1e-7L));
1112 check_eps ("cos (pi/2) == 0", FUNC(cos) (M_PI_2l),
1113 0, CHOOSE (1e-19L, 1e-16L, 1e-7L));
1115 check_eps ("cos (0.7) == 0.7648421872...", FUNC(cos) (0.7),
1116 0.7648421872844884262L, CHOOSE(3e-17, 2e-16, 6e-8));
1122 check ("cosh (+0) == 1", FUNC(cosh) (0), 1);
1123 check ("cosh (-0) == 1", FUNC(cosh) (minus_zero), 1);
1126 check_isinfp ("cosh (+inf) == +inf", FUNC(cosh) (plus_infty));
1127 check_isinfp ("cosh (-inf) == +inf", FUNC(cosh) (minus_infty));
1130 check_eps ("cosh (0.7) == 1.2551690056...", FUNC(cosh) (0.7),
1131 1.255169005630943018L, CHOOSE(4e-17L, 0, 0));
1140 if (errno == ENOSYS)
1141 /* Function not implemented. */
1144 check ("erf (+0) == +0", FUNC(erf) (0), 0);
1145 check ("erf (-0) == -0", FUNC(erf) (minus_zero), minus_zero);
1146 check ("erf (+inf) == +1", FUNC(erf) (plus_infty), 1);
1147 check ("erf (-inf) == -1", FUNC(erf) (minus_infty), -1);
1149 check_eps ("erf (0.7) == 0.6778011938...", FUNC(erf) (0.7),
1150 0.67780119383741847297L, CHOOSE(0, 2e-16, 0));
1159 if (errno == ENOSYS)
1160 /* Function not implemented. */
1163 check ("erfc (+inf) == 0", FUNC(erfc) (plus_infty), 0.0);
1164 check ("erfc (-inf) == 2", FUNC(erfc) (minus_infty), 2.0);
1165 check ("erfc (+0) == 1", FUNC(erfc) (0.0), 1.0);
1166 check ("erfc (-0) == 1", FUNC(erfc) (minus_zero), 1.0);
1168 check_eps ("erfc (0.7) == 0.3221988061...", FUNC(erfc) (0.7),
1169 0.32219880616258152702L, CHOOSE(0, 6e-17, 0));
1176 check ("exp (+0) == 1", FUNC(exp) (0), 1);
1177 check ("exp (-0) == 1", FUNC(exp) (minus_zero), 1);
1180 check_isinfp ("exp (+inf) == +inf", FUNC(exp) (plus_infty));
1181 check ("exp (-inf) == 0", FUNC(exp) (minus_infty), 0);
1183 check_eps ("exp (1) == e", FUNC(exp) (1), M_El, CHOOSE (4e-18L, 0, 0));
1185 check_eps ("exp (2) == e^2", FUNC(exp) (2), M_E2l,
1186 CHOOSE (1e-18, 0, 0));
1187 check_eps ("exp (3) == e^3", FUNC(exp) (3), M_E3l,
1188 CHOOSE (1.5e-17, 0, 0));
1189 check_eps ("exp (0.7) == 2.0137527074...", FUNC(exp) (0.7),
1190 2.0137527074704765216L, CHOOSE(9e-17L, 0, 0));
1199 if (errno == ENOSYS)
1200 /* Function not implemented. */
1203 check ("exp10 (+0) == 1", FUNC(exp10) (0), 1);
1204 check ("exp10 (-0) == 1", FUNC(exp10) (minus_zero), 1);
1206 check_isinfp ("exp10 (+inf) == +inf", FUNC(exp10) (plus_infty));
1207 check ("exp10 (-inf) == 0", FUNC(exp10) (minus_infty), 0);
1208 check_eps ("exp10 (3) == 1000", FUNC(exp10) (3), 1000,
1209 CHOOSE(5e-16, 7e-13, 2e-4));
1210 check_eps ("exp10 (-1) == 0.1", FUNC(exp10) (-1), 0.1,
1211 CHOOSE(6e-18, 3e-17, 8e-09));
1212 check_isinfp ("exp10 (1e6) == +inf", FUNC(exp10) (1e6));
1213 check ("exp10 (-1e6) == 0", FUNC(exp10) (-1e6), 0);
1214 check_eps ("exp10 (0.7) == 5.0118723...", FUNC(exp10) (0.7),
1215 5.0118723362727228500L, CHOOSE(6e-16, 9e-16, 5e-7));
1224 if (errno == ENOSYS)
1225 /* Function not implemented. */
1228 check ("exp2 (+0) == 1", FUNC(exp2) (0), 1);
1229 check ("exp2 (-0) == 1", FUNC(exp2) (minus_zero), 1);
1231 check_isinfp ("exp2 (+inf) == +inf", FUNC(exp2) (plus_infty));
1232 check ("exp2 (-inf) == 0", FUNC(exp2) (minus_infty), 0);
1233 check ("exp2 (10) == 1024", FUNC(exp2) (10), 1024);
1234 check ("exp2 (-1) == 0.5", FUNC(exp2) (-1), 0.5);
1235 check_isinfp ("exp2 (1e6) == +inf", FUNC(exp2) (1e6));
1236 check ("exp2 (-1e6) == 0", FUNC(exp2) (-1e6), 0);
1237 check_eps ("exp2 (0.7) == 1.6245047927...", FUNC(exp2) (0.7),
1238 1.6245047927124710452L, CHOOSE(6e-17L, 0, 6e-8));
1245 check ("expm1 (+0) == 0", FUNC(expm1) (0), 0);
1247 check ("expm1 (-0) == -0", FUNC(expm1) (minus_zero), minus_zero);
1249 check_isinfp ("expm1 (+inf) == +inf", FUNC(expm1) (plus_infty));
1250 check ("expm1 (-inf) == -1", FUNC(expm1) (minus_infty), -1);
1253 check_eps ("expm1 (1) == e-1", FUNC(expm1) (1), M_El - 1.0,
1254 CHOOSE (4e-18L, 0, 2e-7));
1256 check_eps ("expm1 (0.7) == 1.01375...", FUNC(expm1) (0.7),
1257 1.0137527074704765216L, CHOOSE(9e-17L, 0, 0));
1264 check_frexp (const char *test_name, MATHTYPE computed, MATHTYPE expected,
1265 int comp_int, int exp_int)
1270 result = (check_equal (computed, expected, 0, &diff)
1271 && (comp_int == exp_int));
1276 printf ("Pass: %s\n", test_name);
1281 printf ("Fail: %s\n", test_name);
1284 printf ("Result:\n");
1285 printf (" is: %.20" PRINTF_EXPR " *2^%d %.20"
1286 PRINTF_XEXPR "*2^%d\n",
1287 computed, comp_int, computed, comp_int);
1288 printf (" should be: %.20" PRINTF_EXPR " *2^%d %.20"
1289 PRINTF_XEXPR "*2^%d\n",
1290 expected, exp_int, expected, exp_int);
1291 printf (" difference: %.20" PRINTF_EXPR " %.20" PRINTF_XEXPR "\n",
1296 fpstack_test (test_name);
1297 output_result (test_name, result,
1298 computed, expected, diff, PRINT, PRINT);
1308 result = FUNC(frexp) (plus_infty, &x_int);
1309 check_isinfp ("frexp (+inf, expr) == +inf", result);
1311 result = FUNC(frexp) (minus_infty, &x_int);
1312 check_isinfn ("frexp (-inf, expr) == -inf", result);
1314 result = FUNC(frexp) (nan_value, &x_int);
1315 check_isnan ("frexp (Nan, expr) == NaN", result);
1317 result = FUNC(frexp) (0, &x_int);
1318 check_frexp ("frexp: +0 == 0 * 2^0", result, 0, x_int, 0);
1320 result = FUNC(frexp) (minus_zero, &x_int);
1321 check_frexp ("frexp: -0 == -0 * 2^0", result, minus_zero, x_int, 0);
1323 result = FUNC(frexp) (12.8L, &x_int);
1324 check_frexp ("frexp: 12.8 == 0.8 * 2^4", result, 0.8L, x_int, 4);
1326 result = FUNC(frexp) (-27.34L, &x_int);
1327 check_frexp ("frexp: -27.34 == -0.854375 * 2^5", result, -0.854375L, x_int, 5);
1332 #if __GLIBC__ < 2 || (__GLIBC__ == 2 && __GLIBC_MINOR__ < 1)
1333 /* All floating-point numbers can be put in one of these categories. */
1337 #define FP_NAN FP_NAN
1339 #define FP_INFINITE FP_INFINITE
1341 #define FP_ZERO FP_ZERO
1343 #define FP_SUBNORMAL FP_SUBNORMAL
1345 #define FP_NORMAL FP_NORMAL
1351 fpclassify_test (void)
1355 /* fpclassify is a macro, don't give it constants as parameter */
1356 check_bool ("fpclassify (NaN) == FP_NAN", fpclassify (nan_value) == FP_NAN);
1357 check_bool ("fpclassify (+inf) == FP_INFINITE",
1358 fpclassify (plus_infty) == FP_INFINITE);
1359 check_bool ("fpclassify (-inf) == FP_INFINITE",
1360 fpclassify (minus_infty) == FP_INFINITE);
1361 check_bool ("fpclassify (+0) == FP_ZERO",
1362 fpclassify (plus_zero) == FP_ZERO);
1363 check_bool ("fpclassify (-0) == FP_ZERO",
1364 fpclassify (minus_zero) == FP_ZERO);
1367 check_bool ("fpclassify (1000) == FP_NORMAL",
1368 fpclassify (x) == FP_NORMAL);
1373 isfinite_test (void)
1375 check_bool ("isfinite (0) != 0", isfinite (0));
1376 check_bool ("isfinite (-0) != 0", isfinite (minus_zero));
1377 check_bool ("isfinite (10) != 0", isfinite (10));
1378 check_bool ("isfinite (+inf) == 0", isfinite (plus_infty) == 0);
1379 check_bool ("isfinite (-inf) == 0", isfinite (minus_infty) == 0);
1380 check_bool ("isfinite (NaN) == 0", isfinite (nan_value) == 0);
1385 isnormal_test (void)
1387 check_bool ("isnormal (0) == 0", isnormal (0) == 0);
1388 check_bool ("isnormal (-0) == 0", isnormal (minus_zero) == 0);
1389 check_bool ("isnormal (10) != 0", isnormal (10));
1390 check_bool ("isnormal (+inf) == 0", isnormal (plus_infty) == 0);
1391 check_bool ("isnormal (-inf) == 0", isnormal (minus_infty) == 0);
1392 check_bool ("isnormal (NaN) == 0", isnormal (nan_value) == 0);
1402 check_bool ("signbit (+0) == 0", signbit (0) == 0);
1403 check_bool ("signbit (-0) != 0", signbit (minus_zero));
1404 check_bool ("signbit (+inf) == 0", signbit (plus_infty) == 0);
1405 check_bool ("signbit (-inf) != 0", signbit (minus_infty));
1407 x = random_less (0);
1408 check_bool ("signbit (x) != 0 for x < 0", signbit (x));
1410 x = random_greater (0);
1411 check_bool ("signbit (x) == 0 for x > 0", signbit (x) == 0);
1421 if (errno == ENOSYS)
1422 /* Function not implemented. */
1424 feclearexcept (FE_ALL_EXCEPT);
1427 check_isinfp ("gamma (+inf) == +inf", FUNC(gamma) (plus_infty));
1428 check_isinfp_exc ("gamma (0) == +inf plus divide by zero exception",
1429 FUNC(gamma) (0), DIVIDE_BY_ZERO_EXCEPTION);
1431 check_isinfp_exc ("gamma (x) == +inf plus divide by zero exception for integer x <= 0",
1432 FUNC(gamma) (-3), DIVIDE_BY_ZERO_EXCEPTION);
1433 check_isnan_exc ("gamma (-inf) == NaN plus invalid exception",
1434 FUNC(gamma) (minus_infty), INVALID_EXCEPTION);
1437 check ("gamma (1) == 0", FUNC(gamma) (1), 0);
1438 check_int ("gamma (1) sets signgam to 1", signgam, 1);
1441 check ("gamma (3) == M_LN2", FUNC(gamma) (3), M_LN2l);
1442 check_int ("gamma (3) sets signgam to 1", signgam, 1);
1445 check_eps ("gamma (0.5) == log(sqrt(pi))", FUNC(gamma) (0.5),
1446 FUNC(log) (FUNC(sqrt) (M_PIl)), CHOOSE (0, 1e-15, 1e-7));
1447 check_int ("gamma (0.5) sets signgam to 1", signgam, 1);
1450 check_eps ("gamma (-0.5) == log(2*sqrt(pi))", FUNC(gamma) (-0.5),
1451 FUNC(log) (2*FUNC(sqrt) (M_PIl)), CHOOSE (0, 1e-15, 0));
1453 check_int ("gamma (-0.5) sets signgam to -1", signgam, -1);
1462 if (errno == ENOSYS)
1463 /* Function not implemented. */
1465 feclearexcept (FE_ALL_EXCEPT);
1468 check_isinfp ("tgamma (+inf) == +inf", FUNC(tgamma) (plus_infty));
1469 check_isnan_exc ("tgamma (0) == NaN plus invalid exception",
1470 FUNC(tgamma) (0), INVALID_EXCEPTION);
1472 check_isnan_exc_ext ("tgamma (x) == NaN plus invalid exception for integer x <= 0",
1473 FUNC(tgamma) (-2), INVALID_EXCEPTION, -2);
1474 check_isnan_exc ("tgamma (-inf) == NaN plus invalid exception",
1475 FUNC(tgamma) (minus_infty), INVALID_EXCEPTION);
1478 check_eps ("tgamma (0.5) == sqrt(pi)", FUNC(tgamma) (0.5),
1479 FUNC(sqrt) (M_PIl), CHOOSE (0, 5e-16, 2e-7));
1481 check_eps ("tgamma (-0.5) == -2*sqrt(pi)", FUNC(tgamma) (-0.5),
1482 -2*FUNC(sqrt) (M_PIl), CHOOSE (0, 5e-16, 3e-7));
1484 check ("tgamma (1) == 1", FUNC(tgamma) (1), 1);
1485 check ("tgamma (4) == 6", FUNC(tgamma) (4), 6);
1487 check_eps ("tgamma (0.7) == 1.29805...", FUNC(tgamma) (0.7),
1488 1.29805533264755778568L, CHOOSE(0, 3e-16, 2e-7));
1489 check ("tgamma (1.2) == 0.91816...", FUNC(tgamma) (1.2),
1490 0.91816874239976061064L);
1499 if (errno == ENOSYS)
1500 /* Function not implemented. */
1502 feclearexcept (FE_ALL_EXCEPT);
1504 check_isinfp ("lgamma (+inf) == +inf", FUNC(lgamma) (plus_infty));
1505 check_isinfp_exc ("lgamma (0) == +inf plus divide by zero exception",
1506 FUNC(lgamma) (0), DIVIDE_BY_ZERO_EXCEPTION);
1508 check_isinfp_exc ("lgamma (x) == +inf plus divide by zero exception for integer x <= 0",
1509 FUNC(lgamma) (-3), DIVIDE_BY_ZERO_EXCEPTION);
1510 check_isnan_exc ("lgamma (-inf) == NaN plus invalid exception",
1511 FUNC(lgamma) (minus_infty), INVALID_EXCEPTION);
1514 check ("lgamma (1) == 0", FUNC(lgamma) (1), 0);
1515 check_int ("lgamma (0) sets signgam to 1", signgam, 1);
1518 check ("lgamma (3) == M_LN2", FUNC(lgamma) (3), M_LN2l);
1519 check_int ("lgamma (3) sets signgam to 1", signgam, 1);
1522 check_eps ("lgamma (0.5) == log(sqrt(pi))", FUNC(lgamma) (0.5),
1523 FUNC(log) (FUNC(sqrt) (M_PIl)), CHOOSE (0, 1e-15, 1e-7));
1524 check_int ("lgamma (0.5) sets signgam to 1", signgam, 1);
1527 check_eps ("lgamma (-0.5) == log(2*sqrt(pi))", FUNC(lgamma) (-0.5),
1528 FUNC(log) (2*FUNC(sqrt) (M_PIl)), CHOOSE (0, 1e-15, 0));
1530 check_int ("lgamma (-0.5) sets signgam to -1", signgam, -1);
1533 check_eps ("lgamma (0.7) == 0.26086...", FUNC(lgamma) (0.7),
1534 0.26086724653166651439L, CHOOSE(0, 6e-17, 3e-8));
1535 check_int ("lgamma (0.7) sets signgam to 1", signgam, 1);
1538 check_eps ("lgamma (1.2) == -0.08537...", FUNC(lgamma) (1.2),
1539 -0.853740900033158497197e-1L, CHOOSE(0, 2e-17, 2e-8));
1540 check_int ("lgamma (1.2) sets signgam to 1", signgam, 1);
1550 check_int ("ilogb (1) == 0", FUNC(ilogb) (1), 0);
1551 check_int ("ilogb (e) == 1", FUNC(ilogb) (M_El), 1);
1552 check_int ("ilogb (1024) == 10", FUNC(ilogb) (1024), 10);
1553 check_int ("ilogb (-2000) == 10", FUNC(ilogb) (-2000), 10);
1555 /* XXX We have a problem here: the standard does not tell us whether
1556 exceptions are allowed/required. ignore them for now. */
1557 i = FUNC (ilogb) (0.0);
1558 feclearexcept (FE_ALL_EXCEPT);
1559 check_int ("ilogb (0) == FP_ILOGB0", i, FP_ILOGB0);
1560 i = FUNC(ilogb) (nan_value);
1561 feclearexcept (FE_ALL_EXCEPT);
1562 check_int ("ilogb (NaN) == FP_ILOGBNAN", i, FP_ILOGBNAN);
1572 check ("ldexp (0, 0) == 0", FUNC(ldexp) (0, 0), 0);
1574 check_isinfp ("ldexp (+inf, 1) == +inf", FUNC(ldexp) (plus_infty, 1));
1575 check_isinfn ("ldexp (-inf, 1) == -inf", FUNC(ldexp) (minus_infty, 1));
1576 check_isnan ("ldexp (NaN, 1) == NaN", FUNC(ldexp) (nan_value, 1));
1578 check ("ldexp (0.8, 4) == 12.8", FUNC(ldexp) (0.8L, 4), 12.8L);
1579 check ("ldexp (-0.854375, 5) == -27.34", FUNC(ldexp) (-0.854375L, 5), -27.34L);
1581 x = random_greater (0.0);
1582 check_ext ("ldexp (x, 0) == x", FUNC(ldexp) (x, 0L), x, x);
1590 check_isinfn_exc ("log (+0) == -inf plus divide-by-zero exception",
1591 FUNC(log) (0), DIVIDE_BY_ZERO_EXCEPTION);
1592 check_isinfn_exc ("log (-0) == -inf plus divide-by-zero exception",
1593 FUNC(log) (minus_zero), DIVIDE_BY_ZERO_EXCEPTION);
1595 check ("log (1) == 0", FUNC(log) (1), 0);
1597 check_isnan_exc ("log (x) == NaN plus invalid exception if x < 0",
1598 FUNC(log) (-1), INVALID_EXCEPTION);
1599 check_isinfp ("log (+inf) == +inf", FUNC(log) (plus_infty));
1601 check_eps ("log (e) == 1", FUNC(log) (M_El), 1, CHOOSE (1e-18L, 0, 9e-8L));
1602 check_eps ("log (1/e) == -1", FUNC(log) (1.0 / M_El), -1,
1603 CHOOSE (2e-18L, 0, 0));
1604 check_eps ("log (2) == M_LN2", FUNC(log) (2), M_LN2l,
1605 CHOOSE (6e-20L, 0, 0));
1606 check_eps ("log (10) == M_LN10", FUNC(log) (10), M_LN10l,
1607 CHOOSE (1e-18L, 0, 0));
1608 check_eps ("log (0.7) == -0.3566749439...", FUNC(log) (0.7),
1609 -0.35667494393873237891L, CHOOSE(7e-17L, 6e-17, 3e-8));
1616 check_isinfn_exc ("log10 (+0) == -inf plus divide-by-zero exception",
1617 FUNC(log10) (0), DIVIDE_BY_ZERO_EXCEPTION);
1618 check_isinfn_exc ("log10 (-0) == -inf plus divide-by-zero exception",
1619 FUNC(log10) (minus_zero), DIVIDE_BY_ZERO_EXCEPTION);
1621 check ("log10 (1) == +0", FUNC(log10) (1), 0);
1623 check_isnan_exc ("log10 (x) == NaN plus invalid exception if x < 0",
1624 FUNC(log10) (-1), INVALID_EXCEPTION);
1626 check_isinfp ("log10 (+inf) == +inf", FUNC(log10) (plus_infty));
1628 check_eps ("log10 (0.1) == -1", FUNC(log10) (0.1L), -1,
1629 CHOOSE (1e-18L, 0, 0));
1630 check_eps ("log10 (10) == 1", FUNC(log10) (10.0), 1,
1631 CHOOSE (1e-18L, 0, 0));
1632 check_eps ("log10 (100) == 2", FUNC(log10) (100.0), 2,
1633 CHOOSE (1e-18L, 0, 0));
1634 check ("log10 (10000) == 4", FUNC(log10) (10000.0), 4);
1635 check_eps ("log10 (e) == M_LOG10E", FUNC(log10) (M_El), M_LOG10El,
1636 CHOOSE (1e-18, 0, 9e-8));
1637 check_eps ("log10 (0.7) == -0.1549019599...", FUNC(log10) (0.7),
1638 -0.15490195998574316929L, CHOOSE(3e-17L, 3e-17, 2e-8));
1645 check ("log1p (+0) == +0", FUNC(log1p) (0), 0);
1646 check ("log1p (-0) == -0", FUNC(log1p) (minus_zero), minus_zero);
1648 check_isinfn_exc ("log1p (-1) == -inf plus divide-by-zero exception",
1649 FUNC(log1p) (-1), DIVIDE_BY_ZERO_EXCEPTION);
1650 check_isnan_exc ("log1p (x) == NaN plus invalid exception if x < -1",
1651 FUNC(log1p) (-2), INVALID_EXCEPTION);
1653 check_isinfp ("log1p (+inf) == +inf", FUNC(log1p) (plus_infty));
1655 check_eps ("log1p (e-1) == 1", FUNC(log1p) (M_El - 1.0), 1,
1656 CHOOSE (1e-18L, 0, 6e-8));
1658 check_eps ("log1p (-0.3) == -0.35667...", FUNC(log1p) (-0.3),
1659 -0.35667494393873237891L, CHOOSE(2e-17L, 6e-17, 3e-8));
1666 check_isinfn_exc ("log2 (+0) == -inf plus divide-by-zero exception",
1667 FUNC(log2) (0), DIVIDE_BY_ZERO_EXCEPTION);
1668 check_isinfn_exc ("log2 (-0) == -inf plus divide-by-zero exception",
1669 FUNC(log2) (minus_zero), DIVIDE_BY_ZERO_EXCEPTION);
1671 check ("log2 (1) == +0", FUNC(log2) (1), 0);
1673 check_isnan_exc ("log2 (x) == NaN plus invalid exception if x < 0",
1674 FUNC(log2) (-1), INVALID_EXCEPTION);
1676 check_isinfp ("log2 (+inf) == +inf", FUNC(log2) (plus_infty));
1678 check_eps ("log2 (e) == M_LOG2E", FUNC(log2) (M_El), M_LOG2El,
1679 CHOOSE (1e-18L, 0, 0));
1680 check ("log2 (2) == 1", FUNC(log2) (2.0), 1);
1681 check_eps ("log2 (16) == 4", FUNC(log2) (16.0), 4, CHOOSE (1e-18L, 0, 0));
1682 check ("log2 (256) == 8", FUNC(log2) (256.0), 8);
1683 check_eps ("log2 (0.7) == -0.5145731728...", FUNC(log2) (0.7),
1684 -0.51457317282975824043L, CHOOSE(1e-16L, 2e-16, 6e-8));
1692 check_isinfp ("logb (+inf) == +inf", FUNC(logb) (plus_infty));
1693 check_isinfp ("logb (-inf) == +inf", FUNC(logb) (minus_infty));
1695 check_isinfn_exc ("logb (+0) == -inf plus divide-by-zero exception",
1696 FUNC(logb) (0), DIVIDE_BY_ZERO_EXCEPTION);
1698 check_isinfn_exc ("logb (-0) == -inf plus divide-by-zero exception",
1699 FUNC(logb) (minus_zero), DIVIDE_BY_ZERO_EXCEPTION);
1701 check ("logb (1) == 0", FUNC(logb) (1), 0);
1702 check ("logb (e) == 1", FUNC(logb) (M_El), 1);
1703 check ("logb (1024) == 10", FUNC(logb) (1024), 10);
1704 check ("logb (-2000) == 10", FUNC(logb) (-2000), 10);
1712 MATHTYPE result, intpart;
1714 result = FUNC(modf) (plus_infty, &intpart);
1715 check ("modf (+inf, &x) returns +0", result, 0);
1716 check_isinfp ("modf (+inf, &x) set x to +inf", intpart);
1718 result = FUNC(modf) (minus_infty, &intpart);
1719 check ("modf (-inf, &x) returns -0", result, minus_zero);
1720 check_isinfn ("modf (-inf, &x) sets x to -inf", intpart);
1722 result = FUNC(modf) (nan_value, &intpart);
1723 check_isnan ("modf (NaN, &x) returns NaN", result);
1724 check_isnan ("modf (NaN, &x) sets x to NaN", intpart);
1726 result = FUNC(modf) (0, &intpart);
1727 check ("modf (0, &x) returns 0", result, 0);
1728 check ("modf (0, &x) sets x to 0", intpart, 0);
1730 result = FUNC(modf) (minus_zero, &intpart);
1731 check ("modf (-0, &x) returns -0", result, minus_zero);
1732 check ("modf (-0, &x) sets x to -0", intpart, minus_zero);
1734 result = FUNC(modf) (1.5, &intpart);
1735 check ("modf (1.5, &x) returns 0.5", result, 0.5);
1736 check ("modf (1.5, &x) sets x to 1", intpart, 1);
1738 result = FUNC(modf) (2.5, &intpart);
1739 check ("modf (2.5, &x) returns 0.5", result, 0.5);
1740 check ("modf (2.5, &x) sets x to 2", intpart, 2);
1742 result = FUNC(modf) (-2.5, &intpart);
1743 check ("modf (-2.5, &x) returns -0.5", result, -0.5);
1744 check ("modf (-2.5, &x) sets x to -2", intpart, -2);
1746 result = FUNC(modf) (20, &intpart);
1747 check ("modf (20, &x) returns 0", result, 0);
1748 check ("modf (20, &x) sets x to 20", intpart, 20);
1750 result = FUNC(modf) (21, &intpart);
1751 check ("modf (21, &x) returns 0", result, 0);
1752 check ("modf (21, &x) sets x to 21", intpart, 21);
1754 result = FUNC(modf) (89.6, &intpart);
1755 check_eps ("modf (89.6, &x) returns 0.6", result, 0.6,
1756 CHOOSE(6e-15L, 6e-15, 2e-6));
1757 check ("modf (89.6, &x) sets x to 89", intpart, 89);
1766 check_isnan ("scalb (2, 0.5) == NaN", FUNC(scalb) (2, 0.5));
1767 check_isnan ("scalb (3, -2.5) == NaN", FUNC(scalb) (3, -2.5));
1769 check_isnan ("scalb (0, NaN) == NaN", FUNC(scalb) (0, nan_value));
1770 check_isnan ("scalb (1, NaN) == NaN", FUNC(scalb) (1, nan_value));
1772 x = random_greater (0.0);
1773 check ("scalb (x, 0) == 0", FUNC(scalb) (x, 0), x);
1774 x = random_greater (0.0);
1775 check ("scalb (-x, 0) == 0", FUNC(scalb) (-x, 0), -x);
1777 check_isnan_exc ("scalb (+0, +inf) == NaN plus invalid exception",
1778 FUNC(scalb) (0, plus_infty), INVALID_EXCEPTION);
1779 check_isnan_exc ("scalb (-0, +inf) == NaN plus invalid exception",
1780 FUNC(scalb) (minus_zero, plus_infty), INVALID_EXCEPTION);
1782 check ("scalb (+0, 2) == +0", FUNC(scalb) (0, 2), 0);
1783 check ("scalb (-0, 4) == -0", FUNC(scalb) (minus_zero, -4), minus_zero);
1784 check ("scalb (+0, 0) == +0", FUNC(scalb) (0, 0), 0);
1785 check ("scalb (-0, 0) == -0", FUNC(scalb) (minus_zero, 0), minus_zero);
1786 check ("scalb (+0, -1) == +0", FUNC(scalb) (0, -1), 0);
1787 check ("scalb (-0, -10) == -0", FUNC(scalb) (minus_zero, -10), minus_zero);
1788 check ("scalb (+0, -inf) == +0", FUNC(scalb) (0, minus_infty), 0);
1789 check ("scalb (-0, -inf) == -0", FUNC(scalb) (minus_zero, minus_infty),
1792 check_isinfp ("scalb (+inf, -1) == +inf", FUNC(scalb) (plus_infty, -1));
1793 check_isinfn ("scalb (-inf, -10) == -inf", FUNC(scalb) (minus_infty, -10));
1794 check_isinfp ("scalb (+inf, 0) == +inf", FUNC(scalb) (plus_infty, 0));
1795 check_isinfn ("scalb (-inf, 0) == -inf", FUNC(scalb) (minus_infty, 0));
1796 check_isinfp ("scalb (+inf, 2) == +inf", FUNC(scalb) (plus_infty, 2));
1797 check_isinfn ("scalb (-inf, 100) == -inf", FUNC(scalb) (minus_infty, 100));
1799 x = random_greater (0.0);
1800 check ("scalb (x, -inf) == 0", FUNC(scalb) (x, minus_infty), 0.0);
1801 check ("scalb (-x, -inf) == -0", FUNC(scalb) (-x, minus_infty), minus_zero);
1803 x = random_greater (0.0);
1804 check_isinfp ("scalb (x, +inf) == +inf", FUNC(scalb) (x, plus_infty));
1805 x = random_greater (0.0);
1806 check_isinfn ("scalb (-x, +inf) == -inf", FUNC(scalb) (-x, plus_infty));
1807 check_isinfp ("scalb (+inf, +inf) == +inf",
1808 FUNC(scalb) (plus_infty, plus_infty));
1809 check_isinfn ("scalb (-inf, +inf) == -inf",
1810 FUNC(scalb) (minus_infty, plus_infty));
1812 check_isnan ("scalb (+inf, -inf) == NaN",
1813 FUNC(scalb) (plus_infty, minus_infty));
1814 check_isnan ("scalb (-inf, -inf) == NaN",
1815 FUNC(scalb) (minus_infty, minus_infty));
1817 check_isnan ("scalb (NaN, 1) == NaN", FUNC(scalb) (nan_value, 1));
1818 check_isnan ("scalb (1, NaN) == NaN", FUNC(scalb) (1, nan_value));
1819 check_isnan ("scalb (NaN, 0) == NaN", FUNC(scalb) (nan_value, 0));
1820 check_isnan ("scalb (0, NaN) == NaN", FUNC(scalb) (0, nan_value));
1821 check_isnan ("scalb (NaN, +inf) == NaN",
1822 FUNC(scalb) (nan_value, plus_infty));
1823 check_isnan ("scalb (+inf, NaN) == NaN",
1824 FUNC(scalb) (plus_infty, nan_value));
1825 check_isnan ("scalb (NaN, NaN) == NaN", FUNC(scalb) (nan_value, nan_value));
1827 check ("scalb (0.8, 4) == 12.8", FUNC(scalb) (0.8L, 4), 12.8L);
1828 check ("scalb (-0.854375, 5) == -27.34", FUNC(scalb) (-0.854375L, 5), -27.34L);
1837 check ("scalbn (0, 0) == 0", FUNC(scalbn) (0, 0), 0);
1839 check_isinfp ("scalbn (+inf, 1) == +inf", FUNC(scalbn) (plus_infty, 1));
1840 check_isinfn ("scalbn (-inf, 1) == -inf", FUNC(scalbn) (minus_infty, 1));
1841 check_isnan ("scalbn (NaN, 1) == NaN", FUNC(scalbn) (nan_value, 1));
1843 check ("scalbn (0.8, 4) == 12.8", FUNC(scalbn) (0.8L, 4), 12.8L);
1844 check ("scalbn (-0.854375, 5) == -27.34", FUNC(scalbn) (-0.854375L, 5), -27.34L);
1846 x = random_greater (0.0);
1847 check_ext ("scalbn (x, 0) == x", FUNC(scalbn) (x, 0L), x, x);
1854 check ("sin (+0) == +0", FUNC(sin) (0), 0);
1855 check ("sin (-0) == -0", FUNC(sin) (minus_zero), minus_zero);
1856 check_isnan_exc ("sin (+inf) == NaN plus invalid exception",
1857 FUNC(sin) (plus_infty),
1859 check_isnan_exc ("sin (-inf) == NaN plus invalid exception",
1860 FUNC(sin) (minus_infty),
1863 check_eps ("sin (pi/6) == 0.5", FUNC(sin) (M_PI_6l),
1864 0.5, CHOOSE (4e-18L, 0, 0));
1865 check_eps ("sin (-pi/6) == -0.5", FUNC(sin) (-M_PI_6l),
1866 -0.5, CHOOSE (4e-18L, 0, 0));
1867 check ("sin (pi/2) == 1", FUNC(sin) (M_PI_2l), 1);
1868 check ("sin (-pi/2) == -1", FUNC(sin) (-M_PI_2l), -1);
1869 check_eps ("sin (0.7) == 0.6442176872...", FUNC(sin) (0.7),
1870 0.64421768723769105367L, CHOOSE(4e-17L, 0, 0));
1877 check ("sinh (+0) == +0", FUNC(sinh) (0), 0);
1880 check ("sinh (-0) == -0", FUNC(sinh) (minus_zero), minus_zero);
1882 check_isinfp ("sinh (+inf) == +inf", FUNC(sinh) (plus_infty));
1883 check_isinfn ("sinh (-inf) == -inf", FUNC(sinh) (minus_infty));
1886 check_eps ("sinh (0.7) == 0.7585837018...", FUNC(sinh) (0.7),
1887 0.75858370183953350346L, CHOOSE(6e-17L, 2e-16, 6e-8));
1894 MATHTYPE sin_res, cos_res;
1897 FUNC(sincos) (0, &sin_res, &cos_res);
1899 check ("sincos (+0, &sin, &cos) puts +0 in sin", sin_res, 0);
1901 check ("sincos (+0, &sin, &cos) puts 1 in cos", cos_res, 1);
1903 FUNC(sincos) (minus_zero, &sin_res, &cos_res);
1905 check ("sincos (-0, &sin, &cos) puts -0 in sin", sin_res, minus_zero);
1907 check ("sincos (-0, &sin, &cos) puts 1 in cos", cos_res, 1);
1909 FUNC(sincos) (plus_infty, &sin_res, &cos_res);
1911 check_isnan_exc ("sincos (+inf, &sin, &cos) puts NaN in sin plus invalid exception",
1912 sin_res, INVALID_EXCEPTION);
1914 check_isnan_exc ("sincos (+inf, &sin, &cos) puts NaN in cos plus invalid exception",
1915 cos_res, INVALID_EXCEPTION);
1917 FUNC(sincos) (minus_infty, &sin_res, &cos_res);
1919 check_isnan_exc ("sincos (-inf,&sin, &cos) puts NaN in sin plus invalid exception",
1920 sin_res, INVALID_EXCEPTION);
1922 check_isnan_exc ("sincos (-inf,&sin, &cos) puts NaN in cos plus invalid exception",
1923 cos_res, INVALID_EXCEPTION);
1925 FUNC(sincos) (M_PI_2l, &sin_res, &cos_res);
1927 check ("sincos (pi/2, &sin, &cos) puts 1 in sin", sin_res, 1);
1929 check_eps ("sincos (pi/2, &sin, &cos) puts 0 in cos", cos_res, 0,
1930 CHOOSE (1e-18L, 1e-16, 1e-7));
1932 FUNC(sincos) (M_PI_6l, &sin_res, &cos_res);
1933 check_eps ("sincos (pi/6, &sin, &cos) puts 0.5 in sin", sin_res, 0.5,
1934 CHOOSE (5e-18L, 0, 0));
1936 FUNC(sincos) (M_PI_6l*2.0, &sin_res, &cos_res);
1937 check_eps ("sincos (pi/3, &sin, &cos) puts 0.5 in cos", cos_res, 0.5,
1938 CHOOSE (5e-18L, 1e-15, 1e-7));
1940 FUNC(sincos) (0.7, &sin_res, &cos_res);
1941 check_eps ("sincos (0.7, &sin, &cos) puts 0.6442176872... in sin", sin_res,
1942 0.64421768723769105367L, CHOOSE(4e-17L, 0, 0));
1943 check_eps ("sincos (0.7, &sin, &cos) puts 0.7648421872... in cos", cos_res,
1944 0.76484218728448842626L, CHOOSE(3e-17L, 2e-16, 6e-8));
1951 check ("tan (+0) == +0", FUNC(tan) (0), 0);
1952 check ("tan (-0) == -0", FUNC(tan) (minus_zero), minus_zero);
1953 check_isnan_exc ("tan (+inf) == NaN plus invalid exception",
1954 FUNC(tan) (plus_infty), INVALID_EXCEPTION);
1955 check_isnan_exc ("tan (-inf) == NaN plus invalid exception",
1956 FUNC(tan) (minus_infty), INVALID_EXCEPTION);
1958 check_eps ("tan (pi/4) == 1", FUNC(tan) (M_PI_4l), 1,
1959 CHOOSE (2e-18L, 1e-15L, 2e-7));
1960 check_eps ("tan (0.7) == 0.8422883804...", FUNC(tan) (0.7),
1961 0.84228838046307944813L, CHOOSE(8e-17L, 0, 0));
1968 check ("tanh (+0) == +0", FUNC(tanh) (0), 0);
1970 check ("tanh (-0) == -0", FUNC(tanh) (minus_zero), minus_zero);
1972 check ("tanh (+inf) == +1", FUNC(tanh) (plus_infty), 1);
1973 check ("tanh (-inf) == -1", FUNC(tanh) (minus_infty), -1);
1975 check_eps ("tanh (0.7) == 0.6043677771...", FUNC(tanh) (0.7),
1976 0.60436777711716349631L, CHOOSE(3e-17L, 2e-16, 6e-8));
1983 check ("fabs (+0) == +0", FUNC(fabs) (0), 0);
1984 check ("fabs (-0) == +0", FUNC(fabs) (minus_zero), 0);
1986 check_isinfp ("fabs (+inf) == +inf", FUNC(fabs) (plus_infty));
1987 check_isinfp ("fabs (-inf) == +inf", FUNC(fabs) (minus_infty));
1989 check ("fabs (+38) == 38", FUNC(fabs) (38.0), 38.0);
1990 check ("fabs (-e) == e", FUNC(fabs) (-M_El), M_El);
1997 check ("floor (+0) == +0", FUNC(floor) (0.0), 0.0);
1998 check ("floor (-0) == -0", FUNC(floor) (minus_zero), minus_zero);
1999 check_isinfp ("floor (+inf) == +inf", FUNC(floor) (plus_infty));
2000 check_isinfn ("floor (-inf) == -inf", FUNC(floor) (minus_infty));
2002 check ("floor (pi) == 3", FUNC(floor) (M_PIl), 3.0);
2003 check ("floor (-pi) == -4", FUNC(floor) (-M_PIl), -4.0);
2012 a = random_greater (0);
2013 check_isinfp_ext ("hypot (+inf, x) == +inf", FUNC(hypot) (plus_infty, a), a);
2014 check_isinfp_ext ("hypot (-inf, x) == +inf", FUNC(hypot) (minus_infty, a), a);
2017 check_isinfp ("hypot (+inf, NaN) == +inf", FUNC(hypot) (plus_infty, nan_value));
2018 check_isinfp ("hypot (-inf, NaN) == +inf", FUNC(hypot) (minus_infty, nan_value));
2021 check_isnan ("hypot (NaN, NaN) == NaN", FUNC(hypot) (nan_value, nan_value));
2023 a = FUNC(hypot) (12.4L, 0.7L);
2024 check ("hypot (x,y) == hypot (y,x)", FUNC(hypot) (0.7L, 12.4L), a);
2025 check ("hypot (x,y) == hypot (-x,y)", FUNC(hypot) (-12.4L, 0.7L), a);
2026 check ("hypot (x,y) == hypot (-y,x)", FUNC(hypot) (-0.7L, 12.4L), a);
2027 check ("hypot (x,y) == hypot (-x,-y)", FUNC(hypot) (-12.4L, -0.7L), a);
2028 check ("hypot (x,y) == hypot (-y,-x)", FUNC(hypot) (-0.7L, -12.4L), a);
2029 check ("hypot (x,0) == fabs (x)", FUNC(hypot) (-0.7L, 0), 0.7L);
2030 check ("hypot (x,0) == fabs (x)", FUNC(hypot) (0.7L, 0), 0.7L);
2031 check ("hypot (x,0) == fabs (x)", FUNC(hypot) (-1.0L, 0), 1.0L);
2032 check ("hypot (x,0) == fabs (x)", FUNC(hypot) (1.0L, 0), 1.0L);
2033 check ("hypot (x,0) == fabs (x)", FUNC(hypot) (-5.7e7L, 0), 5.7e7L);
2034 check ("hypot (x,0) == fabs (x)", FUNC(hypot) (5.7e7L, 0), 5.7e7L);
2036 check_eps ("hypot (0.7,1.2) == 1.38924...", FUNC(hypot) (0.7, 1.2),
2037 1.3892443989449804508L, CHOOSE(7e-17L, 3e-16, 0));
2046 check ("pow (+0, +0) == 1", FUNC(pow) (0, 0), 1);
2047 check ("pow (+0, -0) == 1", FUNC(pow) (0, minus_zero), 1);
2048 check ("pow (-0, +0) == 1", FUNC(pow) (minus_zero, 0), 1);
2049 check ("pow (-0, -0) == 1", FUNC(pow) (minus_zero, minus_zero), 1);
2051 check ("pow (+10, +0) == 1", FUNC(pow) (10, 0), 1);
2052 check ("pow (+10, -0) == 1", FUNC(pow) (10, minus_zero), 1);
2053 check ("pow (-10, +0) == 1", FUNC(pow) (-10, 0), 1);
2054 check ("pow (-10, -0) == 1", FUNC(pow) (-10, minus_zero), 1);
2056 check ("pow (NaN, +0) == 1", FUNC(pow) (nan_value, 0), 1);
2057 check ("pow (NaN, -0) == 1", FUNC(pow) (nan_value, minus_zero), 1);
2060 check_isinfp ("pow (+1.1, +inf) == +inf", FUNC(pow) (1.1, plus_infty));
2061 check_isinfp ("pow (+inf, +inf) == +inf", FUNC(pow) (plus_infty, plus_infty));
2062 check_isinfp ("pow (-1.1, +inf) == +inf", FUNC(pow) (-1.1, plus_infty));
2063 check_isinfp ("pow (-inf, +inf) == +inf", FUNC(pow) (minus_infty, plus_infty));
2065 check ("pow (0.9, +inf) == +0", FUNC(pow) (0.9L, plus_infty), 0);
2066 check ("pow (1e-7, +inf) == +0", FUNC(pow) (1e-7L, plus_infty), 0);
2067 check ("pow (-0.9, +inf) == +0", FUNC(pow) (-0.9L, plus_infty), 0);
2068 check ("pow (-1e-7, +inf) == +0", FUNC(pow) (-1e-7L, plus_infty), 0);
2070 check ("pow (+1.1, -inf) == 0", FUNC(pow) (1.1, minus_infty), 0);
2071 check ("pow (+inf, -inf) == 0", FUNC(pow) (plus_infty, minus_infty), 0);
2072 check ("pow (-1.1, -inf) == 0", FUNC(pow) (-1.1, minus_infty), 0);
2073 check ("pow (-inf, -inf) == 0", FUNC(pow) (minus_infty, minus_infty), 0);
2075 check_isinfp ("pow (0.9, -inf) == +inf", FUNC(pow) (0.9L, minus_infty));
2076 check_isinfp ("pow (1e-7, -inf) == +inf", FUNC(pow) (1e-7L, minus_infty));
2077 check_isinfp ("pow (-0.9, -inf) == +inf", FUNC(pow) (-0.9L, minus_infty));
2078 check_isinfp ("pow (-1e-7, -inf) == +inf", FUNC(pow) (-1e-7L, minus_infty));
2080 check_isinfp ("pow (+inf, 1e-7) == +inf", FUNC(pow) (plus_infty, 1e-7L));
2081 check_isinfp ("pow (+inf, 1) == +inf", FUNC(pow) (plus_infty, 1));
2082 check_isinfp ("pow (+inf, 1e7) == +inf", FUNC(pow) (plus_infty, 1e7L));
2084 check ("pow (+inf, -1e-7) == 0", FUNC(pow) (plus_infty, -1e-7L), 0);
2085 check ("pow (+inf, -1) == 0", FUNC(pow) (plus_infty, -1), 0);
2086 check ("pow (+inf, -1e7) == 0", FUNC(pow) (plus_infty, -1e7L), 0);
2088 check_isinfn ("pow (-inf, 1) == -inf", FUNC(pow) (minus_infty, 1));
2089 check_isinfn ("pow (-inf, 11) == -inf", FUNC(pow) (minus_infty, 11));
2090 check_isinfn ("pow (-inf, 1001) == -inf", FUNC(pow) (minus_infty, 1001));
2092 check_isinfp ("pow (-inf, 2) == +inf", FUNC(pow) (minus_infty, 2));
2093 check_isinfp ("pow (-inf, 12) == +inf", FUNC(pow) (minus_infty, 12));
2094 check_isinfp ("pow (-inf, 1002) == +inf", FUNC(pow) (minus_infty, 1002));
2095 check_isinfp ("pow (-inf, 0.1) == +inf", FUNC(pow) (minus_infty, 0.1));
2096 check_isinfp ("pow (-inf, 1.1) == +inf", FUNC(pow) (minus_infty, 1.1));
2097 check_isinfp ("pow (-inf, 11.1) == +inf", FUNC(pow) (minus_infty, 11.1));
2098 check_isinfp ("pow (-inf, 1001.1) == +inf", FUNC(pow) (minus_infty, 1001.1));
2100 check ("pow (-inf, -1) == -0", FUNC(pow) (minus_infty, -1), minus_zero);
2101 check ("pow (-inf, -11) == -0", FUNC(pow) (minus_infty, -11), minus_zero);
2102 check ("pow (-inf, -1001) == -0", FUNC(pow) (minus_infty, -1001), minus_zero);
2104 check ("pow (-inf, -2) == +0", FUNC(pow) (minus_infty, -2), 0);
2105 check ("pow (-inf, -12) == +0", FUNC(pow) (minus_infty, -12), 0);
2106 check ("pow (-inf, -1002) == +0", FUNC(pow) (minus_infty, -1002), 0);
2107 check ("pow (-inf, -0.1) == +0", FUNC(pow) (minus_infty, -0.1), 0);
2108 check ("pow (-inf, -1.1) == +0", FUNC(pow) (minus_infty, -1.1), 0);
2109 check ("pow (-inf, -11.1) == +0", FUNC(pow) (minus_infty, -11.1), 0);
2110 check ("pow (-inf, -1001.1) == +0", FUNC(pow) (minus_infty, -1001.1), 0);
2112 check_isnan ("pow (NaN, NaN) == NaN", FUNC(pow) (nan_value, nan_value));
2113 check_isnan ("pow (0, NaN) == NaN", FUNC(pow) (0, nan_value));
2114 check_isnan ("pow (1, NaN) == NaN", FUNC(pow) (1, nan_value));
2115 check_isnan ("pow (-1, NaN) == NaN", FUNC(pow) (-1, nan_value));
2116 check_isnan ("pow (NaN, 1) == NaN", FUNC(pow) (nan_value, 1));
2117 check_isnan ("pow (NaN, -1) == NaN", FUNC(pow) (nan_value, -1));
2119 x = random_greater (0.0);
2120 check_isnan_ext ("pow (x, NaN) == NaN", FUNC(pow) (x, nan_value), x);
2122 check_isnan_exc ("pow (+1, +inf) == NaN plus invalid exception",
2123 FUNC(pow) (1, plus_infty), INVALID_EXCEPTION);
2124 check_isnan_exc ("pow (-1, +inf) == NaN plus invalid exception",
2125 FUNC(pow) (-1, plus_infty), INVALID_EXCEPTION);
2126 check_isnan_exc ("pow (+1, -inf) == NaN plus invalid exception",
2127 FUNC(pow) (1, minus_infty), INVALID_EXCEPTION);
2128 check_isnan_exc ("pow (-1, -inf) == NaN plus invalid exception",
2129 FUNC(pow) (-1, minus_infty), INVALID_EXCEPTION);
2131 check_isnan_exc ("pow (-0.1, 1.1) == NaN plus invalid exception",
2132 FUNC(pow) (-0.1, 1.1), INVALID_EXCEPTION);
2133 check_isnan_exc ("pow (-0.1, -1.1) == NaN plus invalid exception",
2134 FUNC(pow) (-0.1, -1.1), INVALID_EXCEPTION);
2135 check_isnan_exc ("pow (-10.1, 1.1) == NaN plus invalid exception",
2136 FUNC(pow) (-10.1, 1.1), INVALID_EXCEPTION);
2137 check_isnan_exc ("pow (-10.1, -1.1) == NaN plus invalid exception",
2138 FUNC(pow) (-10.1, -1.1), INVALID_EXCEPTION);
2140 check_isinfp_exc ("pow (+0, -1) == +inf plus divide-by-zero exception",
2141 FUNC(pow) (0, -1), DIVIDE_BY_ZERO_EXCEPTION);
2142 check_isinfp_exc ("pow (+0, -11) == +inf plus divide-by-zero exception",
2143 FUNC(pow) (0, -11), DIVIDE_BY_ZERO_EXCEPTION);
2144 check_isinfn_exc ("pow (-0, -1) == -inf plus divide-by-zero exception",
2145 FUNC(pow) (minus_zero, -1), DIVIDE_BY_ZERO_EXCEPTION);
2146 check_isinfn_exc ("pow (-0, -11) == -inf plus divide-by-zero exception",
2147 FUNC(pow) (minus_zero, -11), DIVIDE_BY_ZERO_EXCEPTION);
2149 check_isinfp_exc ("pow (+0, -2) == +inf plus divide-by-zero exception",
2150 FUNC(pow) (0, -2), DIVIDE_BY_ZERO_EXCEPTION);
2151 check_isinfp_exc ("pow (+0, -11.1) == +inf plus divide-by-zero exception",
2152 FUNC(pow) (0, -11.1), DIVIDE_BY_ZERO_EXCEPTION);
2153 check_isinfp_exc ("pow (-0, -2) == +inf plus divide-by-zero exception",
2154 FUNC(pow) (minus_zero, -2), DIVIDE_BY_ZERO_EXCEPTION);
2155 check_isinfp_exc ("pow (-0, -11.1) == +inf plus divide-by-zero exception",
2156 FUNC(pow) (minus_zero, -11.1), DIVIDE_BY_ZERO_EXCEPTION);
2159 check ("pow (+0, 1) == +0", FUNC(pow) (0, 1), 0);
2160 check ("pow (+0, 11) == +0", FUNC(pow) (0, 11), 0);
2162 check ("pow (-0, 1) == -0", FUNC(pow) (minus_zero, 1), minus_zero);
2163 check ("pow (-0, 11) == -0", FUNC(pow) (minus_zero, 11), minus_zero);
2166 check ("pow (+0, 2) == +0", FUNC(pow) (0, 2), 0);
2167 check ("pow (+0, 11.1) == +0", FUNC(pow) (0, 11.1), 0);
2170 check ("pow (-0, 2) == +0", FUNC(pow) (minus_zero, 2), 0);
2171 check ("pow (-0, 11.1) == +0", FUNC(pow) (minus_zero, 11.1), 0);
2173 x = random_greater (1.0);
2174 check_isinfp_ext ("pow (x, +inf) == +inf for |x| > 1",
2175 FUNC(pow) (x, plus_infty), x);
2177 x = random_value (-1.0, 1.0);
2178 check_ext ("pow (x, +inf) == +0 for |x| < 1",
2179 FUNC(pow) (x, plus_infty), 0.0, x);
2181 x = random_greater (1.0);
2182 check_ext ("pow (x, -inf) == +0 for |x| > 1",
2183 FUNC(pow) (x, minus_infty), 0.0, x);
2185 x = random_value (-1.0, 1.0);
2186 check_isinfp_ext ("pow (x, -inf) == +inf for |x| < 1",
2187 FUNC(pow) (x, minus_infty), x);
2189 x = random_greater (0.0);
2190 check_isinfp_ext ("pow (+inf, y) == +inf for y > 0",
2191 FUNC(pow) (plus_infty, x), x);
2193 x = random_less (0.0);
2194 check_ext ("pow (+inf, y) == +0 for y < 0",
2195 FUNC(pow) (plus_infty, x), 0.0, x);
2197 x = (rand () % 1000000) * 2.0 + 1; /* Get random odd integer > 0 */
2198 check_isinfn_ext ("pow (-inf, y) == -inf for y an odd integer > 0",
2199 FUNC(pow) (minus_infty, x), x);
2201 x = ((rand () % 1000000) + 1) * 2.0; /* Get random even integer > 1 */
2202 check_isinfp_ext ("pow (-inf, y) == +inf for y > 0 and not an odd integer",
2203 FUNC(pow) (minus_infty, x), x);
2205 x = -((rand () % 1000000) * 2.0 + 1); /* Get random odd integer < 0 */
2206 check_ext ("pow (-inf, y) == -0 for y an odd integer < 0",
2207 FUNC(pow) (minus_infty, x), minus_zero, x);
2209 x = ((rand () % 1000000) + 1) * -2.0; /* Get random even integer < 0 */
2210 check_ext ("pow (-inf, y) == +0 for y < 0 and not an odd integer",
2211 FUNC(pow) (minus_infty, x), 0.0, x);
2214 x = (rand () % 1000000) * 2.0 + 1; /* Get random odd integer > 0 */
2215 check_ext ("pow (+0, y) == +0 for y an odd integer > 0",
2216 FUNC(pow) (0.0, x), 0.0, x);
2218 x = (rand () % 1000000) * 2.0 + 1; /* Get random odd integer > 0 */
2219 check_ext ("pow (-0, y) == -0 for y an odd integer > 0",
2220 FUNC(pow) (minus_zero, x), minus_zero, x);
2223 x = ((rand () % 1000000) + 1) * 2.0; /* Get random even integer > 1 */
2224 check_ext ("pow (+0, y) == +0 for y > 0 and not an odd integer",
2225 FUNC(pow) (0.0, x), 0.0, x);
2227 x = ((rand () % 1000000) + 1) * 2.0; /* Get random even integer > 1 */
2228 check_ext ("pow (-0, y) == +0 for y > 0 and not an odd integer",
2229 FUNC(pow) (minus_zero, x), 0.0, x);
2231 check_eps ("pow (0.7, 1.2) == 0.65180...", FUNC(pow) (0.7, 1.2),
2232 0.65180494056638638188L, CHOOSE(4e-17L, 0, 0));
2235 check ("pow (-7.49321e+133, -9.80818e+16) == 0",
2236 FUNC(pow) (-7.49321e+133, -9.80818e+16), 0);
2244 check ("fdim (+0, +0) = +0", FUNC(fdim) (0, 0), 0);
2245 check ("fdim (9, 0) = 9", FUNC(fdim) (9, 0), 9);
2246 check ("fdim (0, 9) = 0", FUNC(fdim) (0, 9), 0);
2247 check ("fdim (-9, 0) = 9", FUNC(fdim) (-9, 0), 0);
2248 check ("fdim (0, -9) = 9", FUNC(fdim) (0, -9), 9);
2250 check_isinfp ("fdim (+inf, 9) = +inf", FUNC(fdim) (plus_infty, 9));
2251 check_isinfp ("fdim (+inf, -9) = +inf", FUNC(fdim) (plus_infty, -9));
2252 check ("fdim (-inf, 9) = 0", FUNC(fdim) (minus_infty, 9), 0);
2253 check ("fdim (-inf, -9) = 0", FUNC(fdim) (minus_infty, -9), 0);
2254 check_isinfp ("fdim (+9, -inf) = +inf", FUNC(fdim) (9, minus_infty));
2255 check_isinfp ("fdim (-9, -inf) = +inf", FUNC(fdim) (-9, minus_infty));
2256 check ("fdim (9, inf) = 0", FUNC(fdim) (9, plus_infty), 0);
2257 check ("fdim (-9, inf) = 0", FUNC(fdim) (-9, plus_infty), 0);
2259 check_isnan ("fdim (0, NaN) = NaN", FUNC(fdim) (0, nan_value));
2260 check_isnan ("fdim (9, NaN) = NaN", FUNC(fdim) (9, nan_value));
2261 check_isnan ("fdim (-9, NaN) = NaN", FUNC(fdim) (-9, nan_value));
2262 check_isnan ("fdim (NaN, 9) = NaN", FUNC(fdim) (nan_value, 9));
2263 check_isnan ("fdim (NaN, -9) = NaN", FUNC(fdim) (nan_value, -9));
2264 check_isnan ("fdim (+inf, NaN) = NaN", FUNC(fdim) (plus_infty, nan_value));
2265 check_isnan ("fdim (-inf, NaN) = NaN", FUNC(fdim) (minus_infty, nan_value));
2266 check_isnan ("fdim (NaN, +inf) = NaN", FUNC(fdim) (nan_value, plus_infty));
2267 check_isnan ("fdim (NaN, -inf) = NaN", FUNC(fdim) (nan_value, minus_infty));
2268 check_isnan ("fdim (NaN, NaN) = NaN", FUNC(fdim) (nan_value, nan_value));
2275 check ("fmin (+0, +0) = +0", FUNC(fmin) (0, 0), 0);
2276 check ("fmin (9, 0) = 0", FUNC(fmin) (9, 0), 0);
2277 check ("fmin (0, 9) = 0", FUNC(fmin) (0, 9), 0);
2278 check ("fmin (-9, 0) = -9", FUNC(fmin) (-9, 0), -9);
2279 check ("fmin (0, -9) = -9", FUNC(fmin) (0, -9), -9);
2281 check ("fmin (+inf, 9) = 9", FUNC(fmin) (plus_infty, 9), 9);
2282 check ("fmin (9, +inf) = 9", FUNC(fmin) (9, plus_infty), 9);
2283 check ("fmin (+inf, -9) = -9", FUNC(fmin) (plus_infty, -9), -9);
2284 check ("fmin (-9, +inf) = -9", FUNC(fmin) (-9, plus_infty), -9);
2285 check_isinfn ("fmin (-inf, 9) = -inf", FUNC(fmin) (minus_infty, 9));
2286 check_isinfn ("fmin (-inf, -9) = -inf", FUNC(fmin) (minus_infty, -9));
2287 check_isinfn ("fmin (+9, -inf) = -inf", FUNC(fmin) (9, minus_infty));
2288 check_isinfn ("fmin (-9, -inf) = -inf", FUNC(fmin) (-9, minus_infty));
2290 check ("fmin (0, NaN) = 0", FUNC(fmin) (0, nan_value), 0);
2291 check ("fmin (9, NaN) = 9", FUNC(fmin) (9, nan_value), 9);
2292 check ("fmin (-9, NaN) = 9", FUNC(fmin) (-9, nan_value), -9);
2293 check ("fmin (NaN, 0) = 0", FUNC(fmin) (nan_value, 0), 0);
2294 check ("fmin (NaN, 9) = NaN", FUNC(fmin) (nan_value, 9), 9);
2295 check ("fmin (NaN, -9) = NaN", FUNC(fmin) (nan_value, -9), -9);
2296 check_isinfp ("fmin (+inf, NaN) = +inf", FUNC(fmin) (plus_infty, nan_value));
2297 check_isinfn ("fmin (-inf, NaN) = -inf", FUNC(fmin) (minus_infty, nan_value));
2298 check_isinfp ("fmin (NaN, +inf) = +inf", FUNC(fmin) (nan_value, plus_infty));
2299 check_isinfn ("fmin (NaN, -inf) = -inf", FUNC(fmin) (nan_value, minus_infty));
2300 check_isnan ("fmin (NaN, NaN) = NaN", FUNC(fmin) (nan_value, nan_value));
2307 check ("fmax (+0, +0) = +0", FUNC(fmax) (0, 0), 0);
2308 check ("fmax (9, 0) = 9", FUNC(fmax) (9, 0), 9);
2309 check ("fmax (0, 9) = 9", FUNC(fmax) (0, 9), 9);
2310 check ("fmax (-9, 0) = 0", FUNC(fmax) (-9, 0), 0);
2311 check ("fmax (0, -9) = 0", FUNC(fmax) (0, -9), 0);
2313 check_isinfp ("fmax (+inf, 9) = +inf", FUNC(fmax) (plus_infty, 9));
2314 check_isinfp ("fmax (9, +inf) = +inf", FUNC(fmax) (0, plus_infty));
2315 check_isinfp ("fmax (-9, +inf) = +inf", FUNC(fmax) (-9, plus_infty));
2316 check_isinfp ("fmax (+inf, -9) = +inf", FUNC(fmax) (plus_infty, -9));
2317 check ("fmax (-inf, 9) = 9", FUNC(fmax) (minus_infty, 9), 9);
2318 check ("fmax (-inf, -9) = -9", FUNC(fmax) (minus_infty, -9), -9);
2319 check ("fmax (+9, -inf) = 9", FUNC(fmax) (9, minus_infty), 9);
2320 check ("fmax (-9, -inf) = -9", FUNC(fmax) (-9, minus_infty), -9);
2322 check ("fmax (0, NaN) = 0", FUNC(fmax) (0, nan_value), 0);
2323 check ("fmax (9, NaN) = 9", FUNC(fmax) (9, nan_value), 9);
2324 check ("fmax (-9, NaN) = 9", FUNC(fmax) (-9, nan_value), -9);
2325 check ("fmax (NaN, 0) = 0", FUNC(fmax) (nan_value, 0), 0);
2326 check ("fmax (NaN, 9) = NaN", FUNC(fmax) (nan_value, 9), 9);
2327 check ("fmax (NaN, -9) = NaN", FUNC(fmax) (nan_value, -9), -9);
2328 check_isinfp ("fmax (+inf, NaN) = +inf", FUNC(fmax) (plus_infty, nan_value));
2329 check_isinfn ("fmax (-inf, NaN) = -inf", FUNC(fmax) (minus_infty, nan_value));
2330 check_isinfp ("fmax (NaN, +inf) = +inf", FUNC(fmax) (nan_value, plus_infty));
2331 check_isinfn ("fmax (NaN, -inf) = -inf", FUNC(fmax) (nan_value, minus_infty));
2332 check_isnan ("fmax (NaN, NaN) = NaN", FUNC(fmax) (nan_value, nan_value));
2341 x = random_greater (0);
2342 check_ext ("fmod (+0, y) == +0 for y != 0", FUNC(fmod) (0, x), 0, x);
2344 x = random_greater (0);
2345 check_ext ("fmod (-0, y) == -0 for y != 0", FUNC(fmod) (minus_zero, x),
2348 check_isnan_exc_ext ("fmod (+inf, y) == NaN plus invalid exception",
2349 FUNC(fmod) (plus_infty, x), INVALID_EXCEPTION, x);
2350 check_isnan_exc_ext ("fmod (-inf, y) == NaN plus invalid exception",
2351 FUNC(fmod) (minus_infty, x), INVALID_EXCEPTION, x);
2352 check_isnan_exc_ext ("fmod (x, +0) == NaN plus invalid exception",
2353 FUNC(fmod) (x, 0), INVALID_EXCEPTION, x);
2354 check_isnan_exc_ext ("fmod (x, -0) == NaN plus invalid exception",
2355 FUNC(fmod) (x, minus_zero), INVALID_EXCEPTION, x);
2357 x = random_greater (0);
2358 check_ext ("fmod (x, +inf) == x for x not infinite",
2359 FUNC(fmod) (x, plus_infty), x, x);
2360 x = random_greater (0);
2361 check_ext ("fmod (x, -inf) == x for x not infinite",
2362 FUNC(fmod) (x, minus_infty), x, x);
2364 check_eps ("fmod (6.5, 2.3) == 1.9", FUNC(fmod) (6.5, 2.3), 1.9,
2365 CHOOSE(5e-16, 1e-15, 2e-7));
2366 check_eps ("fmod (-6.5, 2.3) == -1.9", FUNC(fmod) (-6.5, 2.3), -1.9,
2367 CHOOSE(5e-16, 1e-15, 2e-7));
2368 check_eps ("fmod (6.5, -2.3) == 1.9", FUNC(fmod) (6.5, -2.3), 1.9,
2369 CHOOSE(5e-16, 1e-15, 2e-7));
2370 check_eps ("fmod (-6.5, -2.3) == -1.9", FUNC(fmod) (-6.5, -2.3), -1.9,
2371 CHOOSE(5e-16, 1e-15, 2e-7));
2378 nextafter_test (void)
2382 check ("nextafter (+0, +0) = +0", FUNC(nextafter) (0, 0), 0);
2383 check ("nextafter (-0, +0) = +0", FUNC(nextafter) (minus_zero, 0), 0);
2384 check ("nextafter (+0, -0) = -0", FUNC(nextafter) (0, minus_zero),
2386 check ("nextafter (-0, -0) = -0", FUNC(nextafter) (minus_zero, minus_zero),
2389 check ("nextafter (9, 9) = 9", FUNC(nextafter) (9, 9), 9);
2390 check ("nextafter (-9, -9) = -9", FUNC(nextafter) (-9, -9), -9);
2391 check_isinfp ("nextafter (+inf, +inf) = +inf",
2392 FUNC(nextafter) (plus_infty, plus_infty));
2393 check_isinfn ("nextafter (-inf, -inf) = -inf",
2394 FUNC(nextafter) (minus_infty, minus_infty));
2397 check_isnan ("nextafter (NaN, x) = NaN", FUNC(nextafter) (nan_value, x));
2398 check_isnan ("nextafter (x, NaN) = NaN", FUNC(nextafter) (x, nan_value));
2399 check_isnan ("nextafter (NaN, NaN) = NaN", FUNC(nextafter) (nan_value,
2402 /* XXX We need the hexadecimal FP number representation here for further
2408 copysign_test (void)
2410 check ("copysign (0, 4) = 0", FUNC(copysign) (0, 4), 0);
2411 check ("copysign (0, -4) = -0", FUNC(copysign) (0, -4), minus_zero);
2412 check ("copysign (-0, 4) = 0", FUNC(copysign) (minus_zero, 4), 0);
2413 check ("copysign (-0, -4) = -0", FUNC(copysign) (minus_zero, -4),
2416 check_isinfp ("copysign (+inf, 0) = +inf", FUNC(copysign) (plus_infty, 0));
2417 check_isinfn ("copysign (+inf, -0) = -inf", FUNC(copysign) (plus_infty,
2419 check_isinfp ("copysign (-inf, 0) = +inf", FUNC(copysign) (minus_infty, 0));
2420 check_isinfn ("copysign (-inf, -0) = -inf", FUNC(copysign) (minus_infty,
2423 check ("copysign (0, +inf) = 0", FUNC(copysign) (0, plus_infty), 0);
2424 check ("copysign (0, -inf) = -0", FUNC(copysign) (0, minus_zero),
2426 check ("copysign (-0, +inf) = 0", FUNC(copysign) (minus_zero, plus_infty),
2428 check ("copysign (-0, -inf) = -0", FUNC(copysign) (minus_zero, minus_zero),
2431 /* XXX More correctly we would have to check the sign of the NaN. */
2432 check_isnan ("copysign (+NaN, 0) = +NaN", FUNC(copysign) (nan_value, 0));
2433 check_isnan ("copysign (+NaN, -0) = -NaN", FUNC(copysign) (nan_value,
2435 check_isnan ("copysign (-NaN, 0) = +NaN", FUNC(copysign) (-nan_value, 0));
2436 check_isnan ("copysign (-NaN, -0) = -NaN", FUNC(copysign) (-nan_value,
2444 check ("trunc(0) = 0", FUNC(trunc) (0), 0);
2445 check ("trunc(-0) = -0", FUNC(trunc) (minus_zero), minus_zero);
2446 check ("trunc(0.625) = 0", FUNC(trunc) (0.625), 0);
2447 check ("trunc(-0.625) = -0", FUNC(trunc) (-0.625), minus_zero);
2448 check ("trunc(1) = 1", FUNC(trunc) (1), 1);
2449 check ("trunc(-1) = -1", FUNC(trunc) (-1), -1);
2450 check ("trunc(1.625) = 1", FUNC(trunc) (1.625), 1);
2451 check ("trunc(-1.625) = -1", FUNC(trunc) (-1.625), -1);
2453 check ("trunc(1048580.625) = 1048580", FUNC(trunc) (1048580.625L),
2455 check ("trunc(-1048580.625) = -1048580", FUNC(trunc) (-1048580.625L),
2458 check ("trunc(8388610.125) = 8388610", FUNC(trunc) (8388610.125L),
2460 check ("trunc(-8388610.125) = -8388610", FUNC(trunc) (-8388610.125L),
2463 check ("trunc(4294967296.625) = 4294967296", FUNC(trunc) (4294967296.625L),
2465 check ("trunc(-4294967296.625) = -4294967296",
2466 FUNC(trunc) (-4294967296.625L), -4294967296.0L);
2468 check_isinfp ("trunc(+inf) = +inf", FUNC(trunc) (plus_infty));
2469 check_isinfn ("trunc(-inf) = -inf", FUNC(trunc) (minus_infty));
2470 check_isnan ("trunc(NaN) = NaN", FUNC(trunc) (nan_value));
2480 /* XXX Tests fuer negative x are missing */
2481 check ("sqrt (0) == 0", FUNC(sqrt) (0), 0);
2482 check_isnan ("sqrt (NaN) == NaN", FUNC(sqrt) (nan_value));
2483 check_isinfp ("sqrt (+inf) == +inf", FUNC(sqrt) (plus_infty));
2485 check ("sqrt (-0) == -0", FUNC(sqrt) (0), 0);
2487 x = random_less (0.0);
2488 check_isnan_exc_ext ("sqrt (x) == NaN plus invalid exception for x < 0",
2489 FUNC(sqrt) (x), INVALID_EXCEPTION, x);
2491 x = random_value (0, 10000);
2492 check_ext ("sqrt (x*x) == x", FUNC(sqrt) (x*x), x, x);
2493 check ("sqrt (4) == 2", FUNC(sqrt) (4), 2);
2494 check ("sqrt (2) == 1.14142...", FUNC(sqrt) (2), M_SQRT2l);
2495 check ("sqrt (0.25) == 0.5", FUNC(sqrt) (0.25), 0.5);
2496 check ("sqrt (6642.25) == 81.5", FUNC(sqrt) (6642.25), 81.5);
2497 check_eps ("sqrt (15239.903) == 123.45", FUNC(sqrt) (15239.903), 123.45,
2498 CHOOSE (3e-6L, 3e-6, 8e-6));
2499 check_eps ("sqrt (0.7) == 0.8366600265", FUNC(sqrt) (0.7),
2500 0.83666002653407554798L, CHOOSE(3e-17L, 0, 0));
2504 remainder_test (void)
2508 result = FUNC(remainder) (1, 0);
2509 check_isnan_exc ("remainder(1, +0) == NaN plus invalid exception",
2510 result, INVALID_EXCEPTION);
2512 result = FUNC(remainder) (1, minus_zero);
2513 check_isnan_exc ("remainder(1, -0) == NaN plus invalid exception",
2514 result, INVALID_EXCEPTION);
2516 result = FUNC(remainder) (plus_infty, 1);
2517 check_isnan_exc ("remainder(+inf, 1) == NaN plus invalid exception",
2518 result, INVALID_EXCEPTION);
2520 result = FUNC(remainder) (minus_infty, 1);
2521 check_isnan_exc ("remainder(-inf, 1) == NaN plus invalid exception",
2522 result, INVALID_EXCEPTION);
2524 result = FUNC(remainder) (1.625, 1.0);
2525 check ("remainder(1.625, 1.0) == -0.375", result, -0.375);
2527 result = FUNC(remainder) (-1.625, 1.0);
2528 check ("remainder(-1.625, 1.0) == 0.375", result, 0.375);
2530 result = FUNC(remainder) (1.625, -1.0);
2531 check ("remainder(1.625, -1.0) == -0.375", result, -0.375);
2533 result = FUNC(remainder) (-1.625, -1.0);
2534 check ("remainder(-1.625, -1.0) == 0.375", result, 0.375);
2536 result = FUNC(remainder) (5.0, 2.0);
2537 check ("remainder(5.0, 2.0) == 1.0", result, 1.0);
2539 result = FUNC(remainder) (3.0, 2.0);
2540 check ("remainder(3.0, 2.0) == -1.0", result, -1.0);
2550 result = FUNC(remquo) (1, 0, &quo);
2551 check_isnan_exc ("remquo(1, +0, &x) == NaN plus invalid exception",
2552 result, INVALID_EXCEPTION);
2554 result = FUNC(remquo) (1, minus_zero, &quo);
2555 check_isnan_exc ("remquo(1, -0, &x) == NaN plus invalid exception",
2556 result, INVALID_EXCEPTION);
2558 result = FUNC(remquo) (plus_infty, 1, &quo);
2559 check_isnan_exc ("remquo(+inf, 1, &x) == NaN plus invalid exception",
2560 result, INVALID_EXCEPTION);
2562 result = FUNC(remquo) (minus_infty, 1, &quo);
2563 check_isnan_exc ("remquo(-inf, 1, &x) == NaN plus invalid exception",
2564 result, INVALID_EXCEPTION);
2566 result = FUNC(remquo) (1.625, 1.0, &quo);
2567 check ("remquo(1.625, 1.0, &x) == -0.375", result, -0.375);
2568 check_long ("remquo(1.625, 1.0, &x) puts 2 in x", quo, 2);
2570 result = FUNC(remquo) (-1.625, 1.0, &quo);
2571 check ("remquo(-1.625, 1.0, &x) == 0.375", result, 0.375);
2572 check_long ("remquo(-1.625, 1.0, &x) puts -2 in x", quo, -2);
2574 result = FUNC(remquo) (1.625, -1.0, &quo);
2575 check ("remquo(1.625, -1.0, &x) == -0.375", result, -0.375);
2576 check_long ("remquo(1.625, -1.0, &x) puts -2 in x", quo, -2);
2578 result = FUNC(remquo) (-1.625, -1.0, &quo);
2579 check ("remquo(-1.625, -1.0, &x) == 0.375", result, 0.375);
2580 check_long ("remquo(-1.625, -1.0, &x) puts 2 in x", quo, 2);
2582 result = FUNC(remquo) (5.0, 2.0, &quo);
2583 check ("remquo(5.0, 2.0, &x) == 1.0", result, 1.0);
2584 check_long ("remquo (5.0, 2.0, &x) puts 2 in x", quo, 2);
2586 result = FUNC(remquo) (3.0, 2.0, &quo);
2587 check ("remquo(3.0, 2.0, &x) == -1.0", result, -1.0);
2588 check_long ("remquo (3.0, 2.0, &x) puts 2 in x", quo, 2);
2595 __complex__ MATHTYPE result;
2597 result = FUNC(cexp) (BUILD_COMPLEX (plus_zero, plus_zero));
2598 check ("real(cexp(0 + 0i)) = 1", __real__ result, 1);
2599 check ("imag(cexp(0 + 0i)) = 0", __imag__ result, 0);
2600 result = FUNC(cexp) (BUILD_COMPLEX (minus_zero, plus_zero));
2601 check ("real(cexp(-0 + 0i)) = 1", __real__ result, 1);
2602 check ("imag(cexp(-0 + 0i)) = 0", __imag__ result, 0);
2603 result = FUNC(cexp) (BUILD_COMPLEX (plus_zero, minus_zero));
2604 check ("real(cexp(0 - 0i)) = 1", __real__ result, 1);
2605 check ("imag(cexp(0 - 0i)) = -0", __imag__ result, minus_zero);
2606 result = FUNC(cexp) (BUILD_COMPLEX (minus_zero, minus_zero));
2607 check ("real(cexp(-0 - 0i)) = 1", __real__ result, 1);
2608 check ("imag(cexp(-0 - 0i)) = -0", __imag__ result, minus_zero);
2610 result = FUNC(cexp) (BUILD_COMPLEX (plus_infty, plus_zero));
2611 check_isinfp ("real(cexp(+inf + 0i)) = +inf", __real__ result);
2612 check ("imag(cexp(+inf + 0i)) = 0", __imag__ result, 0);
2613 result = FUNC(cexp) (BUILD_COMPLEX (plus_infty, minus_zero));
2614 check_isinfp ("real(cexp(+inf - 0i)) = +inf", __real__ result);
2615 check ("imag(cexp(+inf - 0i)) = -0", __imag__ result, minus_zero);
2617 result = FUNC(cexp) (BUILD_COMPLEX (minus_infty, plus_zero));
2618 check ("real(cexp(-inf + 0i)) = 0", __real__ result, 0);
2619 check ("imag(cexp(-inf + 0i)) = 0", __imag__ result, 0);
2620 result = FUNC(cexp) (BUILD_COMPLEX (minus_infty, minus_zero));
2621 check ("real(cexp(-inf - 0i)) = 0", __real__ result, 0);
2622 check ("imag(cexp(-inf - 0i)) = -0", __imag__ result, minus_zero);
2625 result = FUNC(cexp) (BUILD_COMPLEX (0.0, plus_infty));
2626 check_isnan_exc ("real(cexp(0 + i inf)) = NaN plus invalid exception",
2627 __real__ result, INVALID_EXCEPTION);
2628 check_isnan ("imag(cexp(0 + i inf)) = NaN plus invalid exception",
2631 #if defined __GNUC__ && __GNUC__ <= 2 && __GNUC_MINOR__ <= 7
2633 printf ("The following test for cexp might fail due to a gcc compiler error!\n");
2636 result = FUNC(cexp) (BUILD_COMPLEX (minus_zero, plus_infty));
2637 check_isnan_exc ("real(cexp(-0 + i inf)) = NaN plus invalid exception",
2638 __real__ result, INVALID_EXCEPTION);
2639 check_isnan ("imag(cexp(-0 + i inf)) = NaN plus invalid exception",
2641 result = FUNC(cexp) (BUILD_COMPLEX (0.0, minus_infty));
2642 check_isnan_exc ("real(cexp(0 - i inf)) = NaN plus invalid exception",
2643 __real__ result, INVALID_EXCEPTION);
2644 check_isnan ("imag(cexp(0 - i inf)) = NaN plus invalid exception",
2646 result = FUNC(cexp) (BUILD_COMPLEX (minus_zero, minus_infty));
2647 check_isnan_exc ("real(cexp(-0 - i inf)) = NaN plus invalid exception",
2648 __real__ result, INVALID_EXCEPTION);
2649 check_isnan ("imag(cexp(-0 - i inf)) = NaN plus invalid exception",
2652 result = FUNC(cexp) (BUILD_COMPLEX (100.0, plus_infty));
2653 check_isnan_exc ("real(cexp(100.0 + i inf)) = NaN plus invalid exception",
2654 __real__ result, INVALID_EXCEPTION);
2655 check_isnan ("imag(cexp(100.0 + i inf)) = NaN plus invalid exception",
2657 result = FUNC(cexp) (BUILD_COMPLEX (-100.0, plus_infty));
2658 check_isnan_exc ("real(cexp(-100.0 + i inf)) = NaN plus invalid exception",
2659 __real__ result, INVALID_EXCEPTION);
2660 check_isnan ("imag(cexp(-100.0 + i inf)) = NaN plus invalid exception",
2662 result = FUNC(cexp) (BUILD_COMPLEX (100.0, minus_infty));
2663 check_isnan_exc ("real(cexp(100.0 - i inf)) = NaN plus invalid exception",
2664 __real__ result, INVALID_EXCEPTION);
2665 check_isnan ("imag(cexp(100.0 - i inf)) = NaN plus invalid exception",
2667 result = FUNC(cexp) (BUILD_COMPLEX (-100.0, minus_infty));
2668 check_isnan_exc ("real(cexp(-100.0 - i inf)) = NaN plus invalid exception",
2669 __real__ result, INVALID_EXCEPTION);
2670 check_isnan ("imag(cexp(-100.0 - i inf)) = NaN", __imag__ result);
2672 result = FUNC(cexp) (BUILD_COMPLEX (minus_infty, 2.0));
2673 check ("real(cexp(-inf + 2.0i)) = -0", __real__ result, minus_zero);
2674 check ("imag(cexp(-inf + 2.0i)) = 0", __imag__ result, 0);
2675 result = FUNC(cexp) (BUILD_COMPLEX (minus_infty, 4.0));
2676 check ("real(cexp(-inf + 4.0i)) = -0", __real__ result, minus_zero);
2677 check ("imag(cexp(-inf + 4.0i)) = -0", __imag__ result, minus_zero);
2679 result = FUNC(cexp) (BUILD_COMPLEX (plus_infty, 2.0));
2680 check_isinfn ("real(cexp(+inf + 2.0i)) = -inf", __real__ result);
2681 check_isinfp ("imag(cexp(+inf + 2.0i)) = +inf", __imag__ result);
2682 result = FUNC(cexp) (BUILD_COMPLEX (plus_infty, 4.0));
2683 check_isinfn ("real(cexp(+inf + 4.0i)) = -inf", __real__ result);
2684 check_isinfn ("imag(cexp(+inf + 4.0i)) = -inf", __imag__ result);
2686 result = FUNC(cexp) (BUILD_COMPLEX (plus_infty, plus_infty));
2687 check_isinfp_exc ("real(cexp(+inf + i inf)) = +inf plus invalid exception",
2688 __real__ result, INVALID_EXCEPTION);
2689 check_isnan ("imag(cexp(+inf + i inf)) = NaN plus invalid exception",
2691 result = FUNC(cexp) (BUILD_COMPLEX (plus_infty, minus_infty));
2692 check_isinfp_exc ("real(cexp(+inf - i inf)) = +inf plus invalid exception",
2693 __real__ result, INVALID_EXCEPTION);
2694 check_isnan ("imag(cexp(+inf - i inf)) = NaN plus invalid exception",
2697 result = FUNC(cexp) (BUILD_COMPLEX (minus_infty, plus_infty));
2698 check ("real(cexp(-inf + i inf)) = 0", __real__ result, 0);
2699 check ("imag(cexp(-inf + i inf)) = 0", __imag__ result, 0);
2700 result = FUNC(cexp) (BUILD_COMPLEX (minus_infty, minus_infty));
2701 check ("real(cexp(-inf - i inf)) = 0", __real__ result, 0);
2702 check ("imag(cexp(-inf - i inf)) = -0", __imag__ result, minus_zero);
2704 result = FUNC(cexp) (BUILD_COMPLEX (minus_infty, nan_value));
2705 check ("real(cexp(-inf + i NaN)) = 0", __real__ result, 0);
2706 check ("imag(cexp(-inf + i NaN)) = 0", fabs (__imag__ result), 0);
2708 result = FUNC(cexp) (BUILD_COMPLEX (plus_infty, nan_value));
2709 check_isinfp ("real(cexp(+inf + i NaN)) = +inf", __real__ result);
2710 check_isnan ("imag(cexp(+inf + i NaN)) = NaN", __imag__ result);
2712 result = FUNC(cexp) (BUILD_COMPLEX (nan_value, 0.0));
2713 check_isnan_maybe_exc ("real(cexp(NaN + i0)) = NaN plus maybe invalid exception",
2714 __real__ result, INVALID_EXCEPTION);
2715 check_isnan ("imag(cexp(NaN + i0)) = NaN plus maybe invalid exception",
2717 result = FUNC(cexp) (BUILD_COMPLEX (nan_value, 1.0));
2718 check_isnan_maybe_exc ("real(cexp(NaN + 1i)) = NaN plus maybe invalid exception",
2719 __real__ result, INVALID_EXCEPTION);
2720 check_isnan ("imag(cexp(NaN + 1i)) = NaN plus maybe invalid exception",
2722 result = FUNC(cexp) (BUILD_COMPLEX (nan_value, plus_infty));
2723 check_isnan_maybe_exc ("real(cexp(NaN + i inf)) = NaN plus maybe invalid exception",
2724 __real__ result, INVALID_EXCEPTION);
2725 check_isnan ("imag(cexp(NaN + i inf)) = NaN plus maybe invalid exception",
2728 result = FUNC(cexp) (BUILD_COMPLEX (0, nan_value));
2729 check_isnan_maybe_exc ("real(cexp(0 + i NaN)) = NaN plus maybe invalid exception",
2730 __real__ result, INVALID_EXCEPTION);
2731 check_isnan ("imag(cexp(0 + i NaN)) = NaN plus maybe invalid exception",
2733 result = FUNC(cexp) (BUILD_COMPLEX (1, nan_value));
2734 check_isnan_maybe_exc ("real(cexp(1 + i NaN)) = NaN plus maybe invalid exception",
2735 __real__ result, INVALID_EXCEPTION);
2736 check_isnan ("imag(cexp(1 + i NaN)) = NaN plus maybe invalid exception",
2739 result = FUNC(cexp) (BUILD_COMPLEX (nan_value, nan_value));
2740 check_isnan ("real(cexp(NaN + i NaN)) = NaN", __real__ result);
2741 check_isnan ("imag(cexp(NaN + i NaN)) = NaN", __imag__ result);
2743 result = FUNC(cexp) (BUILD_COMPLEX (0.7, 1.2));
2744 check_eps ("real(cexp(0.7 + i 1.2)) == 0.72969...", __real__ result,
2745 0.7296989091503236012L, CHOOSE(6e-17L, 2e-16, 2e-7));
2746 check_eps ("imag(cexp(0.7 + i 1.2)) == 1.87689...", __imag__ result,
2747 1.8768962328348102821L, CHOOSE(2e-16L, 2.5e-16, 3e-7));
2749 result = FUNC(cexp) (BUILD_COMPLEX (-2, -3));
2750 check_eps ("real(cexp(-2 - i 3)) == -0.13398...", __real__ result,
2751 -0.1339809149295426134L, CHOOSE(6.8e-20L, 0, 2e-8));
2752 check_eps ("imag(cexp(-2 - i 3)) == -0.01909...", __imag__ result,
2753 -0.0190985162611351964L, CHOOSE(4e-20L, 0, 2e-9));
2760 __complex__ MATHTYPE result;
2762 result = FUNC(csin) (BUILD_COMPLEX (0.0, 0.0));
2763 check ("real(csin(0 + 0i)) = 0", __real__ result, 0);
2764 check ("imag(csin(0 + 0i)) = 0", __imag__ result, 0);
2765 result = FUNC(csin) (BUILD_COMPLEX (minus_zero, 0.0));
2766 check ("real(csin(-0 + 0i)) = -0", __real__ result, minus_zero);
2767 check ("imag(csin(-0 + 0i)) = 0", __imag__ result, 0);
2768 result = FUNC(csin) (BUILD_COMPLEX (0.0, minus_zero));
2769 check ("real(csin(0 - 0i)) = 0", __real__ result, 0);
2770 check ("imag(csin(0 - 0i)) = -0", __imag__ result, minus_zero);
2771 result = FUNC(csin) (BUILD_COMPLEX (minus_zero, minus_zero));
2772 check ("real(csin(-0 - 0i)) = -0", __real__ result, minus_zero);
2773 check ("imag(csin(-0 - 0i)) = -0", __imag__ result, minus_zero);
2775 result = FUNC(csin) (BUILD_COMPLEX (0.0, plus_infty));
2776 check ("real(csin(0 + i Inf)) = 0", __real__ result, 0);
2777 check_isinfp ("imag(csin(0 + i Inf)) = +Inf", __imag__ result);
2778 result = FUNC(csin) (BUILD_COMPLEX (minus_zero, plus_infty));
2779 check ("real(csin(-0 + i Inf)) = -0", __real__ result, minus_zero);
2780 check_isinfp ("imag(csin(-0 + i Inf)) = +Inf", __imag__ result);
2781 result = FUNC(csin) (BUILD_COMPLEX (0.0, minus_infty));
2782 check ("real(csin(0 - i Inf)) = 0", __real__ result, 0);
2783 check_isinfn ("imag(csin(0 - i Inf)) = -Inf", __imag__ result);
2784 result = FUNC(csin) (BUILD_COMPLEX (minus_zero, minus_infty));
2785 check ("real(csin(-0 - i Inf)) = -0", __real__ result, minus_zero);
2786 check_isinfn("imag(csin(-0 - i Inf)) = -Inf", __imag__ result);
2788 result = FUNC(csin) (BUILD_COMPLEX (plus_infty, 0.0));
2789 check_isnan_exc ("real(csin(+Inf + 0i)) = NaN plus invalid exception",
2790 __real__ result, INVALID_EXCEPTION);
2791 check ("imag(csin(+Inf + 0i)) = +-0 plus invalid exception",
2792 FUNC(fabs) (__imag__ result), 0);
2793 result = FUNC(csin) (BUILD_COMPLEX (minus_infty, 0.0));
2794 check_isnan_exc ("real(csin(-Inf + 0i)) = NaN plus invalid exception",
2795 __real__ result, INVALID_EXCEPTION);
2796 check ("imag(csin(-Inf + 0i)) = +-0 plus invalid exception",
2797 FUNC(fabs) (__imag__ result), 0);
2798 result = FUNC(csin) (BUILD_COMPLEX (plus_infty, minus_zero));
2799 check_isnan_exc ("real(csin(+Inf - 0i)) = NaN plus invalid exception",
2800 __real__ result, INVALID_EXCEPTION);
2801 check ("imag(csin(+Inf - 0i)) = +-0 plus invalid exception",
2802 FUNC(fabs) (__imag__ result), 0.0);
2803 result = FUNC(csin) (BUILD_COMPLEX (minus_infty, minus_zero));
2804 check_isnan_exc ("real(csin(-Inf - 0i)) = NaN plus invalid exception",
2805 __real__ result, INVALID_EXCEPTION);
2806 check ("imag(csin(-Inf - 0i)) = +-0 plus invalid exception",
2807 FUNC(fabs) (__imag__ result), 0.0);
2809 result = FUNC(csin) (BUILD_COMPLEX (plus_infty, plus_infty));
2810 check_isnan_exc ("real(csin(+Inf + i Inf)) = NaN plus invalid exception",
2811 __real__ result, INVALID_EXCEPTION);
2812 check_isinfp ("imag(csin(+Inf + i Inf)) = +-Inf plus invalid exception",
2813 FUNC(fabs) (__imag__ result));
2814 result = FUNC(csin) (BUILD_COMPLEX (minus_infty, plus_infty));
2815 check_isnan_exc ("real(csin(-Inf + i Inf)) = NaN plus invalid exception",
2816 __real__ result, INVALID_EXCEPTION);
2817 check_isinfp ("imag(csin(-Inf + i Inf)) = +-Inf plus invalid exception",
2818 FUNC(fabs) (__imag__ result));
2819 result = FUNC(csin) (BUILD_COMPLEX (plus_infty, minus_infty));
2820 check_isnan_exc ("real(csin(Inf - i Inf)) = NaN plus invalid exception",
2821 __real__ result, INVALID_EXCEPTION);
2822 check_isinfp ("imag(csin(Inf - i Inf)) = +-Inf plus invalid exception",
2823 FUNC(fabs) (__imag__ result));
2824 result = FUNC(csin) (BUILD_COMPLEX (minus_infty, minus_infty));
2825 check_isnan_exc ("real(csin(-Inf - i Inf)) = NaN plus invalid exception",
2826 __real__ result, INVALID_EXCEPTION);
2827 check_isinfp ("imag(csin(-Inf - i Inf)) = +-Inf plus invalid exception",
2828 FUNC(fabs) (__imag__ result));
2830 result = FUNC(csin) (BUILD_COMPLEX (plus_infty, 6.75));
2831 check_isnan_exc ("real(csin(+Inf + i 6.75)) = NaN plus invalid exception",
2832 __real__ result, INVALID_EXCEPTION);
2833 check_isnan ("imag(csin(+Inf + i6.75)) = NaN plus invalid exception",
2835 result = FUNC(csin) (BUILD_COMPLEX (plus_infty, -6.75));
2836 check_isnan_exc ("real(csin(+Inf - i 6.75)) = NaN plus invalid exception",
2837 __real__ result, INVALID_EXCEPTION);
2838 check_isnan ("imag(csin(+Inf - i6.75)) = NaN plus invalid exception",
2840 result = FUNC(csin) (BUILD_COMPLEX (minus_infty, 6.75));
2841 check_isnan_exc ("real(csin(-Inf + i6.75)) = NaN plus invalid exception",
2842 __real__ result, INVALID_EXCEPTION);
2843 check_isnan ("imag(csin(-Inf + i6.75)) = NaN plus invalid exception",
2845 result = FUNC(csin) (BUILD_COMPLEX (minus_infty, -6.75));
2846 check_isnan_exc ("real(csin(-Inf - i6.75)) = NaN plus invalid exception",
2847 __real__ result, INVALID_EXCEPTION);
2848 check_isnan ("imag(csin(-Inf - i6.75)) = NaN plus invalid exception",
2851 result = FUNC(csin) (BUILD_COMPLEX (4.625, plus_infty));
2852 check_isinfn ("real(csin(4.625 + i Inf)) = -Inf", __real__ result);
2853 check_isinfn ("imag(csin(4.625 + i Inf)) = -Inf", __imag__ result);
2854 result = FUNC(csin) (BUILD_COMPLEX (4.625, minus_infty));
2855 check_isinfn ("real(csin(4.625 - i Inf)) = -Inf", __real__ result);
2856 check_isinfp ("imag(csin(4.625 - i Inf)) = +Inf", __imag__ result);
2857 result = FUNC(csin) (BUILD_COMPLEX (-4.625, plus_infty));
2858 check_isinfp ("real(csin(-4.625 + i Inf)) = +Inf", __real__ result);
2859 check_isinfn ("imag(csin(-4.625 + i Inf)) = -Inf", __imag__ result);
2860 result = FUNC(csin) (BUILD_COMPLEX (-4.625, minus_infty));
2861 check_isinfp ("real(csin(-4.625 - i Inf)) = +Inf", __real__ result);
2862 check_isinfp ("imag(csin(-4.625 - i Inf)) = +Inf", __imag__ result);
2864 result = FUNC(csin) (BUILD_COMPLEX (nan_value, 0.0));
2865 check_isnan ("real(csin(NaN + i0)) = NaN", __real__ result);
2866 check ("imag(csin(NaN + i0)) = +-0", FUNC(fabs) (__imag__ result), 0);
2867 result = FUNC(csin) (BUILD_COMPLEX (nan_value, minus_zero));
2868 check_isnan ("real(csin(NaN - i0)) = NaN", __real__ result);
2869 check ("imag(csin(NaN - i0)) = +-0", FUNC(fabs) (__imag__ result), 0);
2871 result = FUNC(csin) (BUILD_COMPLEX (nan_value, plus_infty));
2872 check_isnan ("real(csin(NaN + i Inf)) = NaN", __real__ result);
2873 check_isinfp ("imag(csin(NaN + i Inf)) = +-Inf",
2874 FUNC(fabs) (__imag__ result));
2875 result = FUNC(csin) (BUILD_COMPLEX (nan_value, minus_infty));
2876 check_isnan ("real(csin(NaN - i Inf)) = NaN", __real__ result);
2877 check_isinfp ("real(csin(NaN - i Inf)) = +-Inf",
2878 FUNC(fabs) (__imag__ result));
2880 result = FUNC(csin) (BUILD_COMPLEX (nan_value, 9.0));
2881 check_isnan_maybe_exc ("real(csin(NaN + i9.0)) = NaN plus maybe invalid exception",
2882 __real__ result, INVALID_EXCEPTION);
2883 check_isnan ("imag(csin(NaN + i9.0)) = NaN plus maybe invalid exception",
2885 result = FUNC(csin) (BUILD_COMPLEX (nan_value, -9.0));
2886 check_isnan_maybe_exc ("real(csin(NaN - i9.0)) = NaN plus maybe invalid exception",
2887 __real__ result, INVALID_EXCEPTION);
2888 check_isnan ("imag(csin(NaN - i9.0)) = NaN plus maybe invalid exception",
2891 result = FUNC(csin) (BUILD_COMPLEX (0.0, nan_value));
2892 check ("real(csin(0 + i NaN))", __real__ result, 0.0);
2893 check_isnan ("imag(csin(0 + i NaN)) = NaN", __imag__ result);
2894 result = FUNC(csin) (BUILD_COMPLEX (minus_zero, nan_value));
2895 check ("real(csin(-0 + i NaN)) = -0", __real__ result, minus_zero);
2896 check_isnan ("imag(csin(-0 + NaN)) = NaN", __imag__ result);
2898 result = FUNC(csin) (BUILD_COMPLEX (10.0, nan_value));
2899 check_isnan_maybe_exc ("real(csin(10 + i NaN)) = NaN plus maybe invalid exception",
2900 __real__ result, INVALID_EXCEPTION);
2901 check_isnan ("imag(csin(10 + i NaN)) = NaN plus maybe invalid exception",
2903 result = FUNC(csin) (BUILD_COMPLEX (nan_value, -10.0));
2904 check_isnan_maybe_exc ("real(csin(-10 + i NaN)) = NaN plus maybe invalid exception",
2905 __real__ result, INVALID_EXCEPTION);
2906 check_isnan ("imag(csin(-10 + i NaN)) = NaN plus maybe invalid exception",
2909 result = FUNC(csin) (BUILD_COMPLEX (plus_infty, nan_value));
2910 check_isnan_maybe_exc ("real(csin(+Inf + i NaN)) = NaN plus maybe invalid exception",
2911 __real__ result, INVALID_EXCEPTION);
2912 check_isnan ("imag(csin(+Inf + i NaN)) = NaN plus maybe invalid exception",
2914 result = FUNC(csin) (BUILD_COMPLEX (minus_infty, nan_value));
2915 check_isnan_maybe_exc ("real(csin(-Inf + i NaN)) = NaN plus maybe invalid exception",
2916 __real__ result, INVALID_EXCEPTION);
2917 check_isnan ("imag(csin(-Inf + i NaN)) = NaN plus maybe invalid exception",
2920 result = FUNC(csin) (BUILD_COMPLEX (nan_value, nan_value));
2921 check_isnan ("real(csin(NaN + i NaN)) = NaN", __real__ result);
2922 check_isnan ("imag(csin(NaN + i NaN)) = NaN", __imag__ result);
2924 result = FUNC(csin) (BUILD_COMPLEX (0.7, 1.2));
2925 check_eps ("real(csin(0.7 + i 1.2)) = 1.166456341...", __real__ result,
2926 1.1664563419657581376L, CHOOSE(2e-16L, 0, 0));
2927 check_eps ("imag(csin(0.7 + i 1.2)) = 1.154499724...", __imag__ result,
2928 1.1544997246948547371L, CHOOSE(2e-17L, 0, 2e-7));
2930 result = FUNC(csin) (BUILD_COMPLEX (-2, -3));
2931 check_eps ("real(csin(-2 - i 3)) == -9.15449...", __real__ result,
2932 -9.1544991469114295734L, CHOOSE(4e-18L, 0, 1e-6));
2933 check_eps ("imag(csin(-2 - i 3)) == -4.16890...", __imag__ result,
2934 4.1689069599665643507L, CHOOSE(2e-17L, 0, 5e-7));
2941 __complex__ MATHTYPE result;
2943 result = FUNC(csinh) (BUILD_COMPLEX (0.0, 0.0));
2944 check ("real(csinh(0 + 0i)) = 0", __real__ result, 0);
2945 check ("imag(csinh(0 + 0i)) = 0", __imag__ result, 0);
2946 result = FUNC(csinh) (BUILD_COMPLEX (minus_zero, 0.0));
2947 check ("real(csinh(-0 + 0i)) = -0", __real__ result, minus_zero);
2948 check ("imag(csinh(-0 + 0i)) = 0", __imag__ result, 0);
2949 result = FUNC(csinh) (BUILD_COMPLEX (0.0, minus_zero));
2950 check ("real(csinh(0 - 0i)) = 0", __real__ result, 0);
2951 check ("imag(csinh(0 - 0i)) = -0", __imag__ result, minus_zero);
2952 result = FUNC(csinh) (BUILD_COMPLEX (minus_zero, minus_zero));
2953 check ("real(csinh(-0 - 0i)) = -0", __real__ result, minus_zero);
2954 check ("imag(csinh(-0 - 0i)) = -0", __imag__ result, minus_zero);
2956 result = FUNC(csinh) (BUILD_COMPLEX (0.0, plus_infty));
2957 check_exc ("real(csinh(0 + i Inf)) = +-0 plus invalid exception",
2958 FUNC(fabs) (__real__ result), 0, INVALID_EXCEPTION);
2959 check_isnan ("imag(csinh(0 + i Inf)) = NaN plus invalid exception",
2961 result = FUNC(csinh) (BUILD_COMPLEX (minus_zero, plus_infty));
2962 check_exc ("real(csinh(-0 + i Inf)) = +-0 plus invalid exception",
2963 FUNC(fabs) (__real__ result), 0, INVALID_EXCEPTION);
2964 check_isnan ("imag(csinh(-0 + i Inf)) = NaN plus invalid exception",
2966 result = FUNC(csinh) (BUILD_COMPLEX (0.0, minus_infty));
2967 check_exc ("real(csinh(0 - i Inf)) = +-0 plus invalid exception",
2968 FUNC(fabs) (__real__ result), 0, INVALID_EXCEPTION);
2969 check_isnan ("imag(csinh(0 - i Inf)) = NaN plus invalid exception",
2971 result = FUNC(csinh) (BUILD_COMPLEX (minus_zero, minus_infty));
2972 check_exc ("real(csinh(-0 - i Inf)) = +-0 plus invalid exception",
2973 FUNC(fabs) (__real__ result), 0, INVALID_EXCEPTION);
2974 check_isnan ("imag(csinh(-0 - i Inf)) = NaN plus invalid exception",
2977 result = FUNC(csinh) (BUILD_COMPLEX (plus_infty, 0.0));
2978 check_isinfp ("real(csinh(+Inf + 0i)) = +Inf", __real__ result);
2979 check ("imag(csinh(+Inf + 0i)) = 0", __imag__ result, 0);
2980 result = FUNC(csinh) (BUILD_COMPLEX (minus_infty, 0.0));
2981 check_isinfn ("real(csinh(-Inf + 0i)) = -Inf", __real__ result);
2982 check ("imag(csinh(-Inf + 0i)) = 0", __imag__ result, 0);
2983 result = FUNC(csinh) (BUILD_COMPLEX (plus_infty, minus_zero));
2984 check_isinfp ("real(csinh(+Inf - 0i)) = +Inf", __real__ result);
2985 check ("imag(csinh(+Inf - 0i)) = -0", __imag__ result, minus_zero);
2986 result = FUNC(csinh) (BUILD_COMPLEX (minus_infty, minus_zero));
2987 check_isinfn ("real(csinh(-Inf - 0i)) = -Inf", __real__ result);
2988 check ("imag(csinh(-Inf - 0i)) = -0", __imag__ result, minus_zero);
2990 result = FUNC(csinh) (BUILD_COMPLEX (plus_infty, plus_infty));
2991 check_isinfp_exc ("real(csinh(+Inf + i Inf)) = +-Inf plus invalid exception",
2992 FUNC(fabs) (__real__ result), INVALID_EXCEPTION);
2993 check_isnan ("imag(csinh(+Inf + i Inf)) = NaN plus invalid exception",
2995 result = FUNC(csinh) (BUILD_COMPLEX (minus_infty, plus_infty));
2996 check_isinfp_exc ("real(csinh(-Inf + i Inf)) = +-Inf plus invalid exception",
2997 FUNC(fabs) (__real__ result), INVALID_EXCEPTION);
2998 check_isnan ("imag(csinh(-Inf + i Inf)) = NaN plus invalid exception",
3000 result = FUNC(csinh) (BUILD_COMPLEX (plus_infty, minus_infty));
3001 check_isinfp_exc ("real(csinh(Inf - i Inf)) = +-Inf plus invalid exception",
3002 FUNC(fabs) (__real__ result), INVALID_EXCEPTION);
3003 check_isnan ("imag(csinh(Inf - i Inf)) = NaN plus invalid exception",
3005 result = FUNC(csinh) (BUILD_COMPLEX (minus_infty, minus_infty));
3006 check_isinfp_exc ("real(csinh(-Inf - i Inf)) = +-Inf plus invalid exception",
3007 FUNC(fabs) (__real__ result), INVALID_EXCEPTION);
3008 check_isnan ("imag(csinh(-Inf - i Inf)) = NaN plus invalid exception",
3011 result = FUNC(csinh) (BUILD_COMPLEX (plus_infty, 4.625));
3012 check_isinfn ("real(csinh(+Inf + i4.625)) = -Inf", __real__ result);
3013 check_isinfn ("imag(csinh(+Inf + i4.625)) = -Inf", __imag__ result);
3014 result = FUNC(csinh) (BUILD_COMPLEX (minus_infty, 4.625));
3015 check_isinfp ("real(csinh(-Inf + i4.625)) = +Inf", __real__ result);
3016 check_isinfn ("imag(csinh(-Inf + i4.625)) = -Inf", __imag__ result);
3017 result = FUNC(csinh) (BUILD_COMPLEX (plus_infty, -4.625));
3018 check_isinfn ("real(csinh(+Inf - i4.625)) = -Inf", __real__ result);
3019 check_isinfp ("imag(csinh(+Inf - i4.625)) = +Inf", __imag__ result);
3020 result = FUNC(csinh) (BUILD_COMPLEX (minus_infty, -4.625));
3021 check_isinfp ("real(csinh(-Inf - i4.625)) = +Inf", __real__ result);
3022 check_isinfp ("imag(csinh(-Inf - i4.625)) = +Inf", __imag__ result);
3024 result = FUNC(csinh) (BUILD_COMPLEX (6.75, plus_infty));
3025 check_isnan_exc ("real(csinh(6.75 + i Inf)) = NaN plus invalid exception",
3026 __real__ result, INVALID_EXCEPTION);
3027 check_isnan ("imag(csinh(6.75 + i Inf)) = NaN plus invalid exception",
3029 result = FUNC(csinh) (BUILD_COMPLEX (-6.75, plus_infty));
3030 check_isnan_exc ("real(csinh(-6.75 + i Inf)) = NaN plus invalid exception",
3031 __real__ result, INVALID_EXCEPTION);
3032 check_isnan ("imag(csinh(-6.75 + i Inf)) = NaN plus invalid exception",
3034 result = FUNC(csinh) (BUILD_COMPLEX (6.75, minus_infty));
3035 check_isnan_exc ("real(csinh(6.75 - i Inf)) = NaN plus invalid exception",
3036 __real__ result, INVALID_EXCEPTION);
3037 check_isnan ("imag(csinh(6.75 - i Inf)) = NaN plus invalid exception",
3039 result = FUNC(csinh) (BUILD_COMPLEX (-6.75, minus_infty));
3040 check_isnan_exc ("real(csinh(-6.75 - i Inf)) = NaN plus invalid exception",
3041 __real__ result, INVALID_EXCEPTION);
3042 check_isnan ("imag(csinh(-6.75 - i Inf)) = NaN plus invalid exception",
3045 result = FUNC(csinh) (BUILD_COMPLEX (0.0, nan_value));
3046 check ("real(csinh(0 + i NaN)) = +-0", FUNC(fabs) (__real__ result), 0);
3047 check_isnan ("imag(csinh(0 + i NaN)) = NaN", __imag__ result);
3048 result = FUNC(csinh) (BUILD_COMPLEX (minus_zero, nan_value));
3049 check ("real(csinh(-0 + i NaN)) = +-0", FUNC(fabs) (__real__ result), 0);
3050 check_isnan ("imag(csinh(-0 + i NaN)) = NaN", __imag__ result);
3052 result = FUNC(csinh) (BUILD_COMPLEX (plus_infty, nan_value));
3053 check_isinfp ("real(csinh(+Inf + i NaN)) = +-Inf",
3054 FUNC(fabs) (__real__ result));
3055 check_isnan ("imag(csinh(+Inf + i NaN)) = NaN", __imag__ result);
3056 result = FUNC(csinh) (BUILD_COMPLEX (minus_infty, nan_value));
3057 check_isinfp ("real(csinh(-Inf + i NaN)) = +-Inf",
3058 FUNC(fabs) (__real__ result));
3059 check_isnan ("imag(csinh(-Inf + i NaN)) = NaN", __imag__ result);
3061 result = FUNC(csinh) (BUILD_COMPLEX (9.0, nan_value));
3062 check_isnan_maybe_exc ("real(csinh(9.0 + i NaN)) = NaN plus maybe invalid exception",
3063 __real__ result, INVALID_EXCEPTION);
3064 check_isnan ("imag(csinh(9.0 + i NaN)) = NaN plus maybe invalid exception",
3066 result = FUNC(csinh) (BUILD_COMPLEX (-9.0, nan_value));
3067 check_isnan_maybe_exc ("real(csinh(-9.0 + i NaN)) = NaN plus maybe invalid exception",
3068 __real__ result, INVALID_EXCEPTION);
3069 check_isnan ("imag(csinh(-9.0 + i NaN)) = NaN plus maybe invalid exception",
3072 result = FUNC(csinh) (BUILD_COMPLEX (nan_value, 0.0));
3073 check_isnan ("real(csinh(NaN + i0)) = NaN", __real__ result);
3074 check ("imag(csinh(NaN + i0)) = 0", __imag__ result, 0.0);
3075 result = FUNC(csinh) (BUILD_COMPLEX (nan_value, minus_zero));
3076 check_isnan ("real(csinh(NaN - i0)) = NaN", __real__ result);
3077 check ("imag(csinh(NaN - i0)) = -0", __imag__ result, minus_zero);
3079 result = FUNC(csinh) (BUILD_COMPLEX (nan_value, 10.0));
3080 check_isnan_maybe_exc ("real(csinh(NaN + i10)) = NaN plus maybe invalid exception",
3081 __real__ result, INVALID_EXCEPTION);
3082 check_isnan ("imag(csinh(NaN + i10)) = NaN plus maybe invalid exception",
3084 result = FUNC(csinh) (BUILD_COMPLEX (nan_value, -10.0));
3085 check_isnan_maybe_exc ("real(csinh(NaN - i10)) = NaN plus maybe invalid exception",
3086 __real__ result, INVALID_EXCEPTION);
3087 check_isnan ("imag(csinh(NaN - i10)) = NaN plus maybe invalid exception",
3090 result = FUNC(csinh) (BUILD_COMPLEX (nan_value, plus_infty));
3091 check_isnan_maybe_exc ("real(csinh(NaN + i Inf)) = NaN plus maybe invalid exception",
3092 __real__ result, INVALID_EXCEPTION);
3093 check_isnan ("imag(csinh(NaN + i Inf)) = NaN plus maybe invalid exception",
3095 result = FUNC(csinh) (BUILD_COMPLEX (nan_value, minus_infty));
3096 check_isnan_maybe_exc ("real(csinh(NaN - i Inf)) = NaN plus maybe invalid exception",
3097 __real__ result, INVALID_EXCEPTION);
3098 check_isnan ("imag(csinh(NaN - i Inf)) = NaN plus maybe invalid exception",
3101 result = FUNC(csinh) (BUILD_COMPLEX (nan_value, nan_value));
3102 check_isnan ("real(csinh(NaN + i NaN)) = NaN", __real__ result);
3103 check_isnan ("imag(csinh(NaN + i NaN)) = NaN", __imag__ result);
3105 result = FUNC(csinh) (BUILD_COMPLEX (0.7, 1.2));
3106 check_eps ("real(csinh(0.7 + i 1.2)) = 0.274878686...", __real__ result,
3107 0.27487868678117583582L, CHOOSE(2e-17L, 6e-17, 3e-8));
3108 check_eps ("imag(csinh(0.7 + i 1.2)) = 1.169866572...", __imag__ result,
3109 1.1698665727426565139L, CHOOSE(6e-17L, 0, 2e-7));
3111 result = FUNC(csinh) (BUILD_COMPLEX (-2, -3));
3112 check_eps ("real(csinh(-2 - i 3)) == -3.59056...", __real__ result,
3113 3.5905645899857799520L, CHOOSE(7e-19L, 5e-16, 3e-7));
3114 check_eps ("imag(csinh(-2 - i 3)) == -0.53092...", __imag__ result,
3115 -0.5309210862485198052L, CHOOSE(3e-19L, 2e-16, 6e-8));
3122 __complex__ MATHTYPE result;
3124 result = FUNC(ccos) (BUILD_COMPLEX (0.0, 0.0));
3125 check ("real(ccos(0 + 0i)) = 1.0", __real__ result, 1.0);
3126 check ("imag(ccos(0 + 0i)) = -0", __imag__ result, minus_zero);
3127 result = FUNC(ccos) (BUILD_COMPLEX (minus_zero, 0.0));
3128 check ("real(ccos(-0 + 0i)) = 1.0", __real__ result, 1.0);
3129 check ("imag(ccos(-0 + 0i)) = 0", __imag__ result, 0.0);
3130 result = FUNC(ccos) (BUILD_COMPLEX (0.0, minus_zero));
3131 check ("real(ccos(0 - 0i)) = 1.0", __real__ result, 1.0);
3132 check ("imag(ccos(0 - 0i)) = 0", __imag__ result, 0.0);
3133 result = FUNC(ccos) (BUILD_COMPLEX (minus_zero, minus_zero));
3134 check ("real(ccos(-0 - 0i)) = 1.0", __real__ result, 1.0);
3135 check ("imag(ccos(-0 - 0i)) = -0", __imag__ result, minus_zero);
3137 result = FUNC(ccos) (BUILD_COMPLEX (plus_infty, 0.0));
3138 check_isnan_exc ("real(ccos(+Inf + i0)) = NaN plus invalid exception",
3139 __real__ result, INVALID_EXCEPTION);
3140 check ("imag(ccos(Inf + i0)) = +-0 plus invalid exception",
3141 FUNC(fabs) (__imag__ result), 0);
3142 result = FUNC(ccos) (BUILD_COMPLEX (plus_infty, minus_zero));
3143 check_isnan_exc ("real(ccos(Inf - i0)) = NaN plus invalid exception",
3144 __real__ result, INVALID_EXCEPTION);
3145 check ("imag(ccos(Inf - i0)) = +-0 plus invalid exception",
3146 FUNC(fabs) (__imag__ result), 0);
3147 result = FUNC(ccos) (BUILD_COMPLEX (minus_infty, 0.0));
3148 check_isnan_exc ("real(ccos(-Inf + i0)) = NaN plus invalid exception",
3149 __real__ result, INVALID_EXCEPTION);
3150 check ("imag(ccos(-Inf + i0)) = +-0 plus invalid exception",
3151 FUNC(fabs) (__imag__ result), 0);
3152 result = FUNC(ccos) (BUILD_COMPLEX (minus_infty, minus_zero));
3153 check_isnan_exc ("real(ccos(-Inf - i0)) = NaN plus invalid exception",
3154 __real__ result, INVALID_EXCEPTION);
3155 check ("imag(ccos(-Inf - i0)) = +-0 plus invalid exception",
3156 FUNC(fabs) (__imag__ result), 0);
3158 result = FUNC(ccos) (BUILD_COMPLEX (0.0, plus_infty));
3159 check_isinfp ("real(ccos(0 + i Inf)) = +Inf", __real__ result);
3160 check ("imag(ccos(0 + i Inf)) = -0", __imag__ result, minus_zero);
3161 result = FUNC(ccos) (BUILD_COMPLEX (0.0, minus_infty));
3162 check_isinfp ("real(ccos(0 - i Inf)) = +Inf", __real__ result);
3163 check ("imag(ccos(0 - i Inf)) = 0", __imag__ result, 0);
3164 result = FUNC(ccos) (BUILD_COMPLEX (minus_zero, plus_infty));
3165 check_isinfp ("real(ccos(-0 + i Inf)) = +Inf", __real__ result);
3166 check ("imag(ccos(-0 + i Inf)) = 0", __imag__ result, 0.0);
3167 result = FUNC(ccos) (BUILD_COMPLEX (minus_zero, minus_infty));
3168 check_isinfp ("real(ccos(-0 - i Inf)) = +Inf", __real__ result);
3169 check ("imag(ccos(-0 - i Inf)) = -0", __imag__ result, minus_zero);
3171 result = FUNC(ccos) (BUILD_COMPLEX (plus_infty, plus_infty));
3172 check_isinfp_exc ("real(ccos(+Inf + i Inf)) = +Inf plus invalid exception",
3173 __real__ result, INVALID_EXCEPTION);
3174 check_isnan ("imag(ccos(+Inf + i Inf)) = NaN plus invalid exception",
3176 result = FUNC(ccos) (BUILD_COMPLEX (minus_infty, plus_infty));
3177 check_isinfp_exc ("real(ccos(-Inf + i Inf)) = +Inf plus invalid exception",
3178 __real__ result, INVALID_EXCEPTION);
3179 check_isnan ("imag(ccos(-Inf + i Inf)) = NaN plus invalid exception",
3181 result = FUNC(ccos) (BUILD_COMPLEX (plus_infty, minus_infty));
3182 check_isinfp_exc ("real(ccos(Inf - i Inf)) = +Inf plus invalid exception",
3183 __real__ result, INVALID_EXCEPTION);
3184 check_isnan ("imag(ccos(Inf - i Inf)) = NaN plus invalid exception",
3186 result = FUNC(ccos) (BUILD_COMPLEX (minus_infty, minus_infty));
3187 check_isinfp_exc ("real(ccos(-Inf - i Inf)) = +Inf plus invalid exception",
3188 __real__ result, INVALID_EXCEPTION);
3189 check_isnan ("imag(ccos(-Inf - i Inf)) = NaN plus invalid exception",
3192 result = FUNC(ccos) (BUILD_COMPLEX (4.625, plus_infty));
3193 check_isinfn ("real(ccos(4.625 + i Inf)) = -Inf", __real__ result);
3194 check_isinfp ("imag(ccos(4.625 + i Inf)) = +Inf", __imag__ result);
3195 result = FUNC(ccos) (BUILD_COMPLEX (4.625, minus_infty));
3196 check_isinfn ("real(ccos(4.625 - i Inf)) = -Inf", __real__ result);
3197 check_isinfn ("imag(ccos(4.625 - i Inf)) = -Inf", __imag__ result);
3198 result = FUNC(ccos) (BUILD_COMPLEX (-4.625, plus_infty));
3199 check_isinfn ("real(ccos(-4.625 + i Inf)) = -Inf", __real__ result);
3200 check_isinfn ("imag(ccos(-4.625 + i Inf)) = -Inf", __imag__ result);
3201 result = FUNC(ccos) (BUILD_COMPLEX (-4.625, minus_infty));
3202 check_isinfn ("real(ccos(-4.625 - i Inf)) = -Inf", __real__ result);
3203 check_isinfp ("imag(ccos(-4.625 - i Inf)) = +Inf", __imag__ result);
3205 result = FUNC(ccos) (BUILD_COMPLEX (plus_infty, 6.75));
3206 check_isnan_exc ("real(ccos(+Inf + i6.75)) = NaN plus invalid exception",
3207 __real__ result, INVALID_EXCEPTION);
3208 check_isnan ("imag(ccos(+Inf + i6.75)) = NaN plus invalid exception",
3210 result = FUNC(ccos) (BUILD_COMPLEX (plus_infty, -6.75));
3211 check_isnan_exc ("real(ccos(+Inf - i6.75)) = NaN plus invalid exception",
3212 __real__ result, INVALID_EXCEPTION);
3213 check_isnan ("imag(ccos(+Inf - i6.75)) = NaN plus invalid exception",
3215 result = FUNC(ccos) (BUILD_COMPLEX (minus_infty, 6.75));
3216 check_isnan_exc ("real(ccos(-Inf + i6.75)) = NaN plus invalid exception",
3217 __real__ result, INVALID_EXCEPTION);
3218 check_isnan ("imag(ccos(-Inf + i6.75)) = NaN plus invalid exception",
3220 result = FUNC(ccos) (BUILD_COMPLEX (minus_infty, -6.75));
3221 check_isnan_exc ("real(ccos(-Inf - i6.75)) = NaN plus invalid exception",
3222 __real__ result, INVALID_EXCEPTION);
3223 check_isnan ("imag(ccos(-Inf - i6.75)) = NaN plus invalid exception",
3226 result = FUNC(ccos) (BUILD_COMPLEX (nan_value, 0.0));
3227 check_isnan ("real(ccos(NaN + i0)) = NaN", __real__ result);
3228 check ("imag(ccos(NaN + i0)) = +-0", FUNC(fabs) (__imag__ result), 0);
3229 result = FUNC(ccos) (BUILD_COMPLEX (nan_value, minus_zero));
3230 check_isnan ("real(ccos(NaN - i0)) = NaN", __real__ result);
3231 check ("imag(ccos(NaN - i0)) = +-0", FUNC(fabs) (__imag__ result), 0);
3233 result = FUNC(ccos) (BUILD_COMPLEX (nan_value, plus_infty));
3234 check_isinfp ("real(ccos(NaN + i Inf)) = +Inf", __real__ result);
3235 check_isnan ("imag(ccos(NaN + i Inf)) = NaN", __imag__ result);
3236 result = FUNC(ccos) (BUILD_COMPLEX (nan_value, minus_infty));
3237 check_isinfp ("real(ccos(NaN - i Inf)) = +Inf", __real__ result);
3238 check_isnan ("imag(ccos(NaN - i Inf)) = NaN", __imag__ result);
3240 result = FUNC(ccos) (BUILD_COMPLEX (nan_value, 9.0));
3241 check_isnan_maybe_exc ("real(ccos(NaN + i9.0)) = NaN plus maybe invalid exception",
3242 __real__ result, INVALID_EXCEPTION);
3243 check_isnan ("imag(ccos(NaN + i9.0)) = NaN plus maybe invalid exception",
3245 result = FUNC(ccos) (BUILD_COMPLEX (nan_value, -9.0));
3246 check_isnan_maybe_exc ("real(ccos(NaN - i9.0)) = NaN plus maybe invalid exception",
3247 __real__ result, INVALID_EXCEPTION);
3248 check_isnan ("imag(ccos(NaN - i9.0)) = NaN plus maybe invalid exception",
3251 result = FUNC(ccos) (BUILD_COMPLEX (0.0, nan_value));
3252 check_isnan ("real(ccos(0 + i NaN)) = NaN", __real__ result);
3253 check ("imag(ccos(0 + i NaN)) = +-0", FUNC(fabs) (__imag__ result), 0.0);
3254 result = FUNC(ccos) (BUILD_COMPLEX (minus_zero, nan_value));
3255 check_isnan ("real(ccos(-0 + i NaN)) = NaN", __real__ result);
3256 check ("imag(ccos(-0 + i NaN)) = +-0", FUNC(fabs) (__imag__ result), 0.0);
3258 result = FUNC(ccos) (BUILD_COMPLEX (10.0, nan_value));
3259 check_isnan_maybe_exc ("real(ccos(10 + i NaN)) = NaN plus maybe invalid exception",
3260 __real__ result, INVALID_EXCEPTION);
3261 check_isnan ("imag(ccos(10 + i NaN)) = NaN plus maybe invalid exception",
3263 result = FUNC(ccos) (BUILD_COMPLEX (-10.0, nan_value));
3264 check_isnan_maybe_exc ("real(ccos(-10 + i NaN)) = NaN plus maybe invalid exception",
3265 __real__ result, INVALID_EXCEPTION);
3266 check_isnan ("imag(ccos(-10 + i NaN)) = NaN plus maybe invalid exception",
3269 result = FUNC(ccos) (BUILD_COMPLEX (plus_infty, nan_value));
3270 check_isnan_maybe_exc ("real(ccos(+Inf + i NaN)) = NaN plus maybe invalid exception",
3271 __real__ result, INVALID_EXCEPTION);
3272 check_isnan ("imag(ccos(+Inf + i NaN)) = NaN plus maybe invalid exception",
3274 result = FUNC(ccos) (BUILD_COMPLEX (minus_infty, nan_value));
3275 check_isnan_maybe_exc ("real(ccos(-Inf + i NaN)) = NaN plus maybe invalid exception",
3276 __real__ result, INVALID_EXCEPTION);
3277 check_isnan ("imag(ccos(-Inf + i NaN)) = NaN plus maybe invalid exception",
3280 result = FUNC(ccos) (BUILD_COMPLEX (nan_value, nan_value));
3281 check_isnan ("real(ccos(NaN + i NaN)) = NaN", __real__ result);
3282 check_isnan ("imag(ccos(NaN + i NaN)) = NaN", __imag__ result);
3284 result = FUNC(ccos) (BUILD_COMPLEX (0.7, 1.2));
3285 check_eps ("real(ccos(0.7 + i 1.2)) = 1.384865764...", __real__ result,
3286 1.3848657645312111080L, CHOOSE(4e-18L, 3e-16, 2e-7));
3287 check_eps ("imag(ccos(0.7 + i 1.2)) = -0.972421703...", __imag__ result,
3288 -0.97242170335830028619L, CHOOSE(2e-16L, 2e-16, 0));
3290 result = FUNC(ccos) (BUILD_COMPLEX (-2, -3));
3291 check_eps ("real(ccos(-2 - i 3)) == -4.18962...", __real__ result,
3292 -4.1896256909688072301L, CHOOSE(2e-17L, 0, 5e-7));
3293 check_eps ("imag(ccos(-2 - i 3)) == -9.10922...", __imag__ result,
3294 -9.1092278937553365979L, CHOOSE(3e-18L, 0, 1e-6));
3301 __complex__ MATHTYPE result;
3303 result = FUNC(ccosh) (BUILD_COMPLEX (0.0, 0.0));
3304 check ("real(ccosh(0 + 0i)) = 1.0", __real__ result, 1.0);
3305 check ("imag(ccosh(0 + 0i)) = 0", __imag__ result, 0);
3306 result = FUNC(ccosh) (BUILD_COMPLEX (minus_zero, 0.0));
3307 check ("real(ccosh(-0 + 0i)) = 1.0", __real__ result, 1.0);
3308 check ("imag(ccosh(-0 + 0i)) = -0", __imag__ result, minus_zero);
3309 result = FUNC(ccosh) (BUILD_COMPLEX (0.0, minus_zero));
3310 check ("real(ccosh(0 - 0i)) = 1.0", __real__ result, 1.0);
3311 check ("imag(ccosh(0 - 0i)) = -0", __imag__ result, minus_zero);
3312 result = FUNC(ccosh) (BUILD_COMPLEX (minus_zero, minus_zero));
3313 check ("real(ccosh(-0 - 0i)) = 1.0", __real__ result, 1.0);
3314 check ("imag(ccosh(-0 - 0i)) = 0", __imag__ result, 0.0);
3316 result = FUNC(ccosh) (BUILD_COMPLEX (0.0, plus_infty));
3317 check_isnan_exc ("real(ccosh(0 + i Inf)) = NaN plus invalid exception",
3318 __real__ result, INVALID_EXCEPTION);
3319 check ("imag(ccosh(0 + i Inf)) = +-0 plus invalid exception",
3320 FUNC(fabs) (__imag__ result), 0);
3321 result = FUNC(ccosh) (BUILD_COMPLEX (minus_zero, plus_infty));
3322 check_isnan_exc ("real(ccosh(-0 + i Inf)) = NaN plus invalid exception",
3323 __real__ result, INVALID_EXCEPTION);
3324 check ("imag(ccosh(-0 + i Inf)) = +-0 plus invalid exception",
3325 FUNC(fabs) (__imag__ result), 0);
3326 result = FUNC(ccosh) (BUILD_COMPLEX (0.0, minus_infty));
3327 check_isnan_exc ("real(ccosh(0 - i Inf)) = NaN plus invalid exception",
3328 __real__ result, INVALID_EXCEPTION);
3329 check ("imag(ccosh(0 - i Inf)) = +-0 plus invalid exception",
3330 FUNC(fabs) (__imag__ result), 0);
3331 result = FUNC(ccosh) (BUILD_COMPLEX (minus_zero, minus_infty));
3332 check_isnan_exc ("real(ccosh(-0 - i Inf)) = NaN plus invalid exception",
3333 __real__ result, INVALID_EXCEPTION);
3334 check ("imag(ccosh(-0 - i Inf)) = +-0 plus invalid exception",
3335 FUNC(fabs) (__imag__ result), 0);
3337 result = FUNC(ccosh) (BUILD_COMPLEX (plus_infty, 0.0));
3338 check_isinfp ("real(ccosh(+Inf + 0i)) = +Inf", __real__ result);
3339 check ("imag(ccosh(+Inf + 0i)) = 0", __imag__ result, 0);
3340 result = FUNC(ccosh) (BUILD_COMPLEX (minus_infty, 0.0));
3341 check_isinfp ("real(ccosh(-Inf + 0i)) = +Inf", __real__ result);
3342 check ("imag(ccosh(-Inf + 0i)) = -0", __imag__ result, minus_zero);
3343 result = FUNC(ccosh) (BUILD_COMPLEX (plus_infty, minus_zero));
3344 check_isinfp ("real(ccosh(+Inf - 0i)) = +Inf", __real__ result);
3345 check ("imag(ccosh(+Inf - 0i)) = -0", __imag__ result, minus_zero);
3346 result = FUNC(ccosh) (BUILD_COMPLEX (minus_infty, minus_zero));
3347 check_isinfp ("real(ccosh(-Inf - 0i)) = +Inf", __real__ result);
3348 check ("imag(ccosh(-Inf - 0i)) = 0", __imag__ result, 0.0);
3350 result = FUNC(ccosh) (BUILD_COMPLEX (plus_infty, plus_infty));
3351 check_isinfp_exc ("real(ccosh(+Inf + i Inf)) = +Inf plus invalid exception",
3352 __real__ result, INVALID_EXCEPTION);
3353 check_isnan ("imag(ccosh(+Inf + i Inf)) = NaN plus invalid exception",
3355 result = FUNC(ccosh) (BUILD_COMPLEX (minus_infty, plus_infty));
3356 check_isinfp_exc ("real(ccosh(-Inf + i Inf)) = +Inf plus invalid exception",
3357 __real__ result, INVALID_EXCEPTION);
3358 check_isnan ("imag(ccosh(-Inf + i Inf)) = NaN plus invalid exception",
3360 result = FUNC(ccosh) (BUILD_COMPLEX (plus_infty, minus_infty));
3361 check_isinfp_exc ("real(ccosh(Inf - i Inf)) = +Inf plus invalid exception",
3362 __real__ result, INVALID_EXCEPTION);
3363 check_isnan ("imag(ccosh(Inf - i Inf)) = NaN plus invalid exception",
3365 result = FUNC(ccosh) (BUILD_COMPLEX (minus_infty, minus_infty));
3366 check_isinfp_exc ("real(ccosh(-Inf - i Inf)) = +Inf plus invalid exception",
3367 __real__ result, INVALID_EXCEPTION);
3368 check_isnan ("imag(ccosh(-Inf - i Inf)) = NaN plus invalid exception",
3371 result = FUNC(ccosh) (BUILD_COMPLEX (plus_infty, 4.625));
3372 check_isinfn ("real(ccosh(+Inf + i4.625)) = -Inf", __real__ result);
3373 check_isinfn ("imag(ccosh(+Inf + i4.625)) = -Inf", __imag__ result);
3374 result = FUNC(ccosh) (BUILD_COMPLEX (minus_infty, 4.625));
3375 check_isinfn ("real(ccosh(-Inf + i4.625)) = -Inf", __real__ result);
3376 check_isinfp ("imag(ccosh(-Inf + i4.625)) = Inf", __imag__ result);
3377 result = FUNC(ccosh) (BUILD_COMPLEX (plus_infty, -4.625));
3378 check_isinfn ("real(ccosh(+Inf - i4.625)) = -Inf", __real__ result);
3379 check_isinfp ("imag(ccosh(+Inf - i4.625)) = +Inf", __imag__ result);
3380 result = FUNC(ccosh) (BUILD_COMPLEX (minus_infty, -4.625));
3381 check_isinfn ("real(ccosh(-Inf - i4.625)) = -Inf", __real__ result);
3382 check_isinfn ("imag(ccosh(-Inf - i4.625)) = -Inf", __imag__ result);
3384 result = FUNC(ccosh) (BUILD_COMPLEX (6.75, plus_infty));
3385 check_isnan_exc ("real(ccosh(6.75 + i Inf)) = NaN plus invalid exception",
3386 __real__ result, INVALID_EXCEPTION);
3387 check_isnan ("imag(ccosh(6.75 + i Inf)) = NaN plus invalid exception",
3389 result = FUNC(ccosh) (BUILD_COMPLEX (-6.75, plus_infty));
3390 check_isnan_exc ("real(ccosh(-6.75 + i Inf)) = NaN plus invalid exception",
3391 __real__ result, INVALID_EXCEPTION);
3392 check_isnan ("imag(ccosh(-6.75 + i Inf)) = NaN plus invalid exception",
3394 result = FUNC(ccosh) (BUILD_COMPLEX (6.75, minus_infty));
3395 check_isnan_exc ("real(ccosh(6.75 - i Inf)) = NaN plus invalid exception",
3396 __real__ result, INVALID_EXCEPTION);
3397 check_isnan ("imag(ccosh(6.75 - i Inf)) = NaN plus invalid exception",
3399 result = FUNC(ccosh) (BUILD_COMPLEX (-6.75, minus_infty));
3400 check_isnan_exc ("real(ccosh(-6.75 - i Inf)) = NaN plus invalid exception",
3401 __real__ result, INVALID_EXCEPTION);
3402 check_isnan ("imag(ccosh(-6.75 - i Inf)) = NaN plus invalid exception",
3405 result = FUNC(ccosh) (BUILD_COMPLEX (0.0, nan_value));
3406 check_isnan ("real(ccosh(0 + i NaN)) = NaN", __real__ result);
3407 check ("imag(ccosh(0 + i NaN)) = +-0", FUNC(fabs) (__imag__ result), 0);
3408 result = FUNC(ccosh) (BUILD_COMPLEX (minus_zero, nan_value));
3409 check_isnan ("real(ccosh(-0 + i NaN)) = NaN", __real__ result);
3410 check ("imag(ccosh(-0 + i NaN)) = +-0", FUNC(fabs) (__imag__ result), 0);
3412 result = FUNC(ccosh) (BUILD_COMPLEX (plus_infty, nan_value));
3413 check_isinfp ("real(ccosh(+Inf + i NaN)) = +Inf", __real__ result);
3414 check_isnan ("imag(ccosh(+Inf + i NaN)) = NaN", __imag__ result);
3415 result = FUNC(ccosh) (BUILD_COMPLEX (minus_infty, nan_value));
3416 check_isinfp ("real(ccosh(-Inf + i NaN)) = +Inf", __real__ result);
3417 check_isnan ("imag(ccosh(-Inf + i NaN)) = NaN", __imag__ result);
3419 result = FUNC(ccosh) (BUILD_COMPLEX (9.0, nan_value));
3420 check_isnan_maybe_exc ("real(ccosh(9.0 + i NaN)) = NaN plus maybe invalid exception",
3421 __real__ result, INVALID_EXCEPTION);
3422 check_isnan ("imag(ccosh(9.0 + i NaN)) = NaN plus maybe invalid exception",
3424 result = FUNC(ccosh) (BUILD_COMPLEX (-9.0, nan_value));
3425 check_isnan_maybe_exc ("real(ccosh(-9.0 + i NaN)) = NaN plus maybe invalid exception",
3426 __real__ result, INVALID_EXCEPTION);
3427 check_isnan ("imag(ccosh(-9.0 + i NaN)) = NaN plus maybe invalid exception",
3430 result = FUNC(ccosh) (BUILD_COMPLEX (nan_value, 0.0));
3431 check_isnan ("real(ccosh(NaN + i0)) = NaN", __real__ result);
3432 check ("imag(ccosh(NaN + i0)) = +-0", FUNC(fabs) (__imag__ result), 0.0);
3433 result = FUNC(ccosh) (BUILD_COMPLEX (nan_value, minus_zero));
3434 check_isnan ("real(ccosh(NaN - i0)) = NaN", __real__ result);
3435 check ("imag(ccosh(NaN - i0)) = +-0", FUNC(fabs) (__imag__ result), 0.0);
3437 result = FUNC(ccosh) (BUILD_COMPLEX (nan_value, 10.0));
3438 check_isnan_maybe_exc ("real(ccosh(NaN + i10)) = NaN plus maybe invalid exception",
3439 __real__ result, INVALID_EXCEPTION);
3440 check_isnan ("imag(ccosh(NaN + i10)) = NaN plus maybe invalid exception",
3442 result = FUNC(ccosh) (BUILD_COMPLEX (nan_value, -10.0));
3443 check_isnan_maybe_exc ("real(ccosh(NaN - i10)) = NaN plus maybe invalid exception",
3444 __real__ result, INVALID_EXCEPTION);
3445 check_isnan ("imag(ccosh(NaN - i10)) = NaN plus maybe invalid exception",
3448 result = FUNC(ccosh) (BUILD_COMPLEX (nan_value, plus_infty));
3449 check_isnan_maybe_exc ("real(ccosh(NaN + i Inf)) = NaN plus maybe invalid exception",
3450 __real__ result, INVALID_EXCEPTION);
3451 check_isnan ("imag(ccosh(NaN + i Inf)) = NaN plus maybe invalid exception",
3453 result = FUNC(ccosh) (BUILD_COMPLEX (nan_value, minus_infty));
3454 check_isnan_maybe_exc ("real(ccosh(NaN - i Inf)) = NaN plus maybe invalid exception",
3455 __real__ result, INVALID_EXCEPTION);
3456 check_isnan ("imag(ccosh(NaN - i Inf)) = NaN plus maybe invalid exception",
3459 result = FUNC(ccosh) (BUILD_COMPLEX (nan_value, nan_value));
3460 check_isnan ("real(ccosh(NaN + i NaN)) = NaN", __real__ result);
3461 check_isnan ("imag(ccosh(NaN + i NaN)) = NaN", __imag__ result);
3463 result = FUNC(ccosh) (BUILD_COMPLEX (0.7, 1.2));
3464 check_eps ("real(ccosh(0.7 + i 1.2)) == 0.45482...", __real__ result,
3465 0.4548202223691477654L, CHOOSE(5e-17L, 6e-17, 9e-8));
3466 check_eps ("imag(ccosh(0.7 + i 1.2)) == 0.70702...", __imag__ result,
3467 0.7070296600921537682L, CHOOSE(7e-17L, 2e-16, 0));
3469 result = FUNC(ccosh) (BUILD_COMPLEX (-2, -3));
3470 check_eps ("real(ccosh(-2 - i 3)) == -3.72454...", __real__ result,
3471 -3.7245455049153225654L, CHOOSE(7e-19L, 0, 3e-7));
3472 check_eps ("imag(ccosh(-2 - i 3)) == -0.51182...", __imag__ result,
3473 0.5118225699873846088L, CHOOSE(3e-19L, 2e-16, 6e-8));
3480 __complex__ MATHTYPE result;
3482 result = FUNC(cacos) (BUILD_COMPLEX (0, 0));
3483 check ("real(cacos(0 + i0)) = pi/2", __real__ result, M_PI_2l);
3484 check ("imag(cacos(0 + i0)) = -0", __imag__ result, minus_zero);
3485 result = FUNC(cacos) (BUILD_COMPLEX (minus_zero, 0));
3486 check ("real(cacos(-0 + i0)) = pi/2", __real__ result, M_PI_2l);
3487 check ("imag(cacos(-0 + i0)) = -0", __imag__ result, minus_zero);
3488 result = FUNC(cacos) (BUILD_COMPLEX (0, minus_zero));
3489 check ("real(cacos(0 - i0)) = pi/2", __real__ result, M_PI_2l);
3490 check ("imag(cacos(0 - i0)) = 0", __imag__ result, 0);
3491 result = FUNC(cacos) (BUILD_COMPLEX (minus_zero, minus_zero));
3492 check ("real(cacos(-0 - i0)) = pi/2", __real__ result, M_PI_2l);
3493 check ("imag(cacos(-0 - i0)) = 0", __imag__ result, 0);
3495 result = FUNC(cacos) (BUILD_COMPLEX (minus_infty, plus_infty));
3496 check ("real(cacos(-Inf + i Inf)) = 3*pi/4", __real__ result,
3498 check_isinfn ("imag(cacos(-Inf + i Inf)) = -Inf", __imag__ result);
3499 result = FUNC(cacos) (BUILD_COMPLEX (minus_infty, minus_infty));
3500 check ("real(cacos(-Inf - i Inf)) = 3*pi/4", __real__ result,
3502 check_isinfp ("imag(cacos(-Inf - i Inf)) = +Inf", __imag__ result);
3504 result = FUNC(cacos) (BUILD_COMPLEX (plus_infty, plus_infty));
3505 check ("real(cacos(+Inf + i Inf)) = pi/4", __real__ result, M_PI_4l);
3506 check_isinfn ("imag(cacos(+Inf + i Inf)) = -Inf", __imag__ result);
3507 result = FUNC(cacos) (BUILD_COMPLEX (plus_infty, minus_infty));
3508 check ("real(cacos(+Inf - i Inf)) = pi/4", __