Update.
[glibc.git] / math / libm-test.c
blobc24b5f0f8330a2c381127dfe908b1e42f63033d4
1 /* Copyright (C) 1997 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:
26 Makros:
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
34 equality
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,
38 e.g. "f"
41 /* This program isn't finished yet.
42 It has tests for:
43 acos, acosh, asin, asinh, atan, atan2, atanh,
44 cbrt, ceil, copysign, cos, cosh, erf, erfc, exp, exp2, expm1,
45 fabs, fdim, floor, fmin, fmax, fmod, fpclassify,
46 frexp, gamma, hypot,
47 ilogb, isfinite, isinf, isnan, isnormal,
48 ldexp, lgamma, log, log10, log1p, log2, logb,
49 modf, nearbyint, nextafter,
50 pow, remainder, remquo, rint, lrint, llrint,
51 round, lround, llround,
52 scalb, scalbn, signbit, sin, sincos, sinh, sqrt, tan, tanh, trunc
54 and for the following complex math functions:
55 cacos, cacosh, casin, casinh, catan, catanh,
56 ccos, ccosh, cexp, clog, cpow, csin, csinh, csqrt, ctanh.
58 At the moment the following functions aren't tested:
59 cabs, carg, conj, cproj, cimag, creal, ctan, drem,
60 j0, j1, jn, y0, y1, yn,
61 significand,
62 nan, comparison macros (isless,isgreater,...).
64 The routines using random variables are still under construction. I don't
65 like it the way it's working now and will change it.
67 Parameter handling is primitive in the moment:
68 --verbose=[0..4] for different levels of output:
69 0: only error count
70 1: basic report on failed tests (default)
71 2: full report on failed tests
72 3: full report on failed and passed tests
73 4: additional report on exceptions
74 -v for full output (equals --verbose=4)
75 -s,--silent outputs only the error count (equals --verbose=0)
78 /* "Philosophy":
80 This suite tests the correct implementation of mathematical
81 functions in libm. Some simple, specific parameters are tested for
82 correctness. Handling of specific inputs (e.g. infinity,
83 not-a-number) is also tested. Correct handling of exceptions is
84 checked against. These implemented tests should check all cases
85 that are specified in ISO C 9X.
87 Exception testing: At the moment only divide-by-zero and invalid
88 exceptions are tested. Overflow/underflow and inexact exceptions
89 aren't checked at the moment.
91 NaN values: There exist signalling and quiet NaNs. This implementation
92 only uses signalling NaN as parameter but does not differenciate
93 between the two kinds of NaNs as result.
95 Inline functions: Inlining functions should give an improvement in
96 speed - but not in precission. The inlined functions return
97 reasonable values for a reasonable range of input values. The
98 result is not necessarily correct for all values and exceptions are
99 not correctly raised in all cases. Problematic input and return
100 values are infinity, not-a-number and minus zero. This suite
101 therefore does not check these specific inputs and the exception
102 handling for inlined mathematical functions - just the "reasonable"
103 values are checked.
105 Beware: The tests might fail for any of the following reasons:
106 - Tests are wrong
107 - Functions are wrong
108 - Floating Point Unit not working properly
109 - Compiler has errors
111 With e.g. gcc 2.7.2.2 the test for cexp fails because of a compiler error.
115 #ifndef _GNU_SOURCE
116 # define _GNU_SOURCE
117 #endif
119 #include <complex.h>
120 #include <math.h>
121 #include <float.h>
122 #include <fenv.h>
124 #include <errno.h>
125 #include <stdlib.h>
126 #include <stdio.h>
127 #include <getopt.h>
129 /* Possible exceptions */
130 #define NO_EXCEPTION 0x0
131 #define INVALID_EXCEPTION 0x1
132 #define DIVIDE_BY_ZERO_EXCEPTION 0x2
134 #define PRINT 1
135 #define NO_PRINT 0
137 /* Various constants (we must supply them precalculated for accuracy). */
138 #define M_PI_6 .52359877559829887308L
140 static int noErrors;
142 static int verbose = 3;
143 static MATHTYPE minus_zero, plus_zero;
144 static MATHTYPE plus_infty, minus_infty, nan_value;
146 typedef MATHTYPE (*mathfunc) (MATHTYPE);
148 #define BUILD_COMPLEX(real, imag) \
149 ({ __complex__ MATHTYPE __retval; \
150 __real__ __retval = (real); \
151 __imag__ __retval = (imag); \
152 __retval; })
155 #define ISINF(x) \
156 (sizeof (x) == sizeof (float) ? \
157 isinff (x) \
158 : sizeof (x) == sizeof (double) ? \
159 isinf (x) : isinfl (x))
163 Test if Floating-Point stack hasn't changed
165 static void
166 fpstack_test (const char *test_name)
168 #ifdef i386
169 static int old_stack;
170 int sw;
171 asm ("fnstsw":"=a" (sw));
172 sw >>= 11;
173 sw &= 7;
174 if (sw != old_stack)
176 printf ("FP-Stack wrong after test %s\n", test_name);
177 if (verbose > 2)
178 printf ("=======> stack = %d\n", sw);
179 ++noErrors;
180 old_stack = sw;
182 #endif
187 Get a random value x with min_value < x < max_value
188 and min_value, max_value finite,
189 max_value and min_value shouldn't be too close together
191 static MATHTYPE
192 random_value (MATHTYPE min_value, MATHTYPE max_value)
194 int r;
195 MATHTYPE x;
197 r = rand ();
199 x = (max_value - min_value) / RAND_MAX * (MATHTYPE) r + min_value;
201 if ((x <= min_value) || (x >= max_value) || !isfinite (x))
202 x = (max_value - min_value) / 2 + min_value;
204 /* Make sure the RNG has no influence on the exceptions. */
205 feclearexcept (FE_ALL_EXCEPT);
207 return x;
210 /* Get a random value x with x > min_value. */
211 static MATHTYPE
212 random_greater (MATHTYPE min_value)
214 return random_value (min_value, 1e6); /* CHOOSE (LDBL_MAX, DBL_MAX, FLT_MAX) */
217 /* Get a random value x with x < max_value. */
218 static MATHTYPE
219 random_less (MATHTYPE max_value)
221 return random_value (-1e6, max_value);
225 static void
226 output_new_test (const char *test_name)
228 if (verbose > 2)
229 printf ("\nTesting: %s\n", test_name);
233 static void
234 output_pass_value (void)
236 if (verbose > 2)
237 printf ("Pass: Value Ok.\n");
241 static void
242 output_fail_value (const char * test_name)
244 if (verbose > 0 && verbose < 3)
245 printf ("Fail: %s\n", test_name);
246 if (verbose >= 3)
247 printf ("Fail:\n");
251 /* Test whether a given exception was raised. */
252 static void
253 test_single_exception (const char *test_name,
254 short int exception,
255 short int exc_flag,
256 int fe_flag,
257 const char *flag_name)
259 #ifndef TEST_INLINE
260 if (exception & exc_flag)
262 if (fetestexcept (fe_flag))
264 if (verbose > 3)
265 printf ("Pass: Exception \"%s\" set\n", flag_name);
267 else
269 if (verbose && verbose < 3)
270 printf ("Fail: %s: Exception \"%s\" not set\n",
271 test_name, flag_name);
272 if (verbose >= 3)
273 printf ("Fail: Exception \"%s\" not set\n",
274 flag_name);
275 ++noErrors;
278 else
280 if (fetestexcept (fe_flag))
282 if (verbose && verbose < 3)
283 printf ("Fail: %s: Exception \"%s\" set\n",
284 test_name, flag_name);
285 if (verbose >= 3)
286 printf ("Fail: Exception \"%s\" set\n",
287 flag_name);
288 ++noErrors;
290 else
292 if (verbose > 3)
293 printf ("Pass: Exception \"%s\" not set\n",
294 flag_name);
297 #endif
301 /* Test whether exception given by EXCEPTION are raised. */
302 static void
303 test_not_exception (const char *test_name, short int exception)
305 #ifdef FE_DIVBYZERO
306 if ((exception & DIVIDE_BY_ZERO_EXCEPTION) == 0)
307 test_single_exception (test_name, exception,
308 DIVIDE_BY_ZERO_EXCEPTION, FE_DIVBYZERO,
309 "Divide by zero");
310 #endif
311 #ifdef FE_INVALID
312 if ((exception & INVALID_EXCEPTION) == 0)
313 test_single_exception (test_name, exception, INVALID_EXCEPTION, FE_INVALID,
314 "Invalid operation");
315 #endif
316 feclearexcept (FE_ALL_EXCEPT);
320 /* Test whether exceptions given by EXCEPTION are raised. */
321 static void
322 test_exceptions (const char *test_name, short int exception)
324 #ifdef FE_DIVBYZERO
325 test_single_exception (test_name, exception,
326 DIVIDE_BY_ZERO_EXCEPTION, FE_DIVBYZERO,
327 "Divide by zero");
328 #endif
329 #ifdef FE_INVALID
330 test_single_exception (test_name, exception, INVALID_EXCEPTION, FE_INVALID,
331 "Invalid operation");
332 #endif
333 feclearexcept (FE_ALL_EXCEPT);
337 /* Test if two floating point numbers are equal. */
338 static int
339 check_equal (MATHTYPE computed, MATHTYPE supplied, MATHTYPE eps, MATHTYPE * diff)
341 int ret_value;
343 /* Both plus Infinity or both minus infinity. */
344 if (ISINF (computed) && (ISINF (computed) == ISINF (supplied)))
345 return 1;
347 if (isnan (computed) && isnan (supplied)) /* isnan works for all types */
348 return 1;
350 *diff = FUNC(fabs) (computed - supplied);
353 ret_value = (*diff <= eps &&
354 (signbit (computed) == signbit (supplied) || eps != 0.0));
356 /* Make sure the subtraction/comparsion have no influence on the exceptions. */
357 feclearexcept (FE_ALL_EXCEPT);
359 return ret_value;
364 static void
365 output_result_bool (const char *test_name, int result)
367 if (result)
369 output_pass_value ();
371 else
373 output_fail_value (test_name);
374 if (verbose > 1)
375 printf (" Value: %d\n", result);
376 ++noErrors;
379 fpstack_test (test_name);
383 static void
384 output_isvalue (const char *test_name, int result,
385 MATHTYPE value)
387 if (result)
389 output_pass_value ();
391 else
393 output_fail_value (test_name);
394 if (verbose > 1)
395 printf (" Value: %.20" PRINTF_EXPR "\n", value);
396 noErrors++;
399 fpstack_test (test_name);
403 static void
404 output_isvalue_ext (const char *test_name, int result,
405 MATHTYPE value, MATHTYPE parameter)
407 if (result)
409 output_pass_value ();
411 else
413 output_fail_value (test_name);
414 if (verbose > 1)
416 printf (" Value: %.20" PRINTF_EXPR "\n", value);
417 printf (" Parameter: %.20" PRINTF_EXPR "\n", parameter);
419 noErrors++;
422 fpstack_test (test_name);
426 static void
427 output_result (const char *test_name, int result,
428 MATHTYPE computed, MATHTYPE expected,
429 MATHTYPE difference,
430 int print_values, int print_diff)
432 if (result)
434 output_pass_value ();
436 else
438 output_fail_value (test_name);
439 if (verbose > 1 && print_values)
441 printf ("Result:\n");
442 printf (" is: %.20" PRINTF_EXPR "\n", computed);
443 printf (" should be: %.20" PRINTF_EXPR "\n", expected);
444 if (print_diff)
445 printf (" difference: %.20" PRINTF_EXPR "\n", difference);
447 noErrors++;
450 fpstack_test (test_name);
454 static void
455 output_result_ext (const char *test_name, int result,
456 MATHTYPE computed, MATHTYPE expected,
457 MATHTYPE difference,
458 MATHTYPE parameter,
459 int print_values, int print_diff)
461 if (result)
463 output_pass_value ();
465 else
467 output_fail_value (test_name);
468 if (verbose > 1 && print_values)
470 printf ("Result:\n");
471 printf (" is: %.20" PRINTF_EXPR "\n", computed);
472 printf (" should be: %.20" PRINTF_EXPR "\n", expected);
473 if (print_diff)
474 printf (" difference: %.20" PRINTF_EXPR "\n", difference);
475 printf ("Parameter: %.20" PRINTF_EXPR "\n", parameter);
477 noErrors++;
480 fpstack_test (test_name);
484 check that computed and expected values are the same
486 static void
487 check (const char *test_name, MATHTYPE computed, MATHTYPE expected)
489 MATHTYPE diff;
490 int result;
492 output_new_test (test_name);
493 test_exceptions (test_name, NO_EXCEPTION);
494 result = check_equal (computed, expected, 0, &diff);
495 output_result (test_name, result,
496 computed, expected, diff, PRINT, PRINT);
501 check that computed and expected values are the same,
502 outputs the parameter to the function
504 static void
505 check_ext (const char *test_name, MATHTYPE computed, MATHTYPE expected,
506 MATHTYPE parameter)
508 MATHTYPE diff;
509 int result;
511 output_new_test (test_name);
512 test_exceptions (test_name, NO_EXCEPTION);
513 result = check_equal (computed, expected, 0, &diff);
514 output_result_ext (test_name, result,
515 computed, expected, diff, parameter, PRINT, PRINT);
520 check that computed and expected values are the same and
521 checks also for exception flags
523 static void
524 check_exc (const char *test_name, MATHTYPE computed, MATHTYPE expected,
525 short exception)
527 MATHTYPE diff;
528 int result;
530 output_new_test (test_name);
531 test_exceptions (test_name, exception);
532 result = check_equal (computed, expected, 0, &diff);
533 output_result (test_name, result,
534 computed, expected, diff, PRINT, PRINT);
538 check that computed and expected values are close enough
540 static void
541 check_eps (const char *test_name, MATHTYPE computed, MATHTYPE expected,
542 MATHTYPE epsilon)
544 MATHTYPE diff;
545 int result;
547 output_new_test (test_name);
548 test_exceptions (test_name, NO_EXCEPTION);
549 result = check_equal (computed, expected, epsilon, &diff);
550 output_result (test_name, result,
551 computed, expected, diff, PRINT, PRINT);
555 check a boolean condition
557 static void
558 check_bool (const char *test_name, int computed)
560 output_new_test (test_name);
561 test_exceptions (test_name, NO_EXCEPTION);
562 output_result_bool (test_name, computed);
568 check that computed and expected values are equal (int values)
570 static void
571 check_int (const char *test_name, int computed, int expected)
573 int diff = computed - expected;
574 int result = diff == 0;
576 output_new_test (test_name);
577 test_exceptions (test_name, NO_EXCEPTION);
579 if (result)
581 output_pass_value ();
583 else
585 output_fail_value (test_name);
586 if (verbose > 1)
588 printf ("Result:\n");
589 printf (" is: %d\n", computed);
590 printf (" should be: %d\n", expected);
592 noErrors++;
595 fpstack_test (test_name);
600 check that computed and expected values are equal (long int values)
602 static void
603 check_long (const char *test_name, long int computed, long int expected)
605 long int diff = computed - expected;
606 int result = diff == 0;
608 output_new_test (test_name);
609 test_exceptions (test_name, NO_EXCEPTION);
611 if (result)
613 output_pass_value ();
615 else
617 output_fail_value (test_name);
618 if (verbose > 1)
620 printf ("Result:\n");
621 printf (" is: %ld\n", computed);
622 printf (" should be: %ld\n", expected);
624 noErrors++;
627 fpstack_test (test_name);
631 check that computed and expected values are equal (long long int values)
633 static void
634 check_longlong (const char *test_name, long long int computed,
635 long long int expected)
637 long long int diff = computed - expected;
638 int result = diff == 0;
640 output_new_test (test_name);
641 test_exceptions (test_name, NO_EXCEPTION);
643 if (result)
645 output_pass_value ();
647 else
649 output_fail_value (test_name);
650 if (verbose > 1)
652 printf ("Result:\n");
653 printf (" is: %lld\n", computed);
654 printf (" should be: %lld\n", expected);
656 noErrors++;
659 fpstack_test (test_name);
663 check that computed value is not-a-number
665 static void
666 check_isnan (const char *test_name, MATHTYPE computed)
668 output_new_test (test_name);
669 test_exceptions (test_name, NO_EXCEPTION);
670 output_isvalue (test_name, isnan (computed), computed);
675 check that computed value is not-a-number and test for exceptions
677 static void
678 check_isnan_exc (const char *test_name, MATHTYPE computed,
679 short exception)
681 output_new_test (test_name);
682 test_exceptions (test_name, exception);
683 output_isvalue (test_name, isnan (computed), computed);
688 check that computed value is not-a-number and test for exceptions
690 static void
691 check_isnan_maybe_exc (const char *test_name, MATHTYPE computed,
692 short exception)
694 output_new_test (test_name);
695 test_not_exception (test_name, exception);
696 output_isvalue (test_name, isnan (computed), computed);
700 check that computed value is not-a-number and supply parameter
702 #ifndef TEST_INLINE
703 static void
704 check_isnan_ext (const char *test_name, MATHTYPE computed,
705 MATHTYPE parameter)
707 output_new_test (test_name);
708 test_exceptions (test_name, NO_EXCEPTION);
709 output_isvalue_ext (test_name, isnan (computed), computed, parameter);
711 #endif
714 check that computed value is not-a-number, test for exceptions
715 and supply parameter
717 static void
718 check_isnan_exc_ext (const char *test_name, MATHTYPE computed,
719 short exception, MATHTYPE parameter)
721 output_new_test (test_name);
722 test_exceptions (test_name,exception);
723 output_isvalue_ext (test_name, isnan (computed), computed, parameter);
727 /* Tests if computed is +Inf */
728 static void
729 check_isinfp (const char *test_name, MATHTYPE computed)
731 output_new_test (test_name);
732 test_exceptions (test_name, NO_EXCEPTION);
733 output_isvalue (test_name, (ISINF (computed) == +1), computed);
737 static void
738 check_isinfp_ext (const char *test_name, MATHTYPE computed,
739 MATHTYPE parameter)
741 output_new_test (test_name);
742 test_exceptions (test_name, NO_EXCEPTION);
743 output_isvalue_ext (test_name, (ISINF (computed) == +1), computed, parameter);
747 /* Tests if computed is +Inf */
748 static void
749 check_isinfp_exc (const char *test_name, MATHTYPE computed,
750 int exception)
752 output_new_test (test_name);
753 test_exceptions (test_name, exception);
754 output_isvalue (test_name, (ISINF (computed) == +1), computed);
757 /* Tests if computed is -Inf */
758 static void
759 check_isinfn (const char *test_name, MATHTYPE computed)
761 output_new_test (test_name);
762 test_exceptions (test_name, NO_EXCEPTION);
763 output_isvalue (test_name, (ISINF (computed) == -1), computed);
767 #ifndef TEST_INLINE
768 static void
769 check_isinfn_ext (const char *test_name, MATHTYPE computed,
770 MATHTYPE parameter)
772 output_new_test (test_name);
773 test_exceptions (test_name, NO_EXCEPTION);
774 output_isvalue_ext (test_name, (ISINF (computed) == -1), computed, parameter);
776 #endif
779 /* Tests if computed is -Inf */
780 static void
781 check_isinfn_exc (const char *test_name, MATHTYPE computed,
782 int exception)
784 output_new_test (test_name);
785 test_exceptions (test_name, exception);
786 output_isvalue (test_name, (ISINF (computed) == -1), computed);
790 /* This is to prevent messages from the SVID libm emulation. */
792 matherr (struct exception *x __attribute__ ((unused)))
794 return 1;
798 /****************************************************************************
799 Test for single functions of libm
800 ****************************************************************************/
802 static void
803 acos_test (void)
805 #ifndef TEST_INLINE
806 MATHTYPE x;
808 x = random_greater (1);
809 check_isnan_exc ("acos (x) == NaN plus invalid exception for |x| > 1",
810 FUNC(acos) (x),
811 INVALID_EXCEPTION);
813 x = random_less (1);
814 check_isnan_exc ("acos (x) == NaN plus invalid exception for |x| > 1",
815 FUNC(acos) (x),
816 INVALID_EXCEPTION);
817 #endif
819 check ("acos (1) == 0", FUNC(acos) (1), 0);
820 check ("acos (-1) == pi", FUNC(acos) (-1), M_PI);
824 static void
825 acosh_test (void)
827 #ifndef TEST_INLINE
828 MATHTYPE x;
830 check_isinfp ("acosh(+inf) == +inf", FUNC(acosh) (plus_infty));
832 x = random_less (1);
833 check_isnan_exc ("acosh(x) == NaN plus invalid exception if x < 1",
834 FUNC(acosh) (x), INVALID_EXCEPTION);
835 #endif
837 check ("acosh(1) == 0", FUNC(acosh) (1), 0);
841 static void
842 asin_test (void)
844 #ifndef TEST_INLINE
845 MATHTYPE x;
847 x = random_greater (1);
848 check_isnan_exc ("asin x == NaN plus invalid exception for |x| > 1",
849 FUNC(asin) (x),
850 INVALID_EXCEPTION);
852 x = random_less (1);
853 check_isnan_exc ("asin x == NaN plus invalid exception for |x| > 1",
854 FUNC(asin) (x),
855 INVALID_EXCEPTION);
856 #endif
858 check ("asin (0) == 0", FUNC(asin) (0), 0);
862 static void
863 asinh_test (void)
866 check ("asinh(+0) == +0", FUNC(asinh) (0), 0);
867 #ifndef TEST_INLINE
868 check ("asinh(-0) == -0", FUNC(asinh) (minus_zero), minus_zero);
869 check_isinfp ("asinh(+inf) == +inf", FUNC(asinh) (plus_infty));
870 check_isinfn ("asinh(-inf) == -inf", FUNC(asinh) (minus_infty));
871 #endif
876 static void
877 atan_test (void)
879 check ("atan (0) == 0", FUNC(atan) (0), 0);
880 check ("atan (-0) == -0", FUNC(atan) (minus_zero), minus_zero);
882 check ("atan (+inf) == pi/2", FUNC(atan) (plus_infty), M_PI_2);
883 check ("atan (-inf) == -pi/2", FUNC(atan) (minus_infty), -M_PI_2);
887 static void
888 atan2_test (void)
890 MATHTYPE x;
892 x = random_greater (0);
893 check ("atan2 (0,x) == 0 for x > 0",
894 FUNC(atan2) (0, x), 0);
895 x = random_greater (0);
896 check ("atan2 (-0,x) == -0 for x > 0",
897 FUNC(atan2) (minus_zero, x), minus_zero);
899 check ("atan2 (+0,+0) == +0", FUNC(atan2) (0, 0), 0);
900 check ("atan2 (-0,+0) == -0", FUNC(atan2) (minus_zero, 0), minus_zero);
902 x = -random_greater (0);
903 check ("atan2 (+0,x) == +pi for x < 0", FUNC(atan2) (0, x), M_PI);
905 x = -random_greater (0);
906 check ("atan2 (-0,x) == -pi for x < 0", FUNC(atan2) (minus_zero, x), -M_PI);
908 check ("atan2 (+0,-0) == +pi", FUNC(atan2) (0, minus_zero), M_PI);
909 check ("atan2 (-0,-0) == -pi", FUNC(atan2) (minus_zero, minus_zero), -M_PI);
911 x = random_greater (0);
912 check ("atan2 (y,+0) == pi/2 for y > 0", FUNC(atan2) (x, 0), M_PI_2);
914 x = random_greater (0);
915 check ("atan2 (y,-0) == pi/2 for y > 0", FUNC(atan2) (x, minus_zero), M_PI_2);
917 x = random_less (0);
918 check ("atan2 (y,+0) == -pi/2 for y < 0", FUNC(atan2) (x, 0), -M_PI_2);
920 x = random_less (0);
921 check ("atan2 (y,-0) == -pi/2 for y < 0", FUNC(atan2) (x, minus_zero), -M_PI_2);
923 x = random_greater (0);
924 check ("atan2 (y,inf) == +0 for finite y > 0",
925 FUNC(atan2) (x, plus_infty), 0);
927 x = -random_greater (0);
928 check ("atan2 (y,inf) == -0 for finite y < 0",
929 FUNC(atan2) (x, plus_infty), minus_zero);
931 x = random_value (-1e4, 1e4);
932 check ("atan2(+inf, x) == pi/2 for finite x",
933 FUNC(atan2) (plus_infty, x), M_PI_2);
935 x = random_value (-1e4, 1e4);
936 check ("atan2(-inf, x) == -pi/2 for finite x",
937 FUNC(atan2) (minus_infty, x), -M_PI_2);
939 x = random_greater (0);
940 check ("atan2 (y,-inf) == +pi for finite y > 0",
941 FUNC(atan2) (x, minus_infty), M_PI);
943 x = -random_greater (0);
944 check ("atan2 (y,-inf) == -pi for finite y < 0",
945 FUNC(atan2) (x, minus_infty), -M_PI);
947 check ("atan2 (+inf,+inf) == +pi/4",
948 FUNC(atan2) (plus_infty, plus_infty), M_PI_4);
950 check ("atan2 (-inf,+inf) == -pi/4",
951 FUNC(atan2) (minus_infty, plus_infty), -M_PI_4);
953 check ("atan2 (+inf,-inf) == +3*pi/4",
954 FUNC(atan2) (plus_infty, minus_infty), 3 * M_PI_4);
956 check ("atan2 (-inf,-inf) == -3*pi/4",
957 FUNC(atan2) (minus_infty, minus_infty), -3 * M_PI_4);
959 /* FIXME: Add some specific tests */
963 static void
964 atanh_test (void)
966 #ifndef TEST_INLINE
967 MATHTYPE x;
968 #endif
970 check ("atanh(+0) == +0", FUNC(atanh) (0), 0);
971 #ifndef TEST_INLINE
972 check ("atanh(-0) == -0", FUNC(atanh) (minus_zero), minus_zero);
974 check_isinfp_exc ("atanh(+1) == +inf plus divide-by-zero exception",
975 FUNC(atanh) (1), DIVIDE_BY_ZERO_EXCEPTION);
976 check_isinfn_exc ("atanh(-1) == -inf plus divide-by-zero exception",
977 FUNC(atanh) (-1), DIVIDE_BY_ZERO_EXCEPTION);
979 x = random_greater (1.0);
980 check_isnan_exc_ext ("atanh (x) == NaN plus invalid exception if |x| > 1",
981 FUNC(atanh) (x), INVALID_EXCEPTION, x);
983 x = random_less (1.0);
984 check_isnan_exc_ext ("atanh (x) == NaN plus invalid exception if |x| > 1",
985 FUNC(atanh) (x), INVALID_EXCEPTION, x);
987 #endif
991 static void
992 cbrt_test (void)
994 check ("cbrt (+0) == +0", FUNC(cbrt) (0.0), 0.0);
995 check ("cbrt (-0) == -0", FUNC(cbrt) (minus_zero), minus_zero);
997 #ifndef TEST_INLINE
998 check_isinfp ("cbrt (+inf) == +inf", FUNC(cbrt) (plus_infty));
999 check_isinfn ("cbrt (-inf) == -inf", FUNC(cbrt) (minus_infty));
1000 check_isnan ("cbrt (NaN) == NaN", FUNC(cbrt) (nan_value));
1001 #endif
1002 check_eps ("cbrt (-0.001) == -0.1", FUNC(cbrt) (-0.001), -0.1,
1003 CHOOSE (5e-18L, 0, 0));
1004 check_eps ("cbrt (8) == 2", FUNC(cbrt) (8), 2, CHOOSE (5e-17L, 0, 0));
1005 check_eps ("cbrt (-27) == -3", FUNC(cbrt) (-27.0), -3.0,
1006 CHOOSE (3e-16L, 5e-16, 0));
1010 static void
1011 ceil_test (void)
1013 check ("ceil (+0) == +0", FUNC(ceil) (0.0), 0.0);
1014 check ("ceil (-0) == -0", FUNC(ceil) (minus_zero), minus_zero);
1015 check_isinfp ("ceil (+inf) == +inf", FUNC(ceil) (plus_infty));
1016 check_isinfn ("ceil (-inf) == -inf", FUNC(ceil) (minus_infty));
1018 check ("ceil (pi) == 4", FUNC(ceil) (M_PI), 4.0);
1019 check ("ceil (-pi) == -3", FUNC(ceil) (-M_PI), -3.0);
1023 static void
1024 cos_test (void)
1027 check ("cos (+0) == 1", FUNC(cos) (0), 1);
1028 check ("cos (-0) == 1", FUNC(cos) (minus_zero), 1);
1029 check_isnan_exc ("cos (+inf) == NaN plus invalid exception",
1030 FUNC(cos) (plus_infty),
1031 INVALID_EXCEPTION);
1032 check_isnan_exc ("cos (-inf) == NaN plus invalid exception",
1033 FUNC(cos) (minus_infty),
1034 INVALID_EXCEPTION);
1036 check_eps ("cos (pi/3) == 0.5", FUNC(cos) (M_PI_6 * 2.0),
1037 0.5, CHOOSE (4e-18L, 1e-15L, 1e-7L));
1038 check_eps ("cos (pi/2) == 0", FUNC(cos) (M_PI_2),
1039 0, CHOOSE (1e-19L, 1e-16L, 1e-7L));
1043 static void
1044 cosh_test (void)
1046 check ("cosh (+0) == 1", FUNC(cosh) (0), 1);
1047 check ("cosh (-0) == 1", FUNC(cosh) (minus_zero), 1);
1049 #ifndef TEST_INLINE
1050 check_isinfp ("cosh (+inf) == +inf", FUNC(cosh) (plus_infty));
1051 check_isinfp ("cosh (-inf) == +inf", FUNC(cosh) (minus_infty));
1052 #endif
1056 static void
1057 erf_test (void)
1059 errno = 0;
1060 FUNC(erf) (0);
1061 if (errno == ENOSYS)
1062 /* Function not implemented. */
1063 return;
1065 check ("erf (+0) == +0", FUNC(erf) (0), 0);
1066 check ("erf (-0) == -0", FUNC(erf) (minus_zero), minus_zero);
1067 check ("erf (+inf) == +1", FUNC(erf) (plus_infty), 1);
1068 check ("erf (-inf) == -1", FUNC(erf) (minus_infty), -1);
1072 static void
1073 erfc_test (void)
1075 errno = 0;
1076 FUNC(erfc) (0);
1077 if (errno == ENOSYS)
1078 /* Function not implemented. */
1079 return;
1081 check ("erfc (+inf) == 0", FUNC(erfc) (plus_infty), 0.0);
1082 check ("erfc (-inf) == 2", FUNC(erfc) (minus_infty), 2.0);
1083 check ("erfc (+0) == 1", FUNC(erfc) (0.0), 1.0);
1084 check ("erfc (-0) == 1", FUNC(erfc) (minus_zero), 1.0);
1088 static void
1089 exp_test (void)
1091 check ("exp (+0) == 1", FUNC(exp) (0), 1);
1092 check ("exp (-0) == 1", FUNC(exp) (minus_zero), 1);
1094 #ifndef TEST_INLINE
1095 check_isinfp ("exp (+inf) == +inf", FUNC(exp) (plus_infty));
1096 check ("exp (-inf) == 0", FUNC(exp) (minus_infty), 0);
1097 #endif
1098 check_eps ("exp (1) == e", FUNC(exp) (1), M_E, CHOOSE (4e-18L, 5e-16, 0));
1102 static void
1103 exp2_test (void)
1105 errno = 0;
1106 FUNC(exp2) (0);
1107 if (errno == ENOSYS)
1108 /* Function not implemented. */
1109 return;
1111 check ("exp2 (+0) == 1", FUNC(exp2) (0), 1);
1112 check ("exp2 (-0) == 1", FUNC(exp2) (minus_zero), 1);
1114 check_isinfp ("exp2 (+inf) == +inf", FUNC(exp2) (plus_infty));
1115 check ("exp2 (-inf) == 0", FUNC(exp2) (minus_infty), 0);
1116 check ("exp2 (10) == 1024", FUNC(exp2) (10), 1024);
1117 check ("exp2 (-1) == 0.5", FUNC(exp2) (-1), 0.5);
1118 check_isinfp ("exp2 (1e6) == +inf", FUNC(exp2) (1e6));
1119 check ("exp2 (-1e6) == 0", FUNC(exp2) (-1e6), 0);
1123 static void
1124 expm1_test (void)
1126 check ("expm1 (+0) == 0", FUNC(expm1) (0), 0);
1127 #ifndef TEST_INLINE
1128 check ("expm1 (-0) == -0", FUNC(expm1) (minus_zero), minus_zero);
1130 check_isinfp ("expm1 (+inf) == +inf", FUNC(expm1) (plus_infty));
1131 check ("expm1 (-inf) == -1", FUNC(expm1) (minus_infty), -1);
1132 #endif
1134 check_eps ("expm1 (1) == e-1", FUNC(expm1) (1), M_E - 1.0,
1135 CHOOSE (4e-18L, 0, 2e-7));
1141 static void
1142 check_frexp (const char *test_name, MATHTYPE computed, MATHTYPE expected,
1143 int comp_int, int exp_int)
1145 MATHTYPE diff;
1146 int result;
1148 result = (check_equal (computed, expected, 0, &diff)
1149 && (comp_int == exp_int));
1151 if (result)
1153 if (verbose > 2)
1154 printf ("Pass: %s\n", test_name);
1156 else
1158 if (verbose)
1159 printf ("Fail: %s\n", test_name);
1160 if (verbose > 1)
1162 printf ("Result:\n");
1163 printf (" is: %.20" PRINTF_EXPR " *2^%d\n", computed, comp_int);
1164 printf (" should be: %.20" PRINTF_EXPR " *2^%d\n", expected, exp_int);
1165 printf (" difference: %.20" PRINTF_EXPR "\n", diff);
1167 noErrors++;
1169 fpstack_test (test_name);
1170 output_result (test_name, result,
1171 computed, expected, diff, PRINT, PRINT);
1175 static void
1176 frexp_test (void)
1178 int x_int;
1179 MATHTYPE result;
1181 result = FUNC(frexp) (plus_infty, &x_int);
1182 check_isinfp ("frexp (+inf, expr) == +inf", result);
1184 result = FUNC(frexp) (minus_infty, &x_int);
1185 check_isinfn ("frexp (-inf, expr) == -inf", result);
1187 result = FUNC(frexp) (nan_value, &x_int);
1188 check_isnan ("frexp (Nan, expr) == NaN", result);
1190 result = FUNC(frexp) (0, &x_int);
1191 check_frexp ("frexp: +0 == 0 * 2^0", result, 0, x_int, 0);
1193 result = FUNC(frexp) (minus_zero, &x_int);
1194 check_frexp ("frexp: -0 == -0 * 2^0", result, minus_zero, x_int, 0);
1196 result = FUNC(frexp) (12.8L, &x_int);
1197 check_frexp ("frexp: 12.8 == 0.8 * 2^4", result, 0.8L, x_int, 4);
1199 result = FUNC(frexp) (-27.34L, &x_int);
1200 check_frexp ("frexp: -27.34 == -0.854375 * 2^5", result, -0.854375L, x_int, 5);
1205 #if __GLIBC__ < 2 || (__GLIBC__ == 2 && __GLIBC_MINOR__ < 1)
1206 /* All floating-point numbers can be put in one of these categories. */
1207 enum
1209 FP_NAN,
1210 #define FP_NAN FP_NAN
1211 FP_INFINITE,
1212 #define FP_INFINITE FP_INFINITE
1213 FP_ZERO,
1214 #define FP_ZERO FP_ZERO
1215 FP_SUBNORMAL,
1216 #define FP_SUBNORMAL FP_SUBNORMAL
1217 FP_NORMAL
1218 #define FP_NORMAL FP_NORMAL
1220 #endif
1223 static void
1224 fpclassify_test (void)
1226 MATHTYPE x;
1228 /* fpclassify is a macro, don't give it constants as parameter */
1229 check_bool ("fpclassify (NaN) == FP_NAN", fpclassify (nan_value) == FP_NAN);
1230 check_bool ("fpclassify (+inf) == FP_INFINITE",
1231 fpclassify (plus_infty) == FP_INFINITE);
1232 check_bool ("fpclassify (-inf) == FP_INFINITE",
1233 fpclassify (minus_infty) == FP_INFINITE);
1234 check_bool ("fpclassify (+0) == FP_ZERO",
1235 fpclassify (plus_zero) == FP_ZERO);
1236 check_bool ("fpclassify (-0) == FP_ZERO",
1237 fpclassify (minus_zero) == FP_ZERO);
1239 x = 1000.0;
1240 check_bool ("fpclassify (1000) == FP_NORMAL",
1241 fpclassify (x) == FP_NORMAL);
1245 static void
1246 isfinite_test (void)
1248 check_bool ("isfinite (0) != 0", isfinite (0));
1249 check_bool ("isfinite (-0) != 0", isfinite (minus_zero));
1250 check_bool ("isfinite (10) != 0", isfinite (10));
1251 check_bool ("isfinite (+inf) == 0", isfinite (plus_infty) == 0);
1252 check_bool ("isfinite (-inf) == 0", isfinite (minus_infty) == 0);
1253 check_bool ("isfinite (NaN) == 0", isfinite (nan_value) == 0);
1257 static void
1258 isnormal_test (void)
1260 check_bool ("isnormal (0) == 0", isnormal (0) == 0);
1261 check_bool ("isnormal (-0) == 0", isnormal (minus_zero) == 0);
1262 check_bool ("isnormal (10) != 0", isnormal (10));
1263 check_bool ("isnormal (+inf) == 0", isnormal (plus_infty) == 0);
1264 check_bool ("isnormal (-inf) == 0", isnormal (minus_infty) == 0);
1265 check_bool ("isnormal (NaN) == 0", isnormal (nan_value) == 0);
1270 static void
1271 signbit_test (void)
1273 MATHTYPE x;
1275 check_bool ("signbit (+0) == 0", signbit (0) == 0);
1276 check_bool ("signbit (-0) != 0", signbit (minus_zero));
1277 check_bool ("signbit (+inf) == 0", signbit (plus_infty) == 0);
1278 check_bool ("signbit (-inf) != 0", signbit (minus_infty));
1280 x = random_less (0);
1281 check_bool ("signbit (x) != 0 for x < 0", signbit (x));
1283 x = random_greater (0);
1284 check_bool ("signbit (x) == 0 for x > 0", signbit (x) == 0);
1290 gamma has different semantics depending on _LIB_VERSION:
1291 if _LIB_VERSION is _SVID, gamma is just an alias for lgamma,
1292 otherwise gamma is the real gamma function as definied in ISO C 9X.
1294 static void
1295 gamma_test (void)
1297 int save_lib_version = _LIB_VERSION;
1298 errno = 0;
1299 FUNC(gamma) (1);
1300 if (errno == ENOSYS)
1301 /* Function not implemented. */
1302 return;
1303 feclearexcept (FE_ALL_EXCEPT);
1306 _LIB_VERSION = _SVID_;
1308 check_isinfp ("gamma (+inf) == +inf", FUNC(gamma) (plus_infty));
1309 check_isinfp_exc ("gamma (0) == +inf plus divide by zero exception",
1310 FUNC(gamma) (0), DIVIDE_BY_ZERO_EXCEPTION);
1312 check_isinfp_exc ("gamma (x) == +inf plus divide by zero exception for integer x <= 0",
1313 FUNC(gamma) (-3), DIVIDE_BY_ZERO_EXCEPTION);
1314 check_isnan_exc ("gamma (-inf) == NaN plus invalid exception",
1315 FUNC(gamma) (minus_infty), INVALID_EXCEPTION);
1317 signgam = 0;
1318 check ("gamma (1) == 0", FUNC(gamma) (1), 0);
1319 check_int ("gamma (0) sets signgam to 1", signgam, 1);
1321 signgam = 0;
1322 check ("gamma (3) == M_LN2", FUNC(gamma) (3), M_LN2);
1323 check_int ("gamma (3) sets signgam to 1", signgam, 1);
1325 signgam = 0;
1326 check_eps ("gamma (0.5) == log(sqrt(pi))", FUNC(gamma) (0.5),
1327 FUNC(log) (FUNC(sqrt) (M_PI)), CHOOSE (0, 1e-15, 1e-7));
1328 check_int ("gamma (0.5) sets signgam to 1", signgam, 1);
1330 signgam = 0;
1331 check_eps ("gamma (-0.5) == log(2*sqrt(pi))", FUNC(gamma) (-0.5),
1332 FUNC(log) (2*FUNC(sqrt) (M_PI)), CHOOSE (0, 1e-15, 0));
1334 check_int ("gamma (-0.5) sets signgam to -1", signgam, -1);
1337 _LIB_VERSION = _IEEE_;
1339 check_isinfp ("gamma (+inf) == +inf", FUNC(gamma) (plus_infty));
1340 check_isnan_exc ("gamma (0) == NaN plus invalid exception",
1341 FUNC(gamma) (0), INVALID_EXCEPTION);
1343 check_isnan_exc_ext ("gamma (x) == NaN plus invalid exception for integer x <= 0",
1344 FUNC(gamma) (-2), INVALID_EXCEPTION, -2);
1345 check_isnan_exc ("gamma (-inf) == NaN plus invalid exception",
1346 FUNC(gamma) (minus_infty), INVALID_EXCEPTION);
1348 check_eps ("gamma (0.5) == sqrt(pi)", FUNC(gamma) (0.5), FUNC(sqrt) (M_PI),
1349 CHOOSE (0, 5e-16, 2e-7));
1350 check_eps ("gamma (-0.5) == -2*sqrt(pi)", FUNC(gamma) (-0.5),
1351 -2*FUNC(sqrt) (M_PI), CHOOSE (0, 5e-16, 3e-7));
1353 check ("gamma (1) == 1", FUNC(gamma) (1), 1);
1354 check ("gamma (4) == 6", FUNC(gamma) (4), 6);
1356 _LIB_VERSION = save_lib_version;
1360 static void
1361 lgamma_test (void)
1363 errno = 0;
1364 FUNC(lgamma) (0);
1365 if (errno == ENOSYS)
1366 /* Function not implemented. */
1367 return;
1368 feclearexcept (FE_ALL_EXCEPT);
1370 check_isinfp ("lgamma (+inf) == +inf", FUNC(lgamma) (plus_infty));
1371 check_isinfp_exc ("lgamma (0) == +inf plus divide by zero exception",
1372 FUNC(lgamma) (0), DIVIDE_BY_ZERO_EXCEPTION);
1374 check_isinfp_exc ("lgamma (x) == +inf plus divide by zero exception for integer x <= 0",
1375 FUNC(lgamma) (-3), DIVIDE_BY_ZERO_EXCEPTION);
1376 check_isnan_exc ("lgamma (-inf) == NaN plus invalid exception",
1377 FUNC(lgamma) (minus_infty), INVALID_EXCEPTION);
1379 signgam = 0;
1380 check ("lgamma (1) == 0", FUNC(lgamma) (1), 0);
1381 check_int ("lgamma (0) sets signgam to 1", signgam, 1);
1383 signgam = 0;
1384 check ("lgamma (3) == M_LN2", FUNC(lgamma) (3), M_LN2);
1385 check_int ("lgamma (3) sets signgam to 1", signgam, 1);
1387 signgam = 0;
1388 check_eps ("lgamma (0.5) == log(sqrt(pi))", FUNC(lgamma) (0.5),
1389 FUNC(log) (FUNC(sqrt) (M_PI)), CHOOSE (0, 1e-15, 1e-7));
1390 check_int ("lgamma (0.5) sets signgam to 1", signgam, 1);
1392 signgam = 0;
1393 check_eps ("lgamma (-0.5) == log(2*sqrt(pi))", FUNC(lgamma) (-0.5),
1394 FUNC(log) (2*FUNC(sqrt) (M_PI)), CHOOSE (0, 1e-15, 0));
1396 check_int ("lgamma (-0.5) sets signgam to -1", signgam, -1);
1401 static void
1402 ilogb_test (void)
1404 int i;
1406 check_int ("ilogb (1) == 0", FUNC(ilogb) (1), 0);
1407 check_int ("ilogb (e) == 1", FUNC(ilogb) (M_E), 1);
1408 check_int ("ilogb (1024) == 10", FUNC(ilogb) (1024), 10);
1409 check_int ("ilogb (-2000) == 10", FUNC(ilogb) (-2000), 10);
1411 /* XXX We have a problem here: the standard does not tell us whether
1412 exceptions are allowed/required. ignore them for now. */
1413 i = FUNC (ilogb) (0.0);
1414 feclearexcept (FE_ALL_EXCEPT);
1415 check_int ("ilogb (0) == FP_ILOGB0", i, FP_ILOGB0);
1416 i = FUNC(ilogb) (nan_value);
1417 feclearexcept (FE_ALL_EXCEPT);
1418 check_int ("ilogb (NaN) == FP_ILOGBNAN", i, FP_ILOGBNAN);
1423 static void
1424 ldexp_test (void)
1426 MATHTYPE x;
1428 check ("ldexp (0, 0) == 0", FUNC(ldexp) (0, 0), 0);
1430 check_isinfp ("ldexp (+inf, 1) == +inf", FUNC(ldexp) (plus_infty, 1));
1431 check_isinfn ("ldexp (-inf, 1) == -inf", FUNC(ldexp) (minus_infty, 1));
1432 check_isnan ("ldexp (NaN, 1) == NaN", FUNC(ldexp) (nan_value, 1));
1434 check ("ldexp (0.8, 4) == 12.8", FUNC(ldexp) (0.8L, 4), 12.8L);
1435 check ("ldexp (-0.854375, 5) == -27.34", FUNC(ldexp) (-0.854375L, 5), -27.34L);
1437 x = random_greater (0.0);
1438 check_ext ("ldexp (x, 0) == x", FUNC(ldexp) (x, 0L), x, x);
1443 static void
1444 log_test (void)
1446 check_isinfn_exc ("log (+0) == -inf plus divide-by-zero exception",
1447 FUNC(log) (0), DIVIDE_BY_ZERO_EXCEPTION);
1448 check_isinfn_exc ("log (-0) == -inf plus divide-by-zero exception",
1449 FUNC(log) (minus_zero), DIVIDE_BY_ZERO_EXCEPTION);
1451 check ("log (1) == 0", FUNC(log) (1), 0);
1453 check_isnan_exc ("log (x) == NaN plus invalid exception if x < 0",
1454 FUNC(log) (-1), INVALID_EXCEPTION);
1455 check_isinfp ("log (+inf) == +inf", FUNC(log) (plus_infty));
1457 check_eps ("log (e) == 1", FUNC(log) (M_E), 1, CHOOSE (1e-18L, 0, 9e-8L));
1458 check_eps ("log (1/e) == -1", FUNC(log) (1.0 / M_E), -1,
1459 CHOOSE (2e-18L, 0, 0));
1460 check ("log (2) == M_LN2", FUNC(log) (2), M_LN2);
1461 check_eps ("log (10) == M_LN10", FUNC(log) (10), M_LN10,
1462 CHOOSE (1e-18L, 0, 0));
1466 static void
1467 log10_test (void)
1469 check_isinfn_exc ("log10 (+0) == -inf plus divide-by-zero exception",
1470 FUNC(log10) (0), DIVIDE_BY_ZERO_EXCEPTION);
1471 check_isinfn_exc ("log10 (-0) == -inf plus divide-by-zero exception",
1472 FUNC(log10) (minus_zero), DIVIDE_BY_ZERO_EXCEPTION);
1474 check ("log10 (1) == +0", FUNC(log10) (1), 0);
1476 check_isnan_exc ("log10 (x) == NaN plus invalid exception if x < 0",
1477 FUNC(log10) (-1), INVALID_EXCEPTION);
1479 check_isinfp ("log10 (+inf) == +inf", FUNC(log10) (plus_infty));
1481 check_eps ("log10 (0.1) == -1", FUNC(log10) (0.1L), -1,
1482 CHOOSE (1e-18L, 0, 0));
1483 check_eps ("log10 (10) == 1", FUNC(log10) (10.0), 1,
1484 CHOOSE (1e-18L, 0, 0));
1485 check_eps ("log10 (100) == 2", FUNC(log10) (100.0), 2,
1486 CHOOSE (1e-18L, 0, 0));
1487 check ("log10 (10000) == 4", FUNC(log10) (10000.0), 4);
1488 check_eps ("log10 (e) == M_LOG10E", FUNC(log10) (M_E), M_LOG10E,
1489 CHOOSE (1e-18, 0, 9e-8));
1493 static void
1494 log1p_test (void)
1496 check ("log1p (+0) == +0", FUNC(log1p) (0), 0);
1497 check ("log1p (-0) == -0", FUNC(log1p) (minus_zero), minus_zero);
1499 check_isinfn_exc ("log1p (-1) == -inf plus divide-by-zero exception",
1500 FUNC(log1p) (-1), DIVIDE_BY_ZERO_EXCEPTION);
1501 check_isnan_exc ("log1p (x) == NaN plus invalid exception if x < -1",
1502 FUNC(log1p) (-2), INVALID_EXCEPTION);
1504 check_isinfp ("log1p (+inf) == +inf", FUNC(log1p) (plus_infty));
1506 check_eps ("log1p (e-1) == 1", FUNC(log1p) (M_E - 1.0), 1,
1507 CHOOSE (1e-18L, 0, 0));
1512 static void
1513 log2_test (void)
1515 check_isinfn_exc ("log2 (+0) == -inf plus divide-by-zero exception",
1516 FUNC(log2) (0), DIVIDE_BY_ZERO_EXCEPTION);
1517 check_isinfn_exc ("log2 (-0) == -inf plus divide-by-zero exception",
1518 FUNC(log2) (minus_zero), DIVIDE_BY_ZERO_EXCEPTION);
1520 check ("log2 (1) == +0", FUNC(log2) (1), 0);
1522 check_isnan_exc ("log2 (x) == NaN plus invalid exception if x < 0",
1523 FUNC(log2) (-1), INVALID_EXCEPTION);
1525 check_isinfp ("log2 (+inf) == +inf", FUNC(log2) (plus_infty));
1527 check_eps ("log2 (e) == M_LOG2E", FUNC(log2) (M_E), M_LOG2E,
1528 CHOOSE (1e-18L, 0, 0));
1529 check ("log2 (2) == 1", FUNC(log2) (2.0), 1);
1530 check_eps ("log2 (16) == 4", FUNC(log2) (16.0), 4, CHOOSE (1e-18L, 0, 0));
1531 check ("log2 (256) == 8", FUNC(log2) (256.0), 8);
1536 static void
1537 logb_test (void)
1539 check_isinfp ("logb (+inf) == +inf", FUNC(logb) (plus_infty));
1540 check_isinfp ("logb (-inf) == +inf", FUNC(logb) (minus_infty));
1542 check_isinfn_exc ("logb (+0) == -inf plus divide-by-zero exception",
1543 FUNC(logb) (0), DIVIDE_BY_ZERO_EXCEPTION);
1545 check_isinfn_exc ("logb (-0) == -inf plus divide-by-zero exception",
1546 FUNC(logb) (minus_zero), DIVIDE_BY_ZERO_EXCEPTION);
1548 check ("logb (1) == 0", FUNC(logb) (1), 0);
1549 check ("logb (e) == 1", FUNC(logb) (M_E), 1);
1550 check ("logb (1024) == 10", FUNC(logb) (1024), 10);
1551 check ("logb (-2000) == 10", FUNC(logb) (-2000), 10);
1556 static void
1557 modf_test (void)
1559 MATHTYPE result, intpart;
1561 result = FUNC(modf) (plus_infty, &intpart);
1562 check ("modf (+inf, &x) returns +0", result, 0);
1563 check_isinfp ("modf (+inf, &x) set x to +inf", intpart);
1565 result = FUNC(modf) (minus_infty, &intpart);
1566 check ("modf (-inf, &x) returns -0", result, minus_zero);
1567 check_isinfn ("modf (-inf, &x) sets x to -inf", intpart);
1569 result = FUNC(modf) (nan_value, &intpart);
1570 check_isnan ("modf (NaN, &x) returns NaN", result);
1571 check_isnan ("modf (NaN, &x) sets x to NaN", intpart);
1573 result = FUNC(modf) (0, &intpart);
1574 check ("modf (0, &x) returns 0", result, 0);
1575 check ("modf (0, &x) sets x to 0", intpart, 0);
1577 result = FUNC(modf) (minus_zero, &intpart);
1578 check ("modf (-0, &x) returns -0", result, minus_zero);
1579 check ("modf (-0, &x) sets x to -0", intpart, minus_zero);
1581 result = FUNC(modf) (2.5, &intpart);
1582 check ("modf (2.5, &x) returns 0.5", result, 0.5);
1583 check ("modf (2.5, &x) sets x to 2", intpart, 2);
1585 result = FUNC(modf) (-2.5, &intpart);
1586 check ("modf (-2.5, &x) returns -0.5", result, -0.5);
1587 check ("modf (-2.5, &x) sets x to -2", intpart, -2);
1592 static void
1593 scalb_test (void)
1595 MATHTYPE x;
1597 check_isnan ("scalb (2, 0.5) == NaN", FUNC(scalb) (2, 0.5));
1598 check_isnan ("scalb (3, -2.5) == NaN", FUNC(scalb) (3, -2.5));
1600 check_isnan ("scalb (0, NaN) == NaN", FUNC(scalb) (0, nan_value));
1601 check_isnan ("scalb (1, NaN) == NaN", FUNC(scalb) (1, nan_value));
1603 x = random_greater (0.0);
1604 check ("scalb (x, 0) == 0", FUNC(scalb) (x, 0), x);
1605 x = random_greater (0.0);
1606 check ("scalb (-x, 0) == 0", FUNC(scalb) (-x, 0), -x);
1608 check_isnan_exc ("scalb (+0, +inf) == NaN plus invalid exception",
1609 FUNC(scalb) (0, plus_infty), INVALID_EXCEPTION);
1610 check_isnan_exc ("scalb (-0, +inf) == NaN plus invalid exception",
1611 FUNC(scalb) (minus_zero, plus_infty), INVALID_EXCEPTION);
1613 check ("scalb (+0, 2) == +0", FUNC(scalb) (0, 2), 0);
1614 check ("scalb (-0, 4) == -0", FUNC(scalb) (minus_zero, -4), minus_zero);
1615 check ("scalb (+0, 0) == +0", FUNC(scalb) (0, 0), 0);
1616 check ("scalb (-0, 0) == -0", FUNC(scalb) (minus_zero, 0), minus_zero);
1617 check ("scalb (+0, -1) == +0", FUNC(scalb) (0, -1), 0);
1618 check ("scalb (-0, -10) == -0", FUNC(scalb) (minus_zero, -10), minus_zero);
1619 check ("scalb (+0, -inf) == +0", FUNC(scalb) (0, minus_infty), 0);
1620 check ("scalb (-0, -inf) == -0", FUNC(scalb) (minus_zero, minus_infty),
1621 minus_zero);
1623 check_isinfp ("scalb (+inf, -1) == +inf", FUNC(scalb) (plus_infty, -1));
1624 check_isinfn ("scalb (-inf, -10) == -inf", FUNC(scalb) (minus_infty, -10));
1625 check_isinfp ("scalb (+inf, 0) == +inf", FUNC(scalb) (plus_infty, 0));
1626 check_isinfn ("scalb (-inf, 0) == -inf", FUNC(scalb) (minus_infty, 0));
1627 check_isinfp ("scalb (+inf, 2) == +inf", FUNC(scalb) (plus_infty, 2));
1628 check_isinfn ("scalb (-inf, 100) == -inf", FUNC(scalb) (minus_infty, 100));
1630 x = random_greater (0.0);
1631 check ("scalb (x, -inf) == 0", FUNC(scalb) (x, minus_infty), 0.0);
1632 check ("scalb (-x, -inf) == -0", FUNC(scalb) (-x, minus_infty), minus_zero);
1634 x = random_greater (0.0);
1635 check_isinfp ("scalb (x, +inf) == +inf", FUNC(scalb) (x, plus_infty));
1636 x = random_greater (0.0);
1637 check_isinfn ("scalb (-x, +inf) == -inf", FUNC(scalb) (-x, plus_infty));
1638 check_isinfp ("scalb (+inf, +inf) == +inf",
1639 FUNC(scalb) (plus_infty, plus_infty));
1640 check_isinfn ("scalb (-inf, +inf) == -inf",
1641 FUNC(scalb) (minus_infty, plus_infty));
1643 check_isnan ("scalb (+inf, -inf) == NaN",
1644 FUNC(scalb) (plus_infty, minus_infty));
1645 check_isnan ("scalb (-inf, -inf) == NaN",
1646 FUNC(scalb) (minus_infty, minus_infty));
1648 check_isnan ("scalb (NaN, 1) == NaN", FUNC(scalb) (nan_value, 1));
1649 check_isnan ("scalb (1, NaN) == NaN", FUNC(scalb) (1, nan_value));
1650 check_isnan ("scalb (NaN, 0) == NaN", FUNC(scalb) (nan_value, 0));
1651 check_isnan ("scalb (0, NaN) == NaN", FUNC(scalb) (0, nan_value));
1652 check_isnan ("scalb (NaN, +inf) == NaN",
1653 FUNC(scalb) (nan_value, plus_infty));
1654 check_isnan ("scalb (+inf, NaN) == NaN",
1655 FUNC(scalb) (plus_infty, nan_value));
1656 check_isnan ("scalb (NaN, NaN) == NaN", FUNC(scalb) (nan_value, nan_value));
1658 check ("scalb (0.8, 4) == 12.8", FUNC(scalb) (0.8L, 4), 12.8L);
1659 check ("scalb (-0.854375, 5) == -27.34", FUNC(scalb) (-0.854375L, 5), -27.34L);
1663 static void
1664 scalbn_test (void)
1666 MATHTYPE x;
1668 check ("scalbn (0, 0) == 0", FUNC(scalbn) (0, 0), 0);
1670 check_isinfp ("scalbn (+inf, 1) == +inf", FUNC(scalbn) (plus_infty, 1));
1671 check_isinfn ("scalbn (-inf, 1) == -inf", FUNC(scalbn) (minus_infty, 1));
1672 check_isnan ("scalbn (NaN, 1) == NaN", FUNC(scalbn) (nan_value, 1));
1674 check ("scalbn (0.8, 4) == 12.8", FUNC(scalbn) (0.8L, 4), 12.8L);
1675 check ("scalbn (-0.854375, 5) == -27.34", FUNC(scalbn) (-0.854375L, 5), -27.34L);
1677 x = random_greater (0.0);
1678 check_ext ("scalbn (x, 0) == x", FUNC(scalbn) (x, 0L), x, x);
1682 static void
1683 sin_test (void)
1685 check ("sin (+0) == +0", FUNC(sin) (0), 0);
1686 check ("sin (-0) == -0", FUNC(sin) (minus_zero), minus_zero);
1687 check_isnan_exc ("sin (+inf) == NaN plus invalid exception",
1688 FUNC(sin) (plus_infty),
1689 INVALID_EXCEPTION);
1690 check_isnan_exc ("sin (-inf) == NaN plus invalid exception",
1691 FUNC(sin) (minus_infty),
1692 INVALID_EXCEPTION);
1694 check_eps ("sin (pi/6) == 0.5", FUNC(sin) (M_PI_6),
1695 0.5,CHOOSE (4e-18L, 0, 0));
1696 check ("sin (pi/2) == 1", FUNC(sin) (M_PI_2), 1);
1700 static void
1701 sinh_test (void)
1703 check ("sinh (+0) == +0", FUNC(sinh) (0), 0);
1705 #ifndef TEST_INLINE
1706 check ("sinh (-0) == -0", FUNC(sinh) (minus_zero), minus_zero);
1708 check_isinfp ("sinh (+inf) == +inf", FUNC(sinh) (plus_infty));
1709 check_isinfn ("sinh (-inf) == -inf", FUNC(sinh) (minus_infty));
1710 #endif
1714 static void
1715 sincos_test (void)
1717 MATHTYPE sin_res, cos_res;
1718 fenv_t fenv;
1720 FUNC(sincos) (0, &sin_res, &cos_res);
1721 fegetenv (&fenv);
1722 check ("sincos (+0, &sin, &cos) puts +0 in sin", sin_res, 0);
1723 fesetenv (&fenv);
1724 check ("sincos (+0, &sin, &cos) puts 1 in cos", cos_res, 1);
1726 FUNC(sincos) (minus_zero, &sin_res, &cos_res);
1727 fegetenv (&fenv);
1728 check ("sincos (-0, &sin, &cos) puts -0 in sin", sin_res, minus_zero);
1729 fesetenv (&fenv);
1730 check ("sincos (-0, &sin, &cos) puts 1 in cos", cos_res, 1);
1732 FUNC(sincos) (plus_infty, &sin_res, &cos_res);
1733 fegetenv (&fenv);
1734 check_isnan_exc ("sincos (+inf, &sin, &cos) puts NaN in sin plus invalid exception",
1735 sin_res, INVALID_EXCEPTION);
1736 fesetenv (&fenv);
1737 check_isnan_exc ("sincos (+inf, &sin, &cos) puts NaN in cos plus invalid exception",
1738 cos_res, INVALID_EXCEPTION);
1740 FUNC(sincos) (minus_infty, &sin_res, &cos_res);
1741 fegetenv (&fenv);
1742 check_isnan_exc ("sincos (-inf,&sin, &cos) puts NaN in sin plus invalid exception",
1743 sin_res, INVALID_EXCEPTION);
1744 fesetenv (&fenv);
1745 check_isnan_exc ("sincos (-inf,&sin, &cos) puts NaN in cos plus invalid exception",
1746 cos_res, INVALID_EXCEPTION);
1748 FUNC(sincos) (M_PI_2, &sin_res, &cos_res);
1749 fegetenv (&fenv);
1750 check ("sincos (pi/2, &sin, &cos) puts 1 in sin", sin_res, 1);
1751 fesetenv (&fenv);
1752 check_eps ("sincos (pi/2, &sin, &cos) puts 0 in cos", cos_res, 0,
1753 CHOOSE (1e-18L, 1e-16, 1e-7));
1755 FUNC(sincos) (M_PI_6, &sin_res, &cos_res);
1756 check_eps ("sincos (pi/6, &sin, &cos) puts 0.5 in sin", sin_res, 0.5,
1757 CHOOSE (5e-18L, 0, 0));
1759 FUNC(sincos) (M_PI_6*2.0, &sin_res, &cos_res);
1760 check_eps ("sincos (pi/3, &sin, &cos) puts 0.5 in cos", cos_res, 0.5,
1761 CHOOSE (5e-18L, 1e-15, 1e-7));
1767 static void
1768 tan_test (void)
1770 check ("tan (+0) == +0", FUNC(tan) (0), 0);
1771 check ("tan (-0) == -0", FUNC(tan) (minus_zero), minus_zero);
1772 check_isnan_exc ("tan (+inf) == NaN plus invalid exception",
1773 FUNC(tan) (plus_infty), INVALID_EXCEPTION);
1774 check_isnan_exc ("tan (-inf) == NaN plus invalid exception",
1775 FUNC(tan) (minus_infty), INVALID_EXCEPTION);
1777 check_eps ("tan (pi/4) == 1", FUNC(tan) (M_PI_4), 1,
1778 CHOOSE (2e-18L, 1e-15L, 0));
1782 static void
1783 tanh_test (void)
1785 check ("tanh (+0) == +0", FUNC(tanh) (0), 0);
1786 #ifndef TEST_INLINE
1787 check ("tanh (-0) == -0", FUNC(tanh) (minus_zero), minus_zero);
1789 check ("tanh (+inf) == +1", FUNC(tanh) (plus_infty), 1);
1790 check ("tanh (-inf) == -1", FUNC(tanh) (minus_infty), -1);
1791 #endif
1795 static void
1796 fabs_test (void)
1798 check ("fabs (+0) == +0", FUNC(fabs) (0), 0);
1799 check ("fabs (-0) == +0", FUNC(fabs) (minus_zero), 0);
1801 check_isinfp ("fabs (+inf) == +inf", FUNC(fabs) (plus_infty));
1802 check_isinfp ("fabs (-inf) == +inf", FUNC(fabs) (minus_infty));
1804 check ("fabs (+38) == 38", FUNC(fabs) (38.0), 38.0);
1805 check ("fabs (-e) == e", FUNC(fabs) (-M_E), M_E);
1809 static void
1810 floor_test (void)
1812 check ("floor (+0) == +0", FUNC(floor) (0.0), 0.0);
1813 check ("floor (-0) == -0", FUNC(floor) (minus_zero), minus_zero);
1814 check_isinfp ("floor (+inf) == +inf", FUNC(floor) (plus_infty));
1815 check_isinfn ("floor (-inf) == -inf", FUNC(floor) (minus_infty));
1817 check ("floor (pi) == 3", FUNC(floor) (M_PI), 3.0);
1818 check ("floor (-pi) == -4", FUNC(floor) (-M_PI), -4.0);
1822 static void
1823 hypot_test (void)
1825 MATHTYPE a;
1827 a = random_greater (0);
1828 check_isinfp_ext ("hypot (+inf, x) == +inf", FUNC(hypot) (plus_infty, a), a);
1829 check_isinfp_ext ("hypot (-inf, x) == +inf", FUNC(hypot) (minus_infty, a), a);
1831 #ifndef TEST_INLINE
1832 check_isinfp ("hypot (+inf, NaN) == +inf", FUNC(hypot) (minus_infty, nan_value));
1833 check_isinfp ("hypot (-inf, NaN) == +inf", FUNC(hypot) (minus_infty, nan_value));
1834 #endif
1836 check_isnan ("hypot (NaN, NaN) == NaN", FUNC(hypot) (nan_value, nan_value));
1838 a = FUNC(hypot) (12.4L, 0.7L);
1839 check ("hypot (x,y) == hypot (y,x)", FUNC(hypot) (0.7L, 12.4L), a);
1840 check ("hypot (x,y) == hypot (-x,y)", FUNC(hypot) (-12.4L, 0.7L), a);
1841 check ("hypot (x,y) == hypot (-y,x)", FUNC(hypot) (-0.7L, 12.4L), a);
1842 check ("hypot (x,y) == hypot (-x,-y)", FUNC(hypot) (-12.4L, -0.7L), a);
1843 check ("hypot (x,y) == hypot (-y,-x)", FUNC(hypot) (-0.7L, -12.4L), a);
1844 check ("hypot (x,0) == fabs (x)", FUNC(hypot) (-0.7L, 0), 0.7L);
1845 check ("hypot (x,0) == fabs (x)", FUNC(hypot) (0.7L, 0), 0.7L);
1846 check ("hypot (x,0) == fabs (x)", FUNC(hypot) (-1.0L, 0), 1.0L);
1847 check ("hypot (x,0) == fabs (x)", FUNC(hypot) (1.0L, 0), 1.0L);
1848 check ("hypot (x,0) == fabs (x)", FUNC(hypot) (-5.7e7L, 0), 5.7e7L);
1849 check ("hypot (x,0) == fabs (x)", FUNC(hypot) (5.7e7L, 0), 5.7e7L);
1853 static void
1854 pow_test (void)
1856 MATHTYPE x;
1858 check ("pow (+0, +0) == 1", FUNC(pow) (0, 0), 1);
1859 check ("pow (+0, -0) == 1", FUNC(pow) (0, minus_zero), 1);
1860 check ("pow (-0, +0) == 1", FUNC(pow) (minus_zero, 0), 1);
1861 check ("pow (-0, -0) == 1", FUNC(pow) (minus_zero, minus_zero), 1);
1863 check ("pow (+10, +0) == 1", FUNC(pow) (10, 0), 1);
1864 check ("pow (+10, -0) == 1", FUNC(pow) (10, minus_zero), 1);
1865 check ("pow (-10, +0) == 1", FUNC(pow) (-10, 0), 1);
1866 check ("pow (-10, -0) == 1", FUNC(pow) (-10, minus_zero), 1);
1868 check ("pow (NaN, +0) == 1", FUNC(pow) (nan_value, 0), 1);
1869 check ("pow (NaN, -0) == 1", FUNC(pow) (nan_value, minus_zero), 1);
1871 #ifndef TEST_INLINE
1872 check_isinfp ("pow (+1.1, +inf) == +inf", FUNC(pow) (1.1, plus_infty));
1873 check_isinfp ("pow (+inf, +inf) == +inf", FUNC(pow) (plus_infty, plus_infty));
1874 check_isinfp ("pow (-1.1, +inf) == +inf", FUNC(pow) (-1.1, plus_infty));
1875 check_isinfp ("pow (-inf, +inf) == +inf", FUNC(pow) (minus_infty, plus_infty));
1877 check ("pow (0.9, +inf) == +0", FUNC(pow) (0.9L, plus_infty), 0);
1878 check ("pow (1e-7, +inf) == +0", FUNC(pow) (1e-7L, plus_infty), 0);
1879 check ("pow (-0.9, +inf) == +0", FUNC(pow) (-0.9L, plus_infty), 0);
1880 check ("pow (-1e-7, +inf) == +0", FUNC(pow) (-1e-7L, plus_infty), 0);
1882 check ("pow (+1.1, -inf) == 0", FUNC(pow) (1.1, minus_infty), 0);
1883 check ("pow (+inf, -inf) == 0", FUNC(pow) (plus_infty, minus_infty), 0);
1884 check ("pow (-1.1, -inf) == 0", FUNC(pow) (-1.1, minus_infty), 0);
1885 check ("pow (-inf, -inf) == 0", FUNC(pow) (minus_infty, minus_infty), 0);
1887 check_isinfp ("pow (0.9, -inf) == +inf", FUNC(pow) (0.9L, minus_infty));
1888 check_isinfp ("pow (1e-7, -inf) == +inf", FUNC(pow) (1e-7L, minus_infty));
1889 check_isinfp ("pow (-0.9, -inf) == +inf", FUNC(pow) (-0.9L, minus_infty));
1890 check_isinfp ("pow (-1e-7, -inf) == +inf", FUNC(pow) (-1e-7L, minus_infty));
1892 check_isinfp ("pow (+inf, 1e-7) == +inf", FUNC(pow) (plus_infty, 1e-7L));
1893 check_isinfp ("pow (+inf, 1) == +inf", FUNC(pow) (plus_infty, 1));
1894 check_isinfp ("pow (+inf, 1e7) == +inf", FUNC(pow) (plus_infty, 1e7L));
1896 check ("pow (+inf, -1e-7) == 0", FUNC(pow) (plus_infty, -1e-7L), 0);
1897 check ("pow (+inf, -1) == 0", FUNC(pow) (plus_infty, -1), 0);
1898 check ("pow (+inf, -1e7) == 0", FUNC(pow) (plus_infty, -1e7L), 0);
1900 check_isinfn ("pow (-inf, 1) == -inf", FUNC(pow) (minus_infty, 1));
1901 check_isinfn ("pow (-inf, 11) == -inf", FUNC(pow) (minus_infty, 11));
1902 check_isinfn ("pow (-inf, 1001) == -inf", FUNC(pow) (minus_infty, 1001));
1904 check_isinfp ("pow (-inf, 2) == +inf", FUNC(pow) (minus_infty, 2));
1905 check_isinfp ("pow (-inf, 12) == +inf", FUNC(pow) (minus_infty, 12));
1906 check_isinfp ("pow (-inf, 1002) == +inf", FUNC(pow) (minus_infty, 1002));
1907 check_isinfp ("pow (-inf, 0.1) == +inf", FUNC(pow) (minus_infty, 0.1));
1908 check_isinfp ("pow (-inf, 1.1) == +inf", FUNC(pow) (minus_infty, 1.1));
1909 check_isinfp ("pow (-inf, 11.1) == +inf", FUNC(pow) (minus_infty, 11.1));
1910 check_isinfp ("pow (-inf, 1001.1) == +inf", FUNC(pow) (minus_infty, 1001.1));
1912 check ("pow (-inf, -1) == -0", FUNC(pow) (minus_infty, -1), minus_zero);
1913 check ("pow (-inf, -11) == -0", FUNC(pow) (minus_infty, -11), minus_zero);
1914 check ("pow (-inf, -1001) == -0", FUNC(pow) (minus_infty, -1001), minus_zero);
1916 check ("pow (-inf, -2) == +0", FUNC(pow) (minus_infty, -2), 0);
1917 check ("pow (-inf, -12) == +0", FUNC(pow) (minus_infty, -12), 0);
1918 check ("pow (-inf, -1002) == +0", FUNC(pow) (minus_infty, -1002), 0);
1919 check ("pow (-inf, -0.1) == +0", FUNC(pow) (minus_infty, -0.1), 0);
1920 check ("pow (-inf, -1.1) == +0", FUNC(pow) (minus_infty, -1.1), 0);
1921 check ("pow (-inf, -11.1) == +0", FUNC(pow) (minus_infty, -11.1), 0);
1922 check ("pow (-inf, -1001.1) == +0", FUNC(pow) (minus_infty, -1001.1), 0);
1924 check_isnan ("pow (NaN, NaN) == NaN", FUNC(pow) (nan_value, nan_value));
1925 check_isnan ("pow (0, NaN) == NaN", FUNC(pow) (0, nan_value));
1926 check_isnan ("pow (1, NaN) == NaN", FUNC(pow) (1, nan_value));
1927 check_isnan ("pow (-1, NaN) == NaN", FUNC(pow) (-1, nan_value));
1928 check_isnan ("pow (NaN, 1) == NaN", FUNC(pow) (nan_value, 1));
1929 check_isnan ("pow (NaN, -1) == NaN", FUNC(pow) (nan_value, -1));
1931 x = random_greater (0.0);
1932 check_isnan_ext ("pow (x, NaN) == NaN", FUNC(pow) (x, nan_value), x);
1934 check_isnan_exc ("pow (+1, +inf) == NaN plus invalid exception",
1935 FUNC(pow) (1, plus_infty), INVALID_EXCEPTION);
1936 check_isnan_exc ("pow (-1, +inf) == NaN plus invalid exception",
1937 FUNC(pow) (-1, plus_infty), INVALID_EXCEPTION);
1938 check_isnan_exc ("pow (+1, -inf) == NaN plus invalid exception",
1939 FUNC(pow) (1, minus_infty), INVALID_EXCEPTION);
1940 check_isnan_exc ("pow (-1, -inf) == NaN plus invalid exception",
1941 FUNC(pow) (-1, minus_infty), INVALID_EXCEPTION);
1943 check_isnan_exc ("pow (-0.1, 1.1) == NaN plus invalid exception",
1944 FUNC(pow) (-0.1, 1.1), INVALID_EXCEPTION);
1945 check_isnan_exc ("pow (-0.1, -1.1) == NaN plus invalid exception",
1946 FUNC(pow) (-0.1, -1.1), INVALID_EXCEPTION);
1947 check_isnan_exc ("pow (-10.1, 1.1) == NaN plus invalid exception",
1948 FUNC(pow) (-10.1, 1.1), INVALID_EXCEPTION);
1949 check_isnan_exc ("pow (-10.1, -1.1) == NaN plus invalid exception",
1950 FUNC(pow) (-10.1, -1.1), INVALID_EXCEPTION);
1952 check_isinfp_exc ("pow (+0, -1) == +inf plus divide-by-zero exception",
1953 FUNC(pow) (0, -1), DIVIDE_BY_ZERO_EXCEPTION);
1954 check_isinfp_exc ("pow (+0, -11) == +inf plus divide-by-zero exception",
1955 FUNC(pow) (0, -11), DIVIDE_BY_ZERO_EXCEPTION);
1956 check_isinfn_exc ("pow (-0, -1) == -inf plus divide-by-zero exception",
1957 FUNC(pow) (minus_zero, -1), DIVIDE_BY_ZERO_EXCEPTION);
1958 check_isinfn_exc ("pow (-0, -11) == -inf plus divide-by-zero exception",
1959 FUNC(pow) (minus_zero, -11), DIVIDE_BY_ZERO_EXCEPTION);
1961 check_isinfp_exc ("pow (+0, -2) == +inf plus divide-by-zero exception",
1962 FUNC(pow) (0, -2), DIVIDE_BY_ZERO_EXCEPTION);
1963 check_isinfp_exc ("pow (+0, -11.1) == +inf plus divide-by-zero exception",
1964 FUNC(pow) (0, -11.1), DIVIDE_BY_ZERO_EXCEPTION);
1965 check_isinfp_exc ("pow (-0, -2) == +inf plus divide-by-zero exception",
1966 FUNC(pow) (minus_zero, -2), DIVIDE_BY_ZERO_EXCEPTION);
1967 check_isinfp_exc ("pow (-0, -11.1) == +inf plus divide-by-zero exception",
1968 FUNC(pow) (minus_zero, -11.1), DIVIDE_BY_ZERO_EXCEPTION);
1969 #endif
1971 check ("pow (+0, 1) == +0", FUNC(pow) (0, 1), 0);
1972 check ("pow (+0, 11) == +0", FUNC(pow) (0, 11), 0);
1973 #ifndef TEST_INLINE
1974 check ("pow (-0, 1) == -0", FUNC(pow) (minus_zero, 1), minus_zero);
1975 check ("pow (-0, 11) == -0", FUNC(pow) (minus_zero, 11), minus_zero);
1976 #endif
1978 check ("pow (+0, 2) == +0", FUNC(pow) (0, 2), 0);
1979 check ("pow (+0, 11.1) == +0", FUNC(pow) (0, 11.1), 0);
1981 #ifndef TEST_INLINE
1982 check ("pow (-0, 2) == +0", FUNC(pow) (minus_zero, 2), 0);
1983 check ("pow (-0, 11.1) == +0", FUNC(pow) (minus_zero, 11.1), 0);
1985 x = random_greater (1.0);
1986 check_isinfp_ext ("pow (x, +inf) == +inf for |x| > 1",
1987 FUNC(pow) (x, plus_infty), x);
1989 x = random_value (-1.0, 1.0);
1990 check_ext ("pow (x, +inf) == +0 for |x| < 1",
1991 FUNC(pow) (x, plus_infty), 0.0, x);
1993 x = random_greater (1.0);
1994 check_ext ("pow (x, -inf) == +0 for |x| > 1",
1995 FUNC(pow) (x, minus_infty), 0.0, x);
1997 x = random_value (-1.0, 1.0);
1998 check_isinfp_ext ("pow (x, -inf) == +inf for |x| < 1",
1999 FUNC(pow) (x, minus_infty), x);
2001 x = random_greater (0.0);
2002 check_isinfp_ext ("pow (+inf, y) == +inf for y > 0",
2003 FUNC(pow) (plus_infty, x), x);
2005 x = random_less (0.0);
2006 check_ext ("pow (+inf, y) == +0 for y < 0",
2007 FUNC(pow) (plus_infty, x), 0.0, x);
2009 x = (rand () % 1000000) * 2.0 + 1; /* Get random odd integer > 0 */
2010 check_isinfn_ext ("pow (-inf, y) == -inf for y an odd integer > 0",
2011 FUNC(pow) (minus_infty, x), x);
2013 x = ((rand () % 1000000) + 1) * 2.0; /* Get random even integer > 1 */
2014 check_isinfp_ext ("pow (-inf, y) == +inf for y > 0 and not an odd integer",
2015 FUNC(pow) (minus_infty, x), x);
2017 x = -((rand () % 1000000) * 2.0 + 1); /* Get random odd integer < 0 */
2018 check_ext ("pow (-inf, y) == -0 for y an odd integer < 0",
2019 FUNC(pow) (minus_infty, x), minus_zero, x);
2021 x = ((rand () % 1000000) + 1) * -2.0; /* Get random even integer < 0 */
2022 check_ext ("pow (-inf, y) == +0 for y < 0 and not an odd integer",
2023 FUNC(pow) (minus_infty, x), 0.0, x);
2024 #endif
2026 x = (rand () % 1000000) * 2.0 + 1; /* Get random odd integer > 0 */
2027 check_ext ("pow (+0, y) == +0 for y an odd integer > 0",
2028 FUNC(pow) (0.0, x), 0.0, x);
2029 #ifndef TEST_INLINE
2030 x = (rand () % 1000000) * 2.0 + 1; /* Get random odd integer > 0 */
2031 check_ext ("pow (-0, y) == -0 for y an odd integer > 0",
2032 FUNC(pow) (minus_zero, x), minus_zero, x);
2033 #endif
2035 x = ((rand () % 1000000) + 1) * 2.0; /* Get random even integer > 1 */
2036 check_ext ("pow (+0, y) == +0 for y > 0 and not an odd integer",
2037 FUNC(pow) (0.0, x), 0.0, x);
2039 x = ((rand () % 1000000) + 1) * 2.0; /* Get random even integer > 1 */
2040 check_ext ("pow (-0, y) == +0 for y > 0 and not an odd integer",
2041 FUNC(pow) (minus_zero, x), 0.0, x);
2045 static void
2046 fdim_test (void)
2048 check ("fdim (+0, +0) = +0", FUNC(fdim) (0, 0), 0);
2049 check ("fdim (9, 0) = 9", FUNC(fdim) (9, 0), 9);
2050 check ("fdim (0, 9) = 0", FUNC(fdim) (0, 9), 0);
2051 check ("fdim (-9, 0) = 9", FUNC(fdim) (-9, 0), 0);
2052 check ("fdim (0, -9) = 9", FUNC(fdim) (0, -9), 9);
2054 check_isinfp ("fdim (+inf, 9) = +inf", FUNC(fdim) (plus_infty, 9));
2055 check_isinfp ("fdim (+inf, -9) = +inf", FUNC(fdim) (plus_infty, -9));
2056 check ("fdim (-inf, 9) = 0", FUNC(fdim) (minus_infty, 9), 0);
2057 check ("fdim (-inf, -9) = 0", FUNC(fdim) (minus_infty, -9), 0);
2058 check_isinfp ("fdim (+9, -inf) = +inf", FUNC(fdim) (9, minus_infty));
2059 check_isinfp ("fdim (-9, -inf) = +inf", FUNC(fdim) (-9, minus_infty));
2060 check ("fdim (9, inf) = 0", FUNC(fdim) (9, plus_infty), 0);
2061 check ("fdim (-9, inf) = 0", FUNC(fdim) (-9, plus_infty), 0);
2063 check_isnan ("fdim (0, NaN) = NaN", FUNC(fdim) (0, nan_value));
2064 check_isnan ("fdim (9, NaN) = NaN", FUNC(fdim) (9, nan_value));
2065 check_isnan ("fdim (-9, NaN) = NaN", FUNC(fdim) (-9, nan_value));
2066 check_isnan ("fdim (NaN, 9) = NaN", FUNC(fdim) (nan_value, 9));
2067 check_isnan ("fdim (NaN, -9) = NaN", FUNC(fdim) (nan_value, -9));
2068 check_isnan ("fdim (+inf, NaN) = NaN", FUNC(fdim) (plus_infty, nan_value));
2069 check_isnan ("fdim (-inf, NaN) = NaN", FUNC(fdim) (minus_infty, nan_value));
2070 check_isnan ("fdim (NaN, +inf) = NaN", FUNC(fdim) (nan_value, plus_infty));
2071 check_isnan ("fdim (NaN, -inf) = NaN", FUNC(fdim) (nan_value, minus_infty));
2072 check_isnan ("fdim (NaN, NaN) = NaN", FUNC(fdim) (nan_value, nan_value));
2076 static void
2077 fmin_test (void)
2079 check ("fmin (+0, +0) = +0", FUNC(fmin) (0, 0), 0);
2080 check ("fmin (9, 0) = 0", FUNC(fmin) (9, 0), 0);
2081 check ("fmin (0, 9) = 0", FUNC(fmin) (0, 9), 0);
2082 check ("fmin (-9, 0) = -9", FUNC(fmin) (-9, 0), -9);
2083 check ("fmin (0, -9) = -9", FUNC(fmin) (0, -9), -9);
2085 check ("fmin (+inf, 9) = 9", FUNC(fmin) (plus_infty, 9), 9);
2086 check ("fmin (9, +inf) = 9", FUNC(fmin) (9, plus_infty), 9);
2087 check ("fmin (+inf, -9) = -9", FUNC(fmin) (plus_infty, -9), -9);
2088 check ("fmin (-9, +inf) = -9", FUNC(fmin) (-9, plus_infty), -9);
2089 check_isinfn ("fmin (-inf, 9) = -inf", FUNC(fmin) (minus_infty, 9));
2090 check_isinfn ("fmin (-inf, -9) = -inf", FUNC(fmin) (minus_infty, -9));
2091 check_isinfn ("fmin (+9, -inf) = -inf", FUNC(fmin) (9, minus_infty));
2092 check_isinfn ("fmin (-9, -inf) = -inf", FUNC(fmin) (-9, minus_infty));
2094 check ("fmin (0, NaN) = 0", FUNC(fmin) (0, nan_value), 0);
2095 check ("fmin (9, NaN) = 9", FUNC(fmin) (9, nan_value), 9);
2096 check ("fmin (-9, NaN) = 9", FUNC(fmin) (-9, nan_value), -9);
2097 check ("fmin (NaN, 0) = 0", FUNC(fmin) (nan_value, 0), 0);
2098 check ("fmin (NaN, 9) = NaN", FUNC(fmin) (nan_value, 9), 9);
2099 check ("fmin (NaN, -9) = NaN", FUNC(fmin) (nan_value, -9), -9);
2100 check_isinfp ("fmin (+inf, NaN) = +inf", FUNC(fmin) (plus_infty, nan_value));
2101 check_isinfn ("fmin (-inf, NaN) = -inf", FUNC(fmin) (minus_infty, nan_value));
2102 check_isinfp ("fmin (NaN, +inf) = +inf", FUNC(fmin) (nan_value, plus_infty));
2103 check_isinfn ("fmin (NaN, -inf) = -inf", FUNC(fmin) (nan_value, minus_infty));
2104 check_isnan ("fmin (NaN, NaN) = NaN", FUNC(fmin) (nan_value, nan_value));
2108 static void
2109 fmax_test (void)
2111 check ("fmax (+0, +0) = +0", FUNC(fmax) (0, 0), 0);
2112 check ("fmax (9, 0) = 9", FUNC(fmax) (9, 0), 9);
2113 check ("fmax (0, 9) = 9", FUNC(fmax) (0, 9), 9);
2114 check ("fmax (-9, 0) = 0", FUNC(fmax) (-9, 0), 0);
2115 check ("fmax (0, -9) = 0", FUNC(fmax) (0, -9), 0);
2117 check_isinfp ("fmax (+inf, 9) = +inf", FUNC(fmax) (plus_infty, 9));
2118 check_isinfp ("fmax (9, +inf) = +inf", FUNC(fmax) (0, plus_infty));
2119 check_isinfp ("fmax (-9, +inf) = +inf", FUNC(fmax) (-9, plus_infty));
2120 check_isinfp ("fmax (+inf, -9) = +inf", FUNC(fmax) (plus_infty, -9));
2121 check ("fmax (-inf, 9) = 9", FUNC(fmax) (minus_infty, 9), 9);
2122 check ("fmax (-inf, -9) = -9", FUNC(fmax) (minus_infty, -9), -9);
2123 check ("fmax (+9, -inf) = 9", FUNC(fmax) (9, minus_infty), 9);
2124 check ("fmax (-9, -inf) = -9", FUNC(fmax) (-9, minus_infty), -9);
2126 check ("fmax (0, NaN) = 0", FUNC(fmax) (0, nan_value), 0);
2127 check ("fmax (9, NaN) = 9", FUNC(fmax) (9, nan_value), 9);
2128 check ("fmax (-9, NaN) = 9", FUNC(fmax) (-9, nan_value), -9);
2129 check ("fmax (NaN, 0) = 0", FUNC(fmax) (nan_value, 0), 0);
2130 check ("fmax (NaN, 9) = NaN", FUNC(fmax) (nan_value, 9), 9);
2131 check ("fmax (NaN, -9) = NaN", FUNC(fmax) (nan_value, -9), -9);
2132 check_isinfp ("fmax (+inf, NaN) = +inf", FUNC(fmax) (plus_infty, nan_value));
2133 check_isinfn ("fmax (-inf, NaN) = -inf", FUNC(fmax) (minus_infty, nan_value));
2134 check_isinfp ("fmax (NaN, +inf) = +inf", FUNC(fmax) (nan_value, plus_infty));
2135 check_isinfn ("fmax (NaN, -inf) = -inf", FUNC(fmax) (nan_value, minus_infty));
2136 check_isnan ("fmax (NaN, NaN) = NaN", FUNC(fmax) (nan_value, nan_value));
2140 static void
2141 fmod_test (void)
2143 MATHTYPE x;
2145 x = random_greater (0);
2146 check_ext ("fmod (+0, y) == +0 for y != 0", FUNC(fmod) (0, x), 0, x);
2148 x = random_greater (0);
2149 check_ext ("fmod (-0, y) == -0 for y != 0", FUNC(fmod) (minus_zero, x),
2150 minus_zero, x);
2152 check_isnan_exc_ext ("fmod (+inf, y) == NaN plus invalid exception",
2153 FUNC(fmod) (plus_infty, x), INVALID_EXCEPTION, x);
2154 check_isnan_exc_ext ("fmod (-inf, y) == NaN plus invalid exception",
2155 FUNC(fmod) (minus_infty, x), INVALID_EXCEPTION, x);
2156 check_isnan_exc_ext ("fmod (x, +0) == NaN plus invalid exception",
2157 FUNC(fmod) (x, 0), INVALID_EXCEPTION, x);
2158 check_isnan_exc_ext ("fmod (x, -0) == NaN plus invalid exception",
2159 FUNC(fmod) (x, minus_zero), INVALID_EXCEPTION, x);
2161 x = random_greater (0);
2162 check_ext ("fmod (x, +inf) == x for x not infinite",
2163 FUNC(fmod) (x, plus_infty), x, x);
2164 x = random_greater (0);
2165 check_ext ("fmod (x, -inf) == x for x not infinite",
2166 FUNC(fmod) (x, minus_infty), x, x);
2168 check_eps ("fmod (6.5, 2.3) == 1.9", FUNC(fmod) (6.5, 2.3), 1.9,
2169 CHOOSE(5e-16, 1e-15, 2e-7));
2170 check_eps ("fmod (-6.5, 2.3) == -1.9", FUNC(fmod) (-6.5, 2.3), -1.9,
2171 CHOOSE(5e-16, 1e-15, 2e-7));
2172 check_eps ("fmod (6.5, -2.3) == 1.9", FUNC(fmod) (6.5, -2.3), 1.9,
2173 CHOOSE(5e-16, 1e-15, 2e-7));
2174 check_eps ("fmod (-6.5, -2.3) == -1.9", FUNC(fmod) (-6.5, -2.3), -1.9,
2175 CHOOSE(5e-16, 1e-15, 2e-7));
2181 static void
2182 nextafter_test (void)
2184 MATHTYPE x;
2186 check ("nextafter (+0, +0) = +0", FUNC(nextafter) (0, 0), 0);
2187 check ("nextafter (-0, +0) = +0", FUNC(nextafter) (minus_zero, 0), 0);
2188 check ("nextafter (+0, -0) = -0", FUNC(nextafter) (0, minus_zero),
2189 minus_zero);
2190 check ("nextafter (-0, -0) = -0", FUNC(nextafter) (minus_zero, minus_zero),
2191 minus_zero);
2193 check ("nextafter (9, 9) = 9", FUNC(nextafter) (9, 9), 9);
2194 check ("nextafter (-9, -9) = -9", FUNC(nextafter) (-9, -9), -9);
2195 check_isinfp ("nextafter (+inf, +inf) = +inf",
2196 FUNC(nextafter) (plus_infty, plus_infty));
2197 check_isinfn ("nextafter (-inf, -inf) = -inf",
2198 FUNC(nextafter) (minus_infty, minus_infty));
2200 x = rand () * 1.1;
2201 check_isnan ("nextafter (NaN, x) = NaN", FUNC(nextafter) (nan_value, x));
2202 check_isnan ("nextafter (x, NaN) = NaN", FUNC(nextafter) (x, nan_value));
2203 check_isnan ("nextafter (NaN, NaN) = NaN", FUNC(nextafter) (nan_value,
2204 nan_value));
2206 /* XXX We need the hexadecimal FP number representation here for further
2207 tests. */
2211 static void
2212 copysign_test (void)
2214 check ("copysign (0, 4) = 0", FUNC(copysign) (0, 4), 0);
2215 check ("copysign (0, -4) = -0", FUNC(copysign) (0, -4), minus_zero);
2216 check ("copysign (-0, 4) = 0", FUNC(copysign) (minus_zero, 4), 0);
2217 check ("copysign (-0, -4) = -0", FUNC(copysign) (minus_zero, -4),
2218 minus_zero);
2220 check_isinfp ("copysign (+inf, 0) = +inf", FUNC(copysign) (plus_infty, 0));
2221 check_isinfn ("copysign (+inf, -0) = -inf", FUNC(copysign) (plus_infty,
2222 minus_zero));
2223 check_isinfp ("copysign (-inf, 0) = +inf", FUNC(copysign) (minus_infty, 0));
2224 check_isinfn ("copysign (-inf, -0) = -inf", FUNC(copysign) (minus_infty,
2225 minus_zero));
2227 check ("copysign (0, +inf) = 0", FUNC(copysign) (0, plus_infty), 0);
2228 check ("copysign (0, -inf) = -0", FUNC(copysign) (0, minus_zero),
2229 minus_zero);
2230 check ("copysign (-0, +inf) = 0", FUNC(copysign) (minus_zero, plus_infty),
2232 check ("copysign (-0, -inf) = -0", FUNC(copysign) (minus_zero, minus_zero),
2233 minus_zero);
2235 /* XXX More correctly we would have to check the sign of the NaN. */
2236 check_isnan ("copysign (+NaN, 0) = +NaN", FUNC(copysign) (nan_value, 0));
2237 check_isnan ("copysign (+NaN, -0) = -NaN", FUNC(copysign) (nan_value,
2238 minus_zero));
2239 check_isnan ("copysign (-NaN, 0) = +NaN", FUNC(copysign) (-nan_value, 0));
2240 check_isnan ("copysign (-NaN, -0) = -NaN", FUNC(copysign) (-nan_value,
2241 minus_zero));
2245 static void
2246 trunc_test (void)
2248 check ("trunc(0) = 0", FUNC(trunc) (0), 0);
2249 check ("trunc(-0) = -0", FUNC(trunc) (minus_zero), minus_zero);
2250 check ("trunc(0.625) = 0", FUNC(trunc) (0.625), 0);
2251 check ("trunc(-0.625) = -0", FUNC(trunc) (-0.625), minus_zero);
2252 check ("trunc(1) = 1", FUNC(trunc) (1), 1);
2253 check ("trunc(-1) = -1", FUNC(trunc) (-1), -1);
2254 check ("trunc(1.625) = 1", FUNC(trunc) (1.625), 1);
2255 check ("trunc(-1.625) = -1", FUNC(trunc) (-1.625), -1);
2257 check ("trunc(1048580.625) = 1048580", FUNC(trunc) (1048580.625L),
2258 1048580L);
2259 check ("trunc(-1048580.625) = -1048580", FUNC(trunc) (-1048580.625L),
2260 -1048580L);
2262 check ("trunc(8388610.125) = 8388610", FUNC(trunc) (8388610.125L),
2263 8388610.0L);
2264 check ("trunc(-8388610.125) = -8388610", FUNC(trunc) (-8388610.125L),
2265 -8388610.0L);
2267 check ("trunc(4294967296.625) = 4294967296", FUNC(trunc) (4294967296.625L),
2268 4294967296.0L);
2269 check ("trunc(-4294967296.625) = -4294967296",
2270 FUNC(trunc) (-4294967296.625L), -4294967296.0L);
2272 check_isinfp ("trunc(+inf) = +inf", FUNC(trunc) (plus_infty));
2273 check_isinfn ("trunc(-inf) = -inf", FUNC(trunc) (minus_infty));
2274 check_isnan ("trunc(NaN) = NaN", FUNC(trunc) (nan_value));
2278 static void
2279 sqrt_test (void)
2281 MATHTYPE x;
2284 /* XXX Tests fuer negative x are missing */
2285 check ("sqrt (0) == 0", FUNC(sqrt) (0), 0);
2286 check_isnan ("sqrt (NaN) == NaN", FUNC(sqrt) (nan_value));
2287 check_isinfp ("sqrt (+inf) == +inf", FUNC(sqrt) (plus_infty));
2289 check ("sqrt (-0) == -0", FUNC(sqrt) (0), 0);
2291 x = random_less (0.0);
2292 check_isnan_exc_ext ("sqrt (x) == NaN plus invalid exception for x < 0",
2293 FUNC(sqrt) (x), INVALID_EXCEPTION, x);
2295 x = random_value (0, 10000);
2296 check_ext ("sqrt (x*x) == x", FUNC(sqrt) (x*x), x, x);
2297 check ("sqrt (4) == 2", FUNC(sqrt) (4), 2);
2301 static void
2302 remainder_test (void)
2304 MATHTYPE result;
2306 result = FUNC(remainder) (1, 0);
2307 check_isnan_exc ("remainder(1, +0) == NaN plus invalid exception",
2308 result, INVALID_EXCEPTION);
2310 result = FUNC(remainder) (1, minus_zero);
2311 check_isnan_exc ("remainder(1, -0) == NaN plus invalid exception",
2312 result, INVALID_EXCEPTION);
2314 result = FUNC(remainder) (plus_infty, 1);
2315 check_isnan_exc ("remainder(+inf, 1) == NaN plus invalid exception",
2316 result, INVALID_EXCEPTION);
2318 result = FUNC(remainder) (minus_infty, 1);
2319 check_isnan_exc ("remainder(-inf, 1) == NaN plus invalid exception",
2320 result, INVALID_EXCEPTION);
2322 result = FUNC(remainder) (1.625, 1.0);
2323 check ("remainder(1.625, 1.0) == -0.375", result, -0.375);
2325 result = FUNC(remainder) (-1.625, 1.0);
2326 check ("remainder(-1.625, 1.0) == 0.375", result, 0.375);
2328 result = FUNC(remainder) (1.625, -1.0);
2329 check ("remainder(1.625, -1.0) == -0.375", result, -0.375);
2331 result = FUNC(remainder) (-1.625, -1.0);
2332 check ("remainder(-1.625, -1.0) == 0.375", result, 0.375);
2334 result = FUNC(remainder) (5.0, 2.0);
2335 check ("remainder(5.0, 2.0) == 1.0", result, 1.0);
2337 result = FUNC(remainder) (3.0, 2.0);
2338 check ("remainder(3.0, 2.0) == -1.0", result, -1.0);
2342 static void
2343 remquo_test (void)
2345 int quo;
2346 MATHTYPE result;
2348 result = FUNC(remquo) (1, 0, &quo);
2349 check_isnan_exc ("remquo(1, +0, &x) == NaN plus invalid exception",
2350 result, INVALID_EXCEPTION);
2352 result = FUNC(remquo) (1, minus_zero, &quo);
2353 check_isnan_exc ("remquo(1, -0, &x) == NaN plus invalid exception",
2354 result, INVALID_EXCEPTION);
2356 result = FUNC(remquo) (plus_infty, 1, &quo);
2357 check_isnan_exc ("remquo(+inf, 1, &x) == NaN plus invalid exception",
2358 result, INVALID_EXCEPTION);
2360 result = FUNC(remquo) (minus_infty, 1, &quo);
2361 check_isnan_exc ("remquo(-inf, 1, &x) == NaN plus invalid exception",
2362 result, INVALID_EXCEPTION);
2364 result = FUNC(remquo) (1.625, 1.0, &quo);
2365 check ("remquo(1.625, 1.0, &x) == -0.375", result, -0.375);
2366 check_long ("remquo(1.625, 1.0, &x) puts 2 in x", quo, 2);
2368 result = FUNC(remquo) (-1.625, 1.0, &quo);
2369 check ("remquo(-1.625, 1.0, &x) == 0.375", result, 0.375);
2370 check_long ("remquo(-1.625, 1.0, &x) puts -2 in x", quo, -2);
2372 result = FUNC(remquo) (1.625, -1.0, &quo);
2373 check ("remquo(1.625, -1.0, &x) == -0.375", result, -0.375);
2374 check_long ("remquo(1.625, -1.0, &x) puts -2 in x", quo, -2);
2376 result = FUNC(remquo) (-1.625, -1.0, &quo);
2377 check ("remquo(-1.625, -1.0, &x) == 0.375", result, 0.375);
2378 check_long ("remquo(-1.625, -1.0, &x) puts 2 in x", quo, 2);
2380 result = FUNC(remquo) (5.0, 2.0, &quo);
2381 check ("remquo(5.0, 2.0, &x) == 1.0", result, 1.0);
2382 check_long ("remquo (5.0, 2.0, &x) puts 2 in x", quo, 2);
2384 result = FUNC(remquo) (3.0, 2.0, &quo);
2385 check ("remquo(3.0, 2.0, &x) == -1.0", result, -1.0);
2386 check_long ("remquo (3.0, 2.0, &x) puts 2 in x", quo, 2);
2390 static void
2391 cexp_test (void)
2393 __complex__ MATHTYPE result;
2395 result = FUNC(cexp) (BUILD_COMPLEX (plus_zero, plus_zero));
2396 check ("real(cexp(0 + 0i)) = 1", __real__ result, 1);
2397 check ("imag(cexp(0 + 0i)) = 0", __imag__ result, 0);
2398 result = FUNC(cexp) (BUILD_COMPLEX (minus_zero, plus_zero));
2399 check ("real(cexp(-0 + 0i)) = 1", __real__ result, 1);
2400 check ("imag(cexp(-0 + 0i)) = 0", __imag__ result, 0);
2401 result = FUNC(cexp) (BUILD_COMPLEX (plus_zero, minus_zero));
2402 check ("real(cexp(0 - 0i)) = 1", __real__ result, 1);
2403 check ("imag(cexp(0 - 0i)) = -0", __imag__ result, minus_zero);
2404 result = FUNC(cexp) (BUILD_COMPLEX (minus_zero, minus_zero));
2405 check ("real(cexp(-0 - 0i)) = 1", __real__ result, 1);
2406 check ("imag(cexp(-0 - 0i)) = -0", __imag__ result, minus_zero);
2408 result = FUNC(cexp) (BUILD_COMPLEX (plus_infty, plus_zero));
2409 check_isinfp ("real(cexp(+inf + 0i)) = +inf", __real__ result);
2410 check ("imag(cexp(+inf + 0i)) = 0", __imag__ result, 0);
2411 result = FUNC(cexp) (BUILD_COMPLEX (plus_infty, minus_zero));
2412 check_isinfp ("real(cexp(+inf - 0i)) = +inf", __real__ result);
2413 check ("imag(cexp(+inf - 0i)) = -0", __imag__ result, minus_zero);
2415 result = FUNC(cexp) (BUILD_COMPLEX (minus_infty, plus_zero));
2416 check ("real(cexp(-inf + 0i)) = 0", __real__ result, 0);
2417 check ("imag(cexp(-inf + 0i)) = 0", __imag__ result, 0);
2418 result = FUNC(cexp) (BUILD_COMPLEX (minus_infty, minus_zero));
2419 check ("real(cexp(-inf - 0i)) = 0", __real__ result, 0);
2420 check ("imag(cexp(-inf - 0i)) = -0", __imag__ result, minus_zero);
2423 result = FUNC(cexp) (BUILD_COMPLEX (0.0, plus_infty));
2424 check_isnan_exc ("real(cexp(0 + i inf)) = NaN plus invalid exception",
2425 __real__ result, INVALID_EXCEPTION);
2426 check_isnan ("imag(cexp(0 + i inf)) = NaN plus invalid exception",
2427 __imag__ result);
2429 #if defined __GNUC__ && __GNUC__ <= 2 && __GNUC_MINOR <= 7
2430 if (verbose)
2431 printf ("The following test for cexp might fail due to a gcc compiler error!\n");
2432 #endif
2434 result = FUNC(cexp) (BUILD_COMPLEX (minus_zero, plus_infty));
2435 check_isnan_exc ("real(cexp(-0 + i inf)) = NaN plus invalid exception",
2436 __real__ result, INVALID_EXCEPTION);
2437 check_isnan ("imag(cexp(-0 + i inf)) = NaN plus invalid exception",
2438 __imag__ result);
2439 result = FUNC(cexp) (BUILD_COMPLEX (0.0, minus_infty));
2440 check_isnan_exc ("real(cexp(0 - i inf)) = NaN plus invalid exception",
2441 __real__ result, INVALID_EXCEPTION);
2442 check_isnan ("imag(cexp(0 - i inf)) = NaN plus invalid exception",
2443 __imag__ result);
2444 result = FUNC(cexp) (BUILD_COMPLEX (minus_zero, minus_infty));
2445 check_isnan_exc ("real(cexp(-0 - i inf)) = NaN plus invalid exception",
2446 __real__ result, INVALID_EXCEPTION);
2447 check_isnan ("imag(cexp(-0 - i inf)) = NaN plus invalid exception",
2448 __imag__ result);
2450 result = FUNC(cexp) (BUILD_COMPLEX (100.0, plus_infty));
2451 check_isnan_exc ("real(cexp(100.0 + i inf)) = NaN plus invalid exception",
2452 __real__ result, INVALID_EXCEPTION);
2453 check_isnan ("imag(cexp(100.0 + i inf)) = NaN plus invalid exception",
2454 __imag__ result);
2455 result = FUNC(cexp) (BUILD_COMPLEX (-100.0, plus_infty));
2456 check_isnan_exc ("real(cexp(-100.0 + i inf)) = NaN plus invalid exception",
2457 __real__ result, INVALID_EXCEPTION);
2458 check_isnan ("imag(cexp(-100.0 + i inf)) = NaN plus invalid exception",
2459 __imag__ result);
2460 result = FUNC(cexp) (BUILD_COMPLEX (100.0, minus_infty));
2461 check_isnan_exc ("real(cexp(100.0 - i inf)) = NaN plus invalid exception",
2462 __real__ result, INVALID_EXCEPTION);
2463 check_isnan ("imag(cexp(100.0 - i inf)) = NaN plus invalid exception",
2464 __imag__ result);
2465 result = FUNC(cexp) (BUILD_COMPLEX (-100.0, minus_infty));
2466 check_isnan_exc ("real(cexp(-100.0 - i inf)) = NaN plus invalid exception",
2467 __real__ result, INVALID_EXCEPTION);
2468 check_isnan ("imag(cexp(-100.0 - i inf)) = NaN", __imag__ result);
2470 result = FUNC(cexp) (BUILD_COMPLEX (minus_infty, 2.0));
2471 check ("real(cexp(-inf + 2.0i)) = -0", __real__ result, minus_zero);
2472 check ("imag(cexp(-inf + 2.0i)) = 0", __imag__ result, 0);
2473 result = FUNC(cexp) (BUILD_COMPLEX (minus_infty, 4.0));
2474 check ("real(cexp(-inf + 4.0i)) = -0", __real__ result, minus_zero);
2475 check ("imag(cexp(-inf + 4.0i)) = -0", __imag__ result, minus_zero);
2477 result = FUNC(cexp) (BUILD_COMPLEX (plus_infty, 2.0));
2478 check_isinfn ("real(cexp(+inf + 2.0i)) = -inf", __real__ result);
2479 check_isinfp ("imag(cexp(+inf + 2.0i)) = +inf", __imag__ result);
2480 result = FUNC(cexp) (BUILD_COMPLEX (plus_infty, 4.0));
2481 check_isinfn ("real(cexp(+inf + 4.0i)) = -inf", __real__ result);
2482 check_isinfn ("imag(cexp(+inf + 4.0i)) = -inf", __imag__ result);
2484 result = FUNC(cexp) (BUILD_COMPLEX (plus_infty, plus_infty));
2485 check_isinfp_exc ("real(cexp(+inf + i inf)) = +inf plus invalid exception",
2486 __real__ result, INVALID_EXCEPTION);
2487 check_isnan ("imag(cexp(+inf + i inf)) = NaN plus invalid exception",
2488 __imag__ result);
2489 result = FUNC(cexp) (BUILD_COMPLEX (plus_infty, minus_infty));
2490 check_isinfp_exc ("real(cexp(+inf - i inf)) = +inf plus invalid exception",
2491 __real__ result, INVALID_EXCEPTION);
2492 check_isnan ("imag(cexp(+inf - i inf)) = NaN plus invalid exception",
2493 __imag__ result);
2495 result = FUNC(cexp) (BUILD_COMPLEX (minus_infty, plus_infty));
2496 check ("real(cexp(-inf + i inf)) = 0", __real__ result, 0);
2497 check ("imag(cexp(-inf + i inf)) = 0", __imag__ result, 0);
2498 result = FUNC(cexp) (BUILD_COMPLEX (minus_infty, minus_infty));
2499 check ("real(cexp(-inf - i inf)) = 0", __real__ result, 0);
2500 check ("imag(cexp(-inf - i inf)) = -0", __imag__ result, minus_zero);
2502 result = FUNC(cexp) (BUILD_COMPLEX (minus_infty, nan_value));
2503 check ("real(cexp(-inf + i NaN)) = 0", __real__ result, 0);
2504 check ("imag(cexp(-inf + i NaN)) = 0", fabs (__imag__ result), 0);
2506 result = FUNC(cexp) (BUILD_COMPLEX (plus_infty, nan_value));
2507 check_isinfp ("real(cexp(+inf + i NaN)) = +inf", __real__ result);
2508 check_isnan ("imag(cexp(+inf + i NaN)) = NaN", __imag__ result);
2510 result = FUNC(cexp) (BUILD_COMPLEX (nan_value, 0.0));
2511 check_isnan_maybe_exc ("real(cexp(NaN + i0)) = NaN plus maybe invalid exception",
2512 __real__ result, INVALID_EXCEPTION);
2513 check_isnan ("imag(cexp(NaN + i0)) = NaN plus maybe invalid exception",
2514 __imag__ result);
2515 result = FUNC(cexp) (BUILD_COMPLEX (nan_value, 1.0));
2516 check_isnan_maybe_exc ("real(cexp(NaN + 1i)) = NaN plus maybe invalid exception",
2517 __real__ result, INVALID_EXCEPTION);
2518 check_isnan ("imag(cexp(NaN + 1i)) = NaN plus maybe invalid exception",
2519 __imag__ result);
2520 result = FUNC(cexp) (BUILD_COMPLEX (nan_value, plus_infty));
2521 check_isnan_maybe_exc ("real(cexp(NaN + i inf)) = NaN plus maybe invalid exception",
2522 __real__ result, INVALID_EXCEPTION);
2523 check_isnan ("imag(cexp(NaN + i inf)) = NaN plus maybe invalid exception",
2524 __imag__ result);
2526 result = FUNC(cexp) (BUILD_COMPLEX (0, nan_value));
2527 check_isnan_maybe_exc ("real(cexp(0 + i NaN)) = NaN plus maybe invalid exception",
2528 __real__ result, INVALID_EXCEPTION);
2529 check_isnan ("imag(cexp(0 + i NaN)) = NaN plus maybe invalid exception",
2530 __imag__ result);
2531 result = FUNC(cexp) (BUILD_COMPLEX (1, nan_value));
2532 check_isnan_maybe_exc ("real(cexp(1 + i NaN)) = NaN plus maybe invalid exception",
2533 __real__ result, INVALID_EXCEPTION);
2534 check_isnan ("imag(cexp(1 + i NaN)) = NaN plus maybe invalid exception",
2535 __imag__ result);
2537 result = FUNC(cexp) (BUILD_COMPLEX (nan_value, nan_value));
2538 check_isnan ("real(cexp(NaN + i NaN)) = NaN", __real__ result);
2539 check_isnan ("imag(cexp(NaN + i NaN)) = NaN", __imag__ result);
2543 static void
2544 csin_test (void)
2546 __complex__ MATHTYPE result;
2548 result = FUNC(csin) (BUILD_COMPLEX (0.0, 0.0));
2549 check ("real(csin(0 + 0i)) = 0", __real__ result, 0);
2550 check ("imag(csin(0 + 0i)) = 0", __imag__ result, 0);
2551 result = FUNC(csin) (BUILD_COMPLEX (minus_zero, 0.0));
2552 check ("real(csin(-0 + 0i)) = -0", __real__ result, minus_zero);
2553 check ("imag(csin(-0 + 0i)) = 0", __imag__ result, 0);
2554 result = FUNC(csin) (BUILD_COMPLEX (0.0, minus_zero));
2555 check ("real(csin(0 - 0i)) = 0", __real__ result, 0);
2556 check ("imag(csin(0 - 0i)) = -0", __imag__ result, minus_zero);
2557 result = FUNC(csin) (BUILD_COMPLEX (minus_zero, minus_zero));
2558 check ("real(csin(-0 - 0i)) = -0", __real__ result, minus_zero);
2559 check ("imag(csin(-0 - 0i)) = -0", __imag__ result, minus_zero);
2561 result = FUNC(csin) (BUILD_COMPLEX (0.0, plus_infty));
2562 check ("real(csin(0 + i Inf)) = 0", __real__ result, 0);
2563 check_isinfp ("imag(csin(0 + i Inf)) = +Inf", __imag__ result);
2564 result = FUNC(csin) (BUILD_COMPLEX (minus_zero, plus_infty));
2565 check ("real(csin(-0 + i Inf)) = -0", __real__ result, minus_zero);
2566 check_isinfp ("imag(csin(-0 + i Inf)) = +Inf", __imag__ result);
2567 result = FUNC(csin) (BUILD_COMPLEX (0.0, minus_infty));
2568 check ("real(csin(0 - i Inf)) = 0", __real__ result, 0);
2569 check_isinfn ("imag(csin(0 - i Inf)) = -Inf", __imag__ result);
2570 result = FUNC(csin) (BUILD_COMPLEX (minus_zero, minus_infty));
2571 check ("real(csin(-0 - i Inf)) = -0", __real__ result, minus_zero);
2572 check_isinfn("imag(csin(-0 - i Inf)) = -Inf", __imag__ result);
2574 result = FUNC(csin) (BUILD_COMPLEX (plus_infty, 0.0));
2575 check_isnan_exc ("real(csin(+Inf + 0i)) = NaN plus invalid exception",
2576 __real__ result, INVALID_EXCEPTION);
2577 check ("imag(csin(+Inf + 0i)) = +-0 plus invalid exception",
2578 FUNC(fabs) (__imag__ result), 0);
2579 result = FUNC(csin) (BUILD_COMPLEX (minus_infty, 0.0));
2580 check_isnan_exc ("real(csin(-Inf + 0i)) = NaN plus invalid exception",
2581 __real__ result, INVALID_EXCEPTION);
2582 check ("imag(csin(-Inf + 0i)) = +-0 plus invalid exception",
2583 FUNC(fabs) (__imag__ result), 0);
2584 result = FUNC(csin) (BUILD_COMPLEX (plus_infty, minus_zero));
2585 check_isnan_exc ("real(csin(+Inf - 0i)) = NaN plus invalid exception",
2586 __real__ result, INVALID_EXCEPTION);
2587 check ("imag(csin(+Inf - 0i)) = +-0 plus invalid exception",
2588 FUNC(fabs) (__imag__ result), 0.0);
2589 result = FUNC(csin) (BUILD_COMPLEX (minus_infty, minus_zero));
2590 check_isnan_exc ("real(csin(-Inf - 0i)) = NaN plus invalid exception",
2591 __real__ result, INVALID_EXCEPTION);
2592 check ("imag(csin(-Inf - 0i)) = +-0 plus invalid exception",
2593 FUNC(fabs) (__imag__ result), 0.0);
2595 result = FUNC(csin) (BUILD_COMPLEX (plus_infty, plus_infty));
2596 check_isnan_exc ("real(csin(+Inf + i Inf)) = NaN plus invalid exception",
2597 __real__ result, INVALID_EXCEPTION);
2598 check_isinfp ("imag(csin(+Inf + i Inf)) = +-Inf plus invalid exception",
2599 FUNC(fabs) (__imag__ result));
2600 result = FUNC(csin) (BUILD_COMPLEX (minus_infty, plus_infty));
2601 check_isnan_exc ("real(csin(-Inf + i Inf)) = NaN plus invalid exception",
2602 __real__ result, INVALID_EXCEPTION);
2603 check_isinfp ("imag(csin(-Inf + i Inf)) = +-Inf plus invalid exception",
2604 FUNC(fabs) (__imag__ result));
2605 result = FUNC(csin) (BUILD_COMPLEX (plus_infty, minus_infty));
2606 check_isnan_exc ("real(csin(Inf - i Inf)) = NaN plus invalid exception",
2607 __real__ result, INVALID_EXCEPTION);
2608 check_isinfp ("imag(csin(Inf - i Inf)) = +-Inf plus invalid exception",
2609 FUNC(fabs) (__imag__ result));
2610 result = FUNC(csin) (BUILD_COMPLEX (minus_infty, minus_infty));
2611 check_isnan_exc ("real(csin(-Inf - i Inf)) = NaN plus invalid exception",
2612 __real__ result, INVALID_EXCEPTION);
2613 check_isinfp ("imag(csin(-Inf - i Inf)) = +-Inf plus invalid exception",
2614 FUNC(fabs) (__imag__ result));
2616 result = FUNC(csin) (BUILD_COMPLEX (plus_infty, 6.75));
2617 check_isnan_exc ("real(csin(+Inf + i 6.75)) = NaN plus invalid exception",
2618 __real__ result, INVALID_EXCEPTION);
2619 check_isnan ("imag(csin(+Inf + i6.75)) = NaN plus invalid exception",
2620 __imag__ result);
2621 result = FUNC(csin) (BUILD_COMPLEX (plus_infty, -6.75));
2622 check_isnan_exc ("real(csin(+Inf - i 6.75)) = NaN plus invalid exception",
2623 __real__ result, INVALID_EXCEPTION);
2624 check_isnan ("imag(csin(+Inf - i6.75)) = NaN plus invalid exception",
2625 __imag__ result);
2626 result = FUNC(csin) (BUILD_COMPLEX (minus_infty, 6.75));
2627 check_isnan_exc ("real(csin(-Inf + i6.75)) = NaN plus invalid exception",
2628 __real__ result, INVALID_EXCEPTION);
2629 check_isnan ("imag(csin(-Inf + i6.75)) = NaN plus invalid exception",
2630 __imag__ result);
2631 result = FUNC(csin) (BUILD_COMPLEX (minus_infty, -6.75));
2632 check_isnan_exc ("real(csin(-Inf - i6.75)) = NaN plus invalid exception",
2633 __real__ result, INVALID_EXCEPTION);
2634 check_isnan ("imag(csin(-Inf - i6.75)) = NaN plus invalid exception",
2635 __imag__ result);
2637 result = FUNC(csin) (BUILD_COMPLEX (4.625, plus_infty));
2638 check_isinfn ("real(csin(4.625 + i Inf)) = -Inf", __real__ result);
2639 check_isinfn ("imag(csin(4.625 + i Inf)) = -Inf", __imag__ result);
2640 result = FUNC(csin) (BUILD_COMPLEX (4.625, minus_infty));
2641 check_isinfn ("real(csin(4.625 - i Inf)) = -Inf", __real__ result);
2642 check_isinfp ("imag(csin(4.625 - i Inf)) = +Inf", __imag__ result);
2643 result = FUNC(csin) (BUILD_COMPLEX (-4.625, plus_infty));
2644 check_isinfp ("real(csin(-4.625 + i Inf)) = +Inf", __real__ result);
2645 check_isinfn ("imag(csin(-4.625 + i Inf)) = -Inf", __imag__ result);
2646 result = FUNC(csin) (BUILD_COMPLEX (-4.625, minus_infty));
2647 check_isinfp ("real(csin(-4.625 - i Inf)) = +Inf", __real__ result);
2648 check_isinfp ("imag(csin(-4.625 - i Inf)) = +Inf", __imag__ result);
2650 result = FUNC(csin) (BUILD_COMPLEX (nan_value, 0.0));
2651 check_isnan ("real(csin(NaN + i0)) = NaN", __real__ result);
2652 check ("imag(csin(NaN + i0)) = +-0", FUNC(fabs) (__imag__ result), 0);
2653 result = FUNC(csin) (BUILD_COMPLEX (nan_value, minus_zero));
2654 check_isnan ("real(csin(NaN - i0)) = NaN", __real__ result);
2655 check ("imag(csin(NaN - i0)) = +-0", FUNC(fabs) (__imag__ result), 0);
2657 result = FUNC(csin) (BUILD_COMPLEX (nan_value, plus_infty));
2658 check_isnan ("real(csin(NaN + i Inf)) = NaN", __real__ result);
2659 check_isinfp ("imag(csin(NaN + i Inf)) = +-Inf",
2660 FUNC(fabs) (__imag__ result));
2661 result = FUNC(csin) (BUILD_COMPLEX (nan_value, minus_infty));
2662 check_isnan ("real(csin(NaN - i Inf)) = NaN", __real__ result);
2663 check_isinfp ("real(csin(NaN - i Inf)) = +-Inf",
2664 FUNC(fabs) (__imag__ result));
2666 result = FUNC(csin) (BUILD_COMPLEX (nan_value, 9.0));
2667 check_isnan_maybe_exc ("real(csin(NaN + i9.0)) = NaN plus maybe invalid exception",
2668 __real__ result, INVALID_EXCEPTION);
2669 check_isnan ("imag(csin(NaN + i9.0)) = NaN plus maybe invalid exception",
2670 __imag__ result);
2671 result = FUNC(csin) (BUILD_COMPLEX (nan_value, -9.0));
2672 check_isnan_maybe_exc ("real(csin(NaN - i9.0)) = NaN plus maybe invalid exception",
2673 __real__ result, INVALID_EXCEPTION);
2674 check_isnan ("imag(csin(NaN - i9.0)) = NaN plus maybe invalid exception",
2675 __imag__ result);
2677 result = FUNC(csin) (BUILD_COMPLEX (0.0, nan_value));
2678 check ("real(csin(0 + i NaN))", __real__ result, 0.0);
2679 check_isnan ("imag(csin(0 + i NaN)) = NaN", __imag__ result);
2680 result = FUNC(csin) (BUILD_COMPLEX (minus_zero, nan_value));
2681 check ("real(csin(-0 + i NaN)) = -0", __real__ result, minus_zero);
2682 check_isnan ("imag(csin(-0 + NaN)) = NaN", __imag__ result);
2684 result = FUNC(csin) (BUILD_COMPLEX (10.0, nan_value));
2685 check_isnan_maybe_exc ("real(csin(10 + i NaN)) = NaN plus maybe invalid exception",
2686 __real__ result, INVALID_EXCEPTION);
2687 check_isnan ("imag(csin(10 + i NaN)) = NaN plus maybe invalid exception",
2688 __imag__ result);
2689 result = FUNC(csin) (BUILD_COMPLEX (nan_value, -10.0));
2690 check_isnan_maybe_exc ("real(csin(-10 + i NaN)) = NaN plus maybe invalid exception",
2691 __real__ result, INVALID_EXCEPTION);
2692 check_isnan ("imag(csin(-10 + i NaN)) = NaN plus maybe invalid exception",
2693 __imag__ result);
2695 result = FUNC(csin) (BUILD_COMPLEX (plus_infty, nan_value));
2696 check_isnan_maybe_exc ("real(csin(+Inf + i NaN)) = NaN plus maybe invalid exception",
2697 __real__ result, INVALID_EXCEPTION);
2698 check_isnan ("imag(csin(+Inf + i NaN)) = NaN plus maybe invalid exception",
2699 __imag__ result);
2700 result = FUNC(csin) (BUILD_COMPLEX (minus_infty, nan_value));
2701 check_isnan_maybe_exc ("real(csin(-Inf + i NaN)) = NaN plus maybe invalid exception",
2702 __real__ result, INVALID_EXCEPTION);
2703 check_isnan ("imag(csin(-Inf + i NaN)) = NaN plus maybe invalid exception",
2704 __imag__ result);
2706 result = FUNC(csin) (BUILD_COMPLEX (nan_value, nan_value));
2707 check_isnan ("real(csin(NaN + i NaN)) = NaN", __real__ result);
2708 check_isnan ("imag(csin(NaN + i NaN)) = NaN", __imag__ result);
2712 static void
2713 csinh_test (void)
2715 __complex__ MATHTYPE result;
2717 result = FUNC(csinh) (BUILD_COMPLEX (0.0, 0.0));
2718 check ("real(csinh(0 + 0i)) = 0", __real__ result, 0);
2719 check ("imag(csinh(0 + 0i)) = 0", __imag__ result, 0);
2720 result = FUNC(csinh) (BUILD_COMPLEX (minus_zero, 0.0));
2721 check ("real(csinh(-0 + 0i)) = -0", __real__ result, minus_zero);
2722 check ("imag(csinh(-0 + 0i)) = 0", __imag__ result, 0);
2723 result = FUNC(csinh) (BUILD_COMPLEX (0.0, minus_zero));
2724 check ("real(csinh(0 - 0i)) = 0", __real__ result, 0);
2725 check ("imag(csinh(0 - 0i)) = -0", __imag__ result, minus_zero);
2726 result = FUNC(csinh) (BUILD_COMPLEX (minus_zero, minus_zero));
2727 check ("real(csinh(-0 - 0i)) = -0", __real__ result, minus_zero);
2728 check ("imag(csinh(-0 - 0i)) = -0", __imag__ result, minus_zero);
2730 result = FUNC(csinh) (BUILD_COMPLEX (0.0, plus_infty));
2731 check_exc ("real(csinh(0 + i Inf)) = +-0 plus invalid exception",
2732 FUNC(fabs) (__real__ result), 0, INVALID_EXCEPTION);
2733 check_isnan ("imag(csinh(0 + i Inf)) = NaN plus invalid exception",
2734 __imag__ result);
2735 result = FUNC(csinh) (BUILD_COMPLEX (minus_zero, plus_infty));
2736 check_exc ("real(csinh(-0 + i Inf)) = +-0 plus invalid exception",
2737 FUNC(fabs) (__real__ result), 0, INVALID_EXCEPTION);
2738 check_isnan ("imag(csinh(-0 + i Inf)) = NaN plus invalid exception",
2739 __imag__ result);
2740 result = FUNC(csinh) (BUILD_COMPLEX (0.0, minus_infty));
2741 check_exc ("real(csinh(0 - i Inf)) = +-0 plus invalid exception",
2742 FUNC(fabs) (__real__ result), 0, INVALID_EXCEPTION);
2743 check_isnan ("imag(csinh(0 - i Inf)) = NaN plus invalid exception",
2744 __imag__ result);
2745 result = FUNC(csinh) (BUILD_COMPLEX (minus_zero, minus_infty));
2746 check_exc ("real(csinh(-0 - i Inf)) = +-0 plus invalid exception",
2747 FUNC(fabs) (__real__ result), 0, INVALID_EXCEPTION);
2748 check_isnan ("imag(csinh(-0 - i Inf)) = NaN plus invalid exception",
2749 __imag__ result);
2751 result = FUNC(csinh) (BUILD_COMPLEX (plus_infty, 0.0));
2752 check_isinfp ("real(csinh(+Inf + 0i)) = +Inf", __real__ result);
2753 check ("imag(csinh(+Inf + 0i)) = 0", __imag__ result, 0);
2754 result = FUNC(csinh) (BUILD_COMPLEX (minus_infty, 0.0));
2755 check_isinfn ("real(csinh(-Inf + 0i)) = -Inf", __real__ result);
2756 check ("imag(csinh(-Inf + 0i)) = 0", __imag__ result, 0);
2757 result = FUNC(csinh) (BUILD_COMPLEX (plus_infty, minus_zero));
2758 check_isinfp ("real(csinh(+Inf - 0i)) = +Inf", __real__ result);
2759 check ("imag(csinh(+Inf - 0i)) = -0", __imag__ result, minus_zero);
2760 result = FUNC(csinh) (BUILD_COMPLEX (minus_infty, minus_zero));
2761 check_isinfn ("real(csinh(-Inf - 0i)) = -Inf", __real__ result);
2762 check ("imag(csinh(-Inf - 0i)) = -0", __imag__ result, minus_zero);
2764 result = FUNC(csinh) (BUILD_COMPLEX (plus_infty, plus_infty));
2765 check_isinfp_exc ("real(csinh(+Inf + i Inf)) = +-Inf plus invalid exception",
2766 FUNC(fabs) (__real__ result), INVALID_EXCEPTION);
2767 check_isnan ("imag(csinh(+Inf + i Inf)) = NaN plus invalid exception",
2768 __imag__ result);
2769 result = FUNC(csinh) (BUILD_COMPLEX (minus_infty, plus_infty));
2770 check_isinfp_exc ("real(csinh(-Inf + i Inf)) = +-Inf plus invalid exception",
2771 FUNC(fabs) (__real__ result), INVALID_EXCEPTION);
2772 check_isnan ("imag(csinh(-Inf + i Inf)) = NaN plus invalid exception",
2773 __imag__ result);
2774 result = FUNC(csinh) (BUILD_COMPLEX (plus_infty, minus_infty));
2775 check_isinfp_exc ("real(csinh(Inf - i Inf)) = +-Inf plus invalid exception",
2776 FUNC(fabs) (__real__ result), INVALID_EXCEPTION);
2777 check_isnan ("imag(csinh(Inf - i Inf)) = NaN plus invalid exception",
2778 __imag__ result);
2779 result = FUNC(csinh) (BUILD_COMPLEX (minus_infty, minus_infty));
2780 check_isinfp_exc ("real(csinh(-Inf - i Inf)) = +-Inf plus invalid exception",
2781 FUNC(fabs) (__real__ result), INVALID_EXCEPTION);
2782 check_isnan ("imag(csinh(-Inf - i Inf)) = NaN plus invalid exception",
2783 __imag__ result);
2785 result = FUNC(csinh) (BUILD_COMPLEX (plus_infty, 4.625));
2786 check_isinfn ("real(csinh(+Inf + i4.625)) = -Inf", __real__ result);
2787 check_isinfn ("imag(csinh(+Inf + i4.625)) = -Inf", __imag__ result);
2788 result = FUNC(csinh) (BUILD_COMPLEX (minus_infty, 4.625));
2789 check_isinfp ("real(csinh(-Inf + i4.625)) = +Inf", __real__ result);
2790 check_isinfn ("imag(csinh(-Inf + i4.625)) = -Inf", __imag__ result);
2791 result = FUNC(csinh) (BUILD_COMPLEX (plus_infty, -4.625));
2792 check_isinfn ("real(csinh(+Inf - i4.625)) = -Inf", __real__ result);
2793 check_isinfp ("imag(csinh(+Inf - i4.625)) = +Inf", __imag__ result);
2794 result = FUNC(csinh) (BUILD_COMPLEX (minus_infty, -4.625));
2795 check_isinfp ("real(csinh(-Inf - i4.625)) = +Inf", __real__ result);
2796 check_isinfp ("imag(csinh(-Inf - i4.625)) = +Inf", __imag__ result);
2798 result = FUNC(csinh) (BUILD_COMPLEX (6.75, plus_infty));
2799 check_isnan_exc ("real(csinh(6.75 + i Inf)) = NaN plus invalid exception",
2800 __real__ result, INVALID_EXCEPTION);
2801 check_isnan ("imag(csinh(6.75 + i Inf)) = NaN plus invalid exception",
2802 __imag__ result);
2803 result = FUNC(csinh) (BUILD_COMPLEX (-6.75, plus_infty));
2804 check_isnan_exc ("real(csinh(-6.75 + i Inf)) = NaN plus invalid exception",
2805 __real__ result, INVALID_EXCEPTION);
2806 check_isnan ("imag(csinh(-6.75 + i Inf)) = NaN plus invalid exception",
2807 __imag__ result);
2808 result = FUNC(csinh) (BUILD_COMPLEX (6.75, minus_infty));
2809 check_isnan_exc ("real(csinh(6.75 - i Inf)) = NaN plus invalid exception",
2810 __real__ result, INVALID_EXCEPTION);
2811 check_isnan ("imag(csinh(6.75 - i Inf)) = NaN plus invalid exception",
2812 __imag__ result);
2813 result = FUNC(csinh) (BUILD_COMPLEX (-6.75, minus_infty));
2814 check_isnan_exc ("real(csinh(-6.75 - i Inf)) = NaN plus invalid exception",
2815 __real__ result, INVALID_EXCEPTION);
2816 check_isnan ("imag(csinh(-6.75 - i Inf)) = NaN plus invalid exception",
2817 __imag__ result);
2819 result = FUNC(csinh) (BUILD_COMPLEX (0.0, nan_value));
2820 check ("real(csinh(0 + i NaN)) = +-0", FUNC(fabs) (__real__ result), 0);
2821 check_isnan ("imag(csinh(0 + i NaN)) = NaN", __imag__ result);
2822 result = FUNC(csinh) (BUILD_COMPLEX (minus_zero, nan_value));
2823 check ("real(csinh(-0 + i NaN)) = +-0", FUNC(fabs) (__real__ result), 0);
2824 check_isnan ("imag(csinh(-0 + i NaN)) = NaN", __imag__ result);
2826 result = FUNC(csinh) (BUILD_COMPLEX (plus_infty, nan_value));
2827 check_isinfp ("real(csinh(+Inf + i NaN)) = +-Inf",
2828 FUNC(fabs) (__real__ result));
2829 check_isnan ("imag(csinh(+Inf + i NaN)) = NaN", __imag__ result);
2830 result = FUNC(csinh) (BUILD_COMPLEX (minus_infty, nan_value));
2831 check_isinfp ("real(csinh(-Inf + i NaN)) = +-Inf",
2832 FUNC(fabs) (__real__ result));
2833 check_isnan ("imag(csinh(-Inf + i NaN)) = NaN", __imag__ result);
2835 result = FUNC(csinh) (BUILD_COMPLEX (9.0, nan_value));
2836 check_isnan_maybe_exc ("real(csinh(9.0 + i NaN)) = NaN plus maybe invalid exception",
2837 __real__ result, INVALID_EXCEPTION);
2838 check_isnan ("imag(csinh(9.0 + i NaN)) = NaN plus maybe invalid exception",
2839 __imag__ result);
2840 result = FUNC(csinh) (BUILD_COMPLEX (-9.0, nan_value));
2841 check_isnan_maybe_exc ("real(csinh(-9.0 + i NaN)) = NaN plus maybe invalid exception",
2842 __real__ result, INVALID_EXCEPTION);
2843 check_isnan ("imag(csinh(-9.0 + i NaN)) = NaN plus maybe invalid exception",
2844 __imag__ result);
2846 result = FUNC(csinh) (BUILD_COMPLEX (nan_value, 0.0));
2847 check_isnan ("real(csinh(NaN + i0)) = NaN", __real__ result);
2848 check ("imag(csinh(NaN + i0)) = 0", __imag__ result, 0.0);
2849 result = FUNC(csinh) (BUILD_COMPLEX (nan_value, minus_zero));
2850 check_isnan ("real(csinh(NaN - i0)) = NaN", __real__ result);
2851 check ("imag(csinh(NaN - i0)) = -0", __imag__ result, minus_zero);
2853 result = FUNC(csinh) (BUILD_COMPLEX (nan_value, 10.0));
2854 check_isnan_maybe_exc ("real(csinh(NaN + i10)) = NaN plus maybe invalid exception",
2855 __real__ result, INVALID_EXCEPTION);
2856 check_isnan ("imag(csinh(NaN + i10)) = NaN plus maybe invalid exception",
2857 __imag__ result);
2858 result = FUNC(csinh) (BUILD_COMPLEX (nan_value, -10.0));
2859 check_isnan_maybe_exc ("real(csinh(NaN - i10)) = NaN plus maybe invalid exception",
2860 __real__ result, INVALID_EXCEPTION);
2861 check_isnan ("imag(csinh(NaN - i10)) = NaN plus maybe invalid exception",
2862 __imag__ result);
2864 result = FUNC(csinh) (BUILD_COMPLEX (nan_value, plus_infty));
2865 check_isnan_maybe_exc ("real(csinh(NaN + i Inf)) = NaN plus maybe invalid exception",
2866 __real__ result, INVALID_EXCEPTION);
2867 check_isnan ("imag(csinh(NaN + i Inf)) = NaN plus maybe invalid exception",
2868 __imag__ result);
2869 result = FUNC(csinh) (BUILD_COMPLEX (nan_value, minus_infty));
2870 check_isnan_maybe_exc ("real(csinh(NaN - i Inf)) = NaN plus maybe invalid exception",
2871 __real__ result, INVALID_EXCEPTION);
2872 check_isnan ("imag(csinh(NaN - i Inf)) = NaN plus maybe invalid exception",
2873 __imag__ result);
2875 result = FUNC(csinh) (BUILD_COMPLEX (nan_value, nan_value));
2876 check_isnan ("real(csinh(NaN + i NaN)) = NaN", __real__ result);
2877 check_isnan ("imag(csinh(NaN + i NaN)) = NaN", __imag__ result);
2881 static void
2882 ccos_test (void)
2884 __complex__ MATHTYPE result;
2886 result = FUNC(ccos) (BUILD_COMPLEX (0.0, 0.0));
2887 check ("real(ccos(0 + 0i)) = 1.0", __real__ result, 1.0);
2888 check ("imag(ccos(0 + 0i)) = -0", __imag__ result, minus_zero);
2889 result = FUNC(ccos) (BUILD_COMPLEX (minus_zero, 0.0));
2890 check ("real(ccos(-0 + 0i)) = 1.0", __real__ result, 1.0);
2891 check ("imag(ccos(-0 + 0i)) = 0", __imag__ result, 0.0);
2892 result = FUNC(ccos) (BUILD_COMPLEX (0.0, minus_zero));
2893 check ("real(ccos(0 - 0i)) = 1.0", __real__ result, 1.0);
2894 check ("imag(ccos(0 - 0i)) = 0", __imag__ result, 0.0);
2895 result = FUNC(ccos) (BUILD_COMPLEX (minus_zero, minus_zero));
2896 check ("real(ccos(-0 - 0i)) = 1.0", __real__ result, 1.0);
2897 check ("imag(ccos(-0 - 0i)) = -0", __imag__ result, minus_zero);
2899 result = FUNC(ccos) (BUILD_COMPLEX (plus_infty, 0.0));
2900 check_isnan_exc ("real(ccos(+Inf + i0)) = NaN plus invalid exception",
2901 __real__ result, INVALID_EXCEPTION);
2902 check ("imag(ccos(Inf + i0)) = +-0 plus invalid exception",
2903 FUNC(fabs) (__imag__ result), 0);
2904 result = FUNC(ccos) (BUILD_COMPLEX (plus_infty, minus_zero));
2905 check_isnan_exc ("real(ccos(Inf - i0)) = NaN plus invalid exception",
2906 __real__ result, INVALID_EXCEPTION);
2907 check ("imag(ccos(Inf - i0)) = +-0 plus invalid exception",
2908 FUNC(fabs) (__imag__ result), 0);
2909 result = FUNC(ccos) (BUILD_COMPLEX (minus_infty, 0.0));
2910 check_isnan_exc ("real(ccos(-Inf + i0)) = NaN plus invalid exception",
2911 __real__ result, INVALID_EXCEPTION);
2912 check ("imag(ccos(-Inf + i0)) = +-0 plus invalid exception",
2913 FUNC(fabs) (__imag__ result), 0);
2914 result = FUNC(ccos) (BUILD_COMPLEX (minus_infty, minus_zero));
2915 check_isnan_exc ("real(ccos(-Inf - i0)) = NaN plus invalid exception",
2916 __real__ result, INVALID_EXCEPTION);
2917 check ("imag(ccos(-Inf - i0)) = +-0 plus invalid exception",
2918 FUNC(fabs) (__imag__ result), 0);
2920 result = FUNC(ccos) (BUILD_COMPLEX (0.0, plus_infty));
2921 check_isinfp ("real(ccos(0 + i Inf)) = +Inf", __real__ result);
2922 check ("imag(ccos(0 + i Inf)) = -0", __imag__ result, minus_zero);
2923 result = FUNC(ccos) (BUILD_COMPLEX (0.0, minus_infty));
2924 check_isinfp ("real(ccos(0 - i Inf)) = +Inf", __real__ result);
2925 check ("imag(ccos(0 - i Inf)) = 0", __imag__ result, 0);
2926 result = FUNC(ccos) (BUILD_COMPLEX (minus_zero, plus_infty));
2927 check_isinfp ("real(ccos(-0 + i Inf)) = +Inf", __real__ result);
2928 check ("imag(ccos(-0 + i Inf)) = 0", __imag__ result, 0.0);
2929 result = FUNC(ccos) (BUILD_COMPLEX (minus_zero, minus_infty));
2930 check_isinfp ("real(ccos(-0 - i Inf)) = +Inf", __real__ result);
2931 check ("imag(ccos(-0 - i Inf)) = -0", __imag__ result, minus_zero);
2933 result = FUNC(ccos) (BUILD_COMPLEX (plus_infty, plus_infty));
2934 check_isinfp_exc ("real(ccos(+Inf + i Inf)) = +Inf plus invalid exception",
2935 __real__ result, INVALID_EXCEPTION);
2936 check_isnan ("imag(ccos(+Inf + i Inf)) = NaN plus invalid exception",
2937 __imag__ result);
2938 result = FUNC(ccos) (BUILD_COMPLEX (minus_infty, plus_infty));
2939 check_isinfp_exc ("real(ccos(-Inf + i Inf)) = +Inf plus invalid exception",
2940 __real__ result, INVALID_EXCEPTION);
2941 check_isnan ("imag(ccos(-Inf + i Inf)) = NaN plus invalid exception",
2942 __imag__ result);
2943 result = FUNC(ccos) (BUILD_COMPLEX (plus_infty, minus_infty));
2944 check_isinfp_exc ("real(ccos(Inf - i Inf)) = +Inf plus invalid exception",
2945 __real__ result, INVALID_EXCEPTION);
2946 check_isnan ("imag(ccos(Inf - i Inf)) = NaN plus invalid exception",
2947 __imag__ result);
2948 result = FUNC(ccos) (BUILD_COMPLEX (minus_infty, minus_infty));
2949 check_isinfp_exc ("real(ccos(-Inf - i Inf)) = +Inf plus invalid exception",
2950 __real__ result, INVALID_EXCEPTION);
2951 check_isnan ("imag(ccos(-Inf - i Inf)) = NaN plus invalid exception",
2952 __imag__ result);
2954 result = FUNC(ccos) (BUILD_COMPLEX (4.625, plus_infty));
2955 check_isinfn ("real(ccos(4.625 + i Inf)) = -Inf", __real__ result);
2956 check_isinfp ("imag(ccos(4.625 + i Inf)) = +Inf", __imag__ result);
2957 result = FUNC(ccos) (BUILD_COMPLEX (4.625, minus_infty));
2958 check_isinfn ("real(ccos(4.625 - i Inf)) = -Inf", __real__ result);
2959 check_isinfn ("imag(ccos(4.625 - i Inf)) = -Inf", __imag__ result);
2960 result = FUNC(ccos) (BUILD_COMPLEX (-4.625, plus_infty));
2961 check_isinfn ("real(ccos(-4.625 + i Inf)) = -Inf", __real__ result);
2962 check_isinfn ("imag(ccos(-4.625 + i Inf)) = -Inf", __imag__ result);
2963 result = FUNC(ccos) (BUILD_COMPLEX (-4.625, minus_infty));
2964 check_isinfn ("real(ccos(-4.625 - i Inf)) = -Inf", __real__ result);
2965 check_isinfp ("imag(ccos(-4.625 - i Inf)) = +Inf", __imag__ result);
2967 result = FUNC(ccos) (BUILD_COMPLEX (plus_infty, 6.75));
2968 check_isnan_exc ("real(ccos(+Inf + i6.75)) = NaN plus invalid exception",
2969 __real__ result, INVALID_EXCEPTION);
2970 check_isnan ("imag(ccos(+Inf + i6.75)) = NaN plus invalid exception",
2971 __imag__ result);
2972 result = FUNC(ccos) (BUILD_COMPLEX (plus_infty, -6.75));
2973 check_isnan_exc ("real(ccos(+Inf - i6.75)) = NaN plus invalid exception",
2974 __real__ result, INVALID_EXCEPTION);
2975 check_isnan ("imag(ccos(+Inf - i6.75)) = NaN plus invalid exception",
2976 __imag__ result);
2977 result = FUNC(ccos) (BUILD_COMPLEX (minus_infty, 6.75));
2978 check_isnan_exc ("real(ccos(-Inf + i6.75)) = NaN plus invalid exception",
2979 __real__ result, INVALID_EXCEPTION);
2980 check_isnan ("imag(ccos(-Inf + i6.75)) = NaN plus invalid exception",
2981 __imag__ result);
2982 result = FUNC(ccos) (BUILD_COMPLEX (minus_infty, -6.75));
2983 check_isnan_exc ("real(ccos(-Inf - i6.75)) = NaN plus invalid exception",
2984 __real__ result, INVALID_EXCEPTION);
2985 check_isnan ("imag(ccos(-Inf - i6.75)) = NaN plus invalid exception",
2986 __imag__ result);
2988 result = FUNC(ccos) (BUILD_COMPLEX (nan_value, 0.0));
2989 check_isnan ("real(ccos(NaN + i0)) = NaN", __real__ result);
2990 check ("imag(ccos(NaN + i0)) = +-0", FUNC(fabs) (__imag__ result), 0);
2991 result = FUNC(ccos) (BUILD_COMPLEX (nan_value, minus_zero));
2992 check_isnan ("real(ccos(NaN - i0)) = NaN", __real__ result);
2993 check ("imag(ccos(NaN - i0)) = +-0", FUNC(fabs) (__imag__ result), 0);
2995 result = FUNC(ccos) (BUILD_COMPLEX (nan_value, plus_infty));
2996 check_isinfp ("real(ccos(NaN + i Inf)) = +Inf", __real__ result);
2997 check_isnan ("imag(ccos(NaN + i Inf)) = NaN", __imag__ result);
2998 result = FUNC(ccos) (BUILD_COMPLEX (nan_value, minus_infty));
2999 check_isinfp ("real(ccos(NaN - i Inf)) = +Inf", __real__ result);
3000 check_isnan ("imag(ccos(NaN - i Inf)) = NaN", __imag__ result);
3002 result = FUNC(ccos) (BUILD_COMPLEX (nan_value, 9.0));
3003 check_isnan_maybe_exc ("real(ccos(NaN + i9.0)) = NaN plus maybe invalid exception",
3004 __real__ result, INVALID_EXCEPTION);
3005 check_isnan ("imag(ccos(NaN + i9.0)) = NaN plus maybe invalid exception",
3006 __imag__ result);
3007 result = FUNC(ccos) (BUILD_COMPLEX (nan_value, -9.0));
3008 check_isnan_maybe_exc ("real(ccos(NaN - i9.0)) = NaN plus maybe invalid exception",
3009 __real__ result, INVALID_EXCEPTION);
3010 check_isnan ("imag(ccos(NaN - i9.0)) = NaN plus maybe invalid exception",
3011 __imag__ result);
3013 result = FUNC(ccos) (BUILD_COMPLEX (0.0, nan_value));
3014 check_isnan ("real(ccos(0 + i NaN)) = NaN", __real__ result);
3015 check ("imag(ccos(0 + i NaN)) = +-0", FUNC(fabs) (__imag__ result), 0.0);
3016 result = FUNC(ccos) (BUILD_COMPLEX (minus_zero, nan_value));
3017 check_isnan ("real(ccos(-0 + i NaN)) = NaN", __real__ result);
3018 check ("imag(ccos(-0 + i NaN)) = +-0", FUNC(fabs) (__imag__ result), 0.0);
3020 result = FUNC(ccos) (BUILD_COMPLEX (10.0, nan_value));
3021 check_isnan_maybe_exc ("real(ccos(10 + i NaN)) = NaN plus maybe invalid exception",
3022 __real__ result, INVALID_EXCEPTION);
3023 check_isnan ("imag(ccos(10 + i NaN)) = NaN plus maybe invalid exception",
3024 __imag__ result);
3025 result = FUNC(ccos) (BUILD_COMPLEX (-10.0, nan_value));
3026 check_isnan_maybe_exc ("real(ccos(-10 + i NaN)) = NaN plus maybe invalid exception",
3027 __real__ result, INVALID_EXCEPTION);
3028 check_isnan ("imag(ccos(-10 + i NaN)) = NaN plus maybe invalid exception",
3029 __imag__ result);
3031 result = FUNC(ccos) (BUILD_COMPLEX (plus_infty, nan_value));
3032 check_isnan_maybe_exc ("real(ccos(+Inf + i NaN)) = NaN plus maybe invalid exception",
3033 __real__ result, INVALID_EXCEPTION);
3034 check_isnan ("imag(ccos(+Inf + i NaN)) = NaN plus maybe invalid exception",
3035 __imag__ result);
3036 result = FUNC(ccos) (BUILD_COMPLEX (minus_infty, nan_value));
3037 check_isnan_maybe_exc ("real(ccos(-Inf + i NaN)) = NaN plus maybe invalid exception",
3038 __real__ result, INVALID_EXCEPTION);
3039 check_isnan ("imag(ccos(-Inf + i NaN)) = NaN plus maybe invalid exception",
3040 __imag__ result);
3042 result = FUNC(ccos) (BUILD_COMPLEX (nan_value, nan_value));
3043 check_isnan ("real(ccos(NaN + i NaN)) = NaN", __real__ result);
3044 check_isnan ("imag(ccos(NaN + i NaN)) = NaN", __imag__ result);
3048 static void
3049 ccosh_test (void)
3051 __complex__ MATHTYPE result;
3053 result = FUNC(ccosh) (BUILD_COMPLEX (0.0, 0.0));
3054 check ("real(ccosh(0 + 0i)) = 1.0", __real__ result, 1.0);
3055 check ("imag(ccosh(0 + 0i)) = 0", __imag__ result, 0);
3056 result = FUNC(ccosh) (BUILD_COMPLEX (minus_zero, 0.0));
3057 check ("real(ccosh(-0 + 0i)) = 1.0", __real__ result, 1.0);
3058 check ("imag(ccosh(-0 + 0i)) = -0", __imag__ result, minus_zero);
3059 result = FUNC(ccosh) (BUILD_COMPLEX (0.0, minus_zero));
3060 check ("real(ccosh(0 - 0i)) = 1.0", __real__ result, 1.0);
3061 check ("imag(ccosh(0 - 0i)) = -0", __imag__ result, minus_zero);
3062 result = FUNC(ccosh) (BUILD_COMPLEX (minus_zero, minus_zero));
3063 check ("real(ccosh(-0 - 0i)) = 1.0", __real__ result, 1.0);
3064 check ("imag(ccosh(-0 - 0i)) = 0", __imag__ result, 0.0);
3066 result = FUNC(ccosh) (BUILD_COMPLEX (0.0, plus_infty));
3067 check_isnan_exc ("real(ccosh(0 + i Inf)) = NaN plus invalid exception",
3068 __real__ result, INVALID_EXCEPTION);
3069 check ("imag(ccosh(0 + i Inf)) = +-0 plus invalid exception",
3070 FUNC(fabs) (__imag__ result), 0);
3071 result = FUNC(ccosh) (BUILD_COMPLEX (minus_zero, plus_infty));
3072 check_isnan_exc ("real(ccosh(-0 + i Inf)) = NaN plus invalid exception",
3073 __real__ result, INVALID_EXCEPTION);
3074 check ("imag(ccosh(-0 + i Inf)) = +-0 plus invalid exception",
3075 FUNC(fabs) (__imag__ result), 0);
3076 result = FUNC(ccosh) (BUILD_COMPLEX (0.0, minus_infty));
3077 check_isnan_exc ("real(ccosh(0 - i Inf)) = NaN plus invalid exception",
3078 __real__ result, INVALID_EXCEPTION);
3079 check ("imag(ccosh(0 - i Inf)) = +-0 plus invalid exception",
3080 FUNC(fabs) (__imag__ result), 0);
3081 result = FUNC(ccosh) (BUILD_COMPLEX (minus_zero, minus_infty));
3082 check_isnan_exc ("real(ccosh(-0 - i Inf)) = NaN plus invalid exception",
3083 __real__ result, INVALID_EXCEPTION);
3084 check ("imag(ccosh(-0 - i Inf)) = +-0 plus invalid exception",
3085 FUNC(fabs) (__imag__ result), 0);
3087 result = FUNC(ccosh) (BUILD_COMPLEX (plus_infty, 0.0));
3088 check_isinfp ("real(ccosh(+Inf + 0i)) = +Inf", __real__ result);
3089 check ("imag(ccosh(+Inf + 0i)) = 0", __imag__ result, 0);
3090 result = FUNC(ccosh) (BUILD_COMPLEX (minus_infty, 0.0));
3091 check_isinfp ("real(ccosh(-Inf + 0i)) = +Inf", __real__ result);
3092 check ("imag(ccosh(-Inf + 0i)) = -0", __imag__ result, minus_zero);
3093 result = FUNC(ccosh) (BUILD_COMPLEX (plus_infty, minus_zero));
3094 check_isinfp ("real(ccosh(+Inf - 0i)) = +Inf", __real__ result);
3095 check ("imag(ccosh(+Inf - 0i)) = -0", __imag__ result, minus_zero);
3096 result = FUNC(ccosh) (BUILD_COMPLEX (minus_infty, minus_zero));
3097 check_isinfp ("real(ccosh(-Inf - 0i)) = +Inf", __real__ result);
3098 check ("imag(ccosh(-Inf - 0i)) = 0", __imag__ result, 0.0);
3100 result = FUNC(ccosh) (BUILD_COMPLEX (plus_infty, plus_infty));
3101 check_isinfp_exc ("real(ccosh(+Inf + i Inf)) = +Inf plus invalid exception",
3102 __real__ result, INVALID_EXCEPTION);
3103 check_isnan ("imag(ccosh(+Inf + i Inf)) = NaN plus invalid exception",
3104 __imag__ result);
3105 result = FUNC(ccosh) (BUILD_COMPLEX (minus_infty, plus_infty));
3106 check_isinfp_exc ("real(ccosh(-Inf + i Inf)) = +Inf plus invalid exception",
3107 __real__ result, INVALID_EXCEPTION);
3108 check_isnan ("imag(ccosh(-Inf + i Inf)) = NaN plus invalid exception",
3109 __imag__ result);
3110 result = FUNC(ccosh) (BUILD_COMPLEX (plus_infty, minus_infty));
3111 check_isinfp_exc ("real(ccosh(Inf - i Inf)) = +Inf plus invalid exception",
3112 __real__ result, INVALID_EXCEPTION);
3113 check_isnan ("imag(ccosh(Inf - i Inf)) = NaN plus invalid exception",
3114 __imag__ result);
3115 result = FUNC(ccosh) (BUILD_COMPLEX (minus_infty, minus_infty));
3116 check_isinfp_exc ("real(ccosh(-Inf - i Inf)) = +Inf plus invalid exception",
3117 __real__ result, INVALID_EXCEPTION);
3118 check_isnan ("imag(ccosh(-Inf - i Inf)) = NaN plus invalid exception",
3119 __imag__ result);
3121 result = FUNC(ccosh) (BUILD_COMPLEX (plus_infty, 4.625));
3122 check_isinfn ("real(ccosh(+Inf + i4.625)) = -Inf", __real__ result);
3123 check_isinfn ("imag(ccosh(+Inf + i4.625)) = -Inf", __imag__ result);
3124 result = FUNC(ccosh) (BUILD_COMPLEX (minus_infty, 4.625));
3125 check_isinfn ("real(ccosh(-Inf + i4.625)) = -Inf", __real__ result);
3126 check_isinfp ("imag(ccosh(-Inf + i4.625)) = Inf", __imag__ result);
3127 result = FUNC(ccosh) (BUILD_COMPLEX (plus_infty, -4.625));
3128 check_isinfn ("real(ccosh(+Inf - i4.625)) = -Inf", __real__ result);
3129 check_isinfp ("imag(ccosh(+Inf - i4.625)) = +Inf", __imag__ result);
3130 result = FUNC(ccosh) (BUILD_COMPLEX (minus_infty, -4.625));
3131 check_isinfn ("real(ccosh(-Inf - i4.625)) = -Inf", __real__ result);
3132 check_isinfn ("imag(ccosh(-Inf - i4.625)) = -Inf", __imag__ result);
3134 result = FUNC(ccosh) (BUILD_COMPLEX (6.75, plus_infty));
3135 check_isnan_exc ("real(ccosh(6.75 + i Inf)) = NaN plus invalid exception",
3136 __real__ result, INVALID_EXCEPTION);
3137 check_isnan ("imag(ccosh(6.75 + i Inf)) = NaN plus invalid exception",
3138 __imag__ result);
3139 result = FUNC(ccosh) (BUILD_COMPLEX (-6.75, plus_infty));
3140 check_isnan_exc ("real(ccosh(-6.75 + i Inf)) = NaN plus invalid exception",
3141 __real__ result, INVALID_EXCEPTION);
3142 check_isnan ("imag(ccosh(-6.75 + i Inf)) = NaN plus invalid exception",
3143 __imag__ result);
3144 result = FUNC(ccosh) (BUILD_COMPLEX (6.75, minus_infty));
3145 check_isnan_exc ("real(ccosh(6.75 - i Inf)) = NaN plus invalid exception",
3146 __real__ result, INVALID_EXCEPTION);
3147 check_isnan ("imag(ccosh(6.75 - i Inf)) = NaN plus invalid exception",
3148 __imag__ result);
3149 result = FUNC(ccosh) (BUILD_COMPLEX (-6.75, minus_infty));
3150 check_isnan_exc ("real(ccosh(-6.75 - i Inf)) = NaN plus invalid exception",
3151 __real__ result, INVALID_EXCEPTION);
3152 check_isnan ("imag(ccosh(-6.75 - i Inf)) = NaN plus invalid exception",
3153 __imag__ result);
3155 result = FUNC(ccosh) (BUILD_COMPLEX (0.0, nan_value));
3156 check_isnan ("real(ccosh(0 + i NaN)) = NaN", __real__ result);
3157 check ("imag(ccosh(0 + i NaN)) = +-0", FUNC(fabs) (__imag__ result), 0);
3158 result = FUNC(ccosh) (BUILD_COMPLEX (minus_zero, nan_value));
3159 check_isnan ("real(ccosh(-0 + i NaN)) = NaN", __real__ result);
3160 check ("imag(ccosh(-0 + i NaN)) = +-0", FUNC(fabs) (__imag__ result), 0);
3162 result = FUNC(ccosh) (BUILD_COMPLEX (plus_infty, nan_value));
3163 check_isinfp ("real(ccosh(+Inf + i NaN)) = +Inf", __real__ result);
3164 check_isnan ("imag(ccosh(+Inf + i NaN)) = NaN", __imag__ result);
3165 result = FUNC(ccosh) (BUILD_COMPLEX (minus_infty, nan_value));
3166 check_isinfp ("real(ccosh(-Inf + i NaN)) = +Inf", __real__ result);
3167 check_isnan ("imag(ccosh(-Inf + i NaN)) = NaN", __imag__ result);
3169 result = FUNC(ccosh) (BUILD_COMPLEX (9.0, nan_value));
3170 check_isnan_maybe_exc ("real(ccosh(9.0 + i NaN)) = NaN plus maybe invalid exception",
3171 __real__ result, INVALID_EXCEPTION);
3172 check_isnan ("imag(ccosh(9.0 + i NaN)) = NaN plus maybe invalid exception",
3173 __imag__ result);
3174 result = FUNC(ccosh) (BUILD_COMPLEX (-9.0, nan_value));
3175 check_isnan_maybe_exc ("real(ccosh(-9.0 + i NaN)) = NaN plus maybe invalid exception",
3176 __real__ result, INVALID_EXCEPTION);
3177 check_isnan ("imag(ccosh(-9.0 + i NaN)) = NaN plus maybe invalid exception",
3178 __imag__ result);
3180 result = FUNC(ccosh) (BUILD_COMPLEX (nan_value, 0.0));
3181 check_isnan ("real(ccosh(NaN + i0)) = NaN", __real__ result);
3182 check ("imag(ccosh(NaN + i0)) = +-0", FUNC(fabs) (__imag__ result), 0.0);
3183 result = FUNC(ccosh) (BUILD_COMPLEX (nan_value, minus_zero));
3184 check_isnan ("real(ccosh(NaN - i0)) = NaN", __real__ result);
3185 check ("imag(ccosh(NaN - i0)) = +-0", FUNC(fabs) (__imag__ result), 0.0);
3187 result = FUNC(ccosh) (BUILD_COMPLEX (nan_value, 10.0));
3188 check_isnan_maybe_exc ("real(ccosh(NaN + i10)) = NaN plus maybe invalid exception",
3189 __real__ result, INVALID_EXCEPTION);
3190 check_isnan ("imag(ccosh(NaN + i10)) = NaN plus maybe invalid exception",
3191 __imag__ result);
3192 result = FUNC(ccosh) (BUILD_COMPLEX (nan_value, -10.0));
3193 check_isnan_maybe_exc ("real(ccosh(NaN - i10)) = NaN plus maybe invalid exception",
3194 __real__ result, INVALID_EXCEPTION);
3195 check_isnan ("imag(ccosh(NaN - i10)) = NaN plus maybe invalid exception",
3196 __imag__ result);
3198 result = FUNC(ccosh) (BUILD_COMPLEX (nan_value, plus_infty));
3199 check_isnan_maybe_exc ("real(ccosh(NaN + i Inf)) = NaN plus maybe invalid exception",
3200 __real__ result, INVALID_EXCEPTION);
3201 check_isnan ("imag(ccosh(NaN + i Inf)) = NaN plus maybe invalid exception",
3202 __imag__ result);
3203 result = FUNC(ccosh) (BUILD_COMPLEX (nan_value, minus_infty));
3204 check_isnan_maybe_exc ("real(ccosh(NaN - i Inf)) = NaN plus maybe invalid exception",
3205 __real__ result, INVALID_EXCEPTION);
3206 check_isnan ("imag(ccosh(NaN - i Inf)) = NaN plus maybe invalid exception",
3207 __imag__ result);
3209 result = FUNC(ccosh) (BUILD_COMPLEX (nan_value, nan_value));
3210 check_isnan ("real(ccosh(NaN + i NaN)) = NaN", __real__ result);
3211 check_isnan ("imag(ccosh(NaN + i NaN)) = NaN", __imag__ result);
3215 static void
3216 cacos_test (void)
3218 __complex__ MATHTYPE result;
3220 result = FUNC(cacos) (BUILD_COMPLEX (0, 0));
3221 check ("real(cacos(0 + i0)) = pi/2", __real__ result, M_PI_2);
3222 check ("imag(cacos(0 + i0)) = -0", __imag__ result, minus_zero);
3223 result = FUNC(cacos) (BUILD_COMPLEX (minus_zero, 0));
3224 check ("real(cacos(-0 + i0)) = pi/2", __real__ result, M_PI_2);
3225 check ("imag(cacos(-0 + i0)) = -0", __imag__ result, minus_zero);
3226 result = FUNC(cacos) (BUILD_COMPLEX (0, minus_zero));
3227 check ("real(cacos(0 - i0)) = pi/2", __real__ result, M_PI_2);
3228 check ("imag(cacos(0 - i0)) = 0", __imag__ result, 0);
3229 result = FUNC(cacos) (BUILD_COMPLEX (minus_zero, minus_zero));
3230 check ("real(cacos(-0 - i0)) = pi/2", __real__ result, M_PI_2);
3231 check ("imag(cacos(-0 - i0)) = 0", __imag__ result, 0);
3233 result = FUNC(cacos) (BUILD_COMPLEX (minus_infty, plus_infty));
3234 check ("real(cacos(-Inf + i Inf)) = 3*pi/4", __real__ result, M_PI - M_PI_4);
3235 check_isinfn ("imag(cacos(-Inf + i Inf)) = -Inf", __imag__ result);
3236 result = FUNC(cacos) (BUILD_COMPLEX (minus_infty, minus_infty));
3237 check ("real(cacos(-Inf - i Inf)) = 3*pi/4", __real__ result, M_PI - M_PI_4);
3238 check_isinfp ("imag(cacos(-Inf - i Inf)) = +Inf", __imag__ result);
3240 result = FUNC(cacos) (BUILD_COMPLEX (plus_infty, plus_infty));
3241 check ("real(cacos(+Inf + i Inf)) = pi/4", __real__ result, M_PI_4);
3242 check_isinfn ("imag(cacos(+Inf + i Inf)) = -Inf", __imag__ result);
3243 result = FUNC(cacos) (BUILD_COMPLEX (plus_infty, minus_infty));
3244 check ("real(cacos(+Inf - i Inf)) = pi/4", __real__ result, M_PI_4);
3245 check_isinfp ("imag(cacos(+Inf - i Inf)) = +Inf", __imag__ result);
3247 result = FUNC(cacos) (BUILD_COMPLEX (-10.0, plus_infty));
3248 check ("real(cacos(-10.0 + i Inf)) = pi/2", __real__ result, M_PI_2);
3249 check_isinfn ("imag(cacos(-10.0 + i Inf)) = -Inf", __imag__ result);
3250 result = FUNC(cacos) (BUILD_COMPLEX (-10.0, minus_infty));
3251 check ("real(cacos(-10.0 - i Inf)) = pi/2", __real__ result, M_PI_2);
3252 check_isinfp ("imag(cacos(-10.0 - i Inf)) = +Inf", __imag__ result);
3253 result = FUNC(cacos) (BUILD_COMPLEX (0, plus_infty));
3254 check ("real(cacos(0 + i Inf)) = pi/2", __real__ result, M_PI_2);
3255 check_isinfn ("imag(cacos(0 + i Inf)) = -Inf", __imag__ result);
3256 result = FUNC(cacos) (BUILD_COMPLEX (0, minus_infty));
3257 check ("real(cacos(0 - i Inf)) = pi/2", __real__ result, M_PI_2);
3258 check_isinfp ("imag(cacos(0 - i Inf)) = +Inf", __imag__ result);
3259 result = FUNC(cacos) (BUILD_COMPLEX (0.1, plus_infty));
3260 check ("real(cacos(0.1 + i Inf)) = pi/2", __real__ result, M_PI_2);
3261 check_isinfn ("imag(cacos(0.1 + i Inf)) = -Inf", __imag__ result);
3262 result = FUNC(cacos) (BUILD_COMPLEX (0.1, minus_infty));
3263 check ("real(cacos(0.1 - i Inf)) = pi/2", __real__ result, M_PI_2);
3264 check_isinfp ("imag(cacos(0.1 - i Inf)) = +Inf", __imag__ result);
3266 result = FUNC(cacos) (BUILD_COMPLEX (minus_infty, 0));
3267 check ("real(cacos(-Inf + i0)) = pi", __real__ result, M_PI);
3268 check_isinfn ("imag(cacos(-Inf + i0)) = -Inf", __imag__ result);
3269 result = FUNC(cacos) (BUILD_COMPLEX (minus_infty, minus_zero));
3270 check ("real(cacos(-Inf - i0)) = pi", __real__ result, M_PI);
3271 check_isinfp ("imag(cacos(-Inf - i0)) = +Inf", __imag__ result);
3272 result = FUNC(cacos) (BUILD_COMPLEX (minus_infty, 100));
3273 check ("real(cacos(-Inf + i100)) = pi", __real__ result, M_PI);
3274 check_isinfn ("imag(cacos(-Inf + i100)) = -Inf", __imag__ result);
3275 result = FUNC(cacos) (BUILD_COMPLEX (minus_infty, -100));
3276 check ("real(cacos(-Inf - i100)) = pi", __real__ result, M_PI);
3277 check_isinfp ("imag(cacos(-Inf - i100)) = +Inf", __imag__ result);
3279 result = FUNC(cacos) (BUILD_COMPLEX (plus_infty, 0));
3280 check ("real(cacos(+Inf + i0)) = 0", __real__ result, 0);
3281 check_isinfn ("imag(cacos(+Inf + i0)) = -Inf", __imag__ result);
3282 result = FUNC(cacos) (BUILD_COMPLEX (plus_infty, minus_zero));
3283 check ("real(cacos(+Inf - i0)) = 0", __real__ result, 0);
3284 check_isinfp ("imag(cacos(+Inf - i0)) = +Inf", __imag__ result);
3285 result = FUNC(cacos) (BUILD_COMPLEX (plus_infty, 0.5));
3286 check ("real(cacos(+Inf + i0.5)) = 0", __real__ result, 0);
3287 check_isinfn ("imag(cacos(+Inf + i0.5)) = -Inf", __imag__ result);
3288 result = FUNC(cacos) (BUILD_COMPLEX (plus_infty, -0.5));
3289 check ("real(cacos(+Inf - i0.5)) = 0", __real__ result, 0);
3290 check_isinfp ("imag(cacos(+Inf - i0.5)) = +Inf", __imag__ result);
3292 result = FUNC(cacos) (BUILD_COMPLEX (plus_infty, nan_value));
3293 check_isnan ("real(cacos(+Inf + i NaN)) = NaN", __real__ result);
3294 check_isinfp ("imag(cacos(+Inf + i NaN)) = +-Inf",
3295 FUNC(fabs) (__imag__ result));
3296 result = FUNC(cacos) (BUILD_COMPLEX (minus_infty, nan_value));
3297 check_isnan ("real(cacos(-Inf + i NaN)) = NaN", __real__ result);
3298 check_isinfp ("imag(cacos(-Inf + i NaN)) = +-Inf",
3299 FUNC(fabs) (__imag__ result));
3301 result = FUNC(cacos) (BUILD_COMPLEX (0, nan_value));
3302 check ("real(cacos(0 + i NaN)) = pi/2", __real__ result, M_PI_2);
3303 check_isnan ("imag(cacos(0 + i NaN)) = NaN", __imag__ result);
3304 result = FUNC(cacos) (BUILD_COMPLEX (minus_zero, nan_value));
3305 check ("real(cacos(-0 + i NaN)) = pi/2", __real__ result, M_PI_2);
3306 check_isnan ("imag(cacos(-0 + i NaN)) = NaN", __imag__ result);
3308 result = FUNC(cacos) (BUILD_COMPLEX (nan_value, plus_infty));
3309 check_isnan ("real(cacos(NaN + i Inf)) = NaN", __real__ result);
3310 check_isinfn ("imag(cacos(NaN + i Inf)) = -Inf", __imag__ result);
3311 result = FUNC(cacos) (BUILD_COMPLEX (nan_value, minus_infty));
3312 check_isnan ("real(cacos(NaN - i Inf)) = NaN", __real__ result);
3313 check_isinfp ("imag(cacos(NaN - i Inf)) = +Inf", __imag__ result);
3315 result = FUNC(cacos) (BUILD_COMPLEX (10.5, nan_value));
3316 check_isnan_maybe_exc ("real(cacos(10.5 + i NaN)) = NaN plus maybe invalid exception",
3317 __real__ result, INVALID_EXCEPTION);
3318 check_isnan ("imag(cacos(10.5 + i NaN)) = NaN plus maybe invalid exception",
3319 __imag__ result);
3320 result = FUNC(cacos) (BUILD_COMPLEX (-10.5, nan_value));
3321 check_isnan_maybe_exc ("real(cacos(-10.5 + i NaN)) = NaN plus maybe invalid exception",
3322 __real__ result, INVALID_EXCEPTION);
3323 check_isnan ("imag(cacos(-10.5 + i NaN)) = NaN plus maybe invalid exception",
3324 __imag__ result);
3326 result = FUNC(cacos) (BUILD_COMPLEX (nan_value, 0.75));
3327 check_isnan_maybe_exc ("real(cacos(NaN + i0.75)) = NaN plus maybe invalid exception",
3328 __real__ result, INVALID_EXCEPTION);
3329 check_isnan ("imag(cacos(NaN + i0.75)) = NaN plus maybe invalid exception",
3330 __imag__ result);
3331 result = FUNC(cacos) (BUILD_COMPLEX (-10.5, nan_value));
3332 check_isnan_maybe_exc ("real(cacos(NaN - i0.75)) = NaN plus maybe invalid exception",
3333 __real__ result, INVALID_EXCEPTION);
3334 check_isnan ("imag(cacos(NaN - i0.75)) = NaN plus maybe invalid exception",
3335 __imag__ result);
3337 result = FUNC(cacos) (BUILD_COMPLEX (nan_value, nan_value));
3338 check_isnan ("real(cacos(NaN + i NaN)) = NaN", __real__ result);
3339 check_isnan ("imag(cacos(NaN + i NaN)) = NaN", __imag__ result);
3343 static void
3344 cacosh_test (void)
3346 __complex__ MATHTYPE result;
3348 result = FUNC(cacosh) (BUILD_COMPLEX (0, 0));
3349 check ("real(cacosh(0 + i0)) = 0", __real__ result, 0);
3350 check ("imag(cacosh(0 + i0)) = pi/2", __imag__ result, M_PI_2);
3351 result = FUNC(cacosh) (BUILD_COMPLEX (minus_zero, 0));
3352 check ("real(cacosh(-0 + i0)) = 0", __real__ result, 0);
3353 check ("imag(cacosh(-0 + i0)) = pi/2", __imag__ result, M_PI_2);
3354 result = FUNC(cacosh) (BUILD_COMPLEX (0, minus_zero));
3355 check ("real(cacosh(0 - i0)) = 0", __real__ result, 0);
3356 check ("imag(cacosh(0 - i0)) = -pi/2", __imag__ result, -M_PI_2);
3357 result = FUNC(cacosh) (BUILD_COMPLEX (minus_zero, minus_zero));
3358 check ("real(cacosh(-0 - i0)) = 0", __real__ result, 0);
3359 check ("imag(cacosh(-0 - i0)) = -pi/2", __imag__ result, -M_PI_2);
3361 result = FUNC(cacosh) (BUILD_COMPLEX (minus_infty, plus_infty));
3362 check_isinfp ("real(cacosh(-Inf + i Inf)) = +Inf", __real__ result);
3363 check ("imag(cacosh(-Inf + i Inf)) = 3*pi/4", __imag__ result,
3364 M_PI - M_PI_4);
3365 result = FUNC(cacosh) (BUILD_COMPLEX (minus_infty, minus_infty));
3366 check_isinfp ("real(cacosh(-Inf - i Inf)) = +Inf", __real__ result);
3367 check ("imag(cacosh(-Inf - i Inf)) = -3*pi/4", __imag__ result,
3368 M_PI_4 - M_PI);
3370 result = FUNC(cacosh) (BUILD_COMPLEX (plus_infty, plus_infty));
3371 check_isinfp ("real(cacosh(+Inf + i Inf)) = +Inf", __real__ result);
3372 check ("imag(cacosh(+Inf + i Inf)) = pi/4", __imag__ result, M_PI_4);
3373 result = FUNC(cacosh) (BUILD_COMPLEX (plus_infty, minus_infty));
3374 check_isinfp ("real(cacosh(+Inf - i Inf)) = +Inf", __real__ result);
3375 check ("imag(cacosh(+Inf - i Inf)) = -pi/4", __imag__ result, -M_PI_4);
3377 result = FUNC(cacosh) (BUILD_COMPLEX (-10.0, plus_infty));
3378 check_isinfp ("real(cacosh(-10.0 + i Inf)) = +Inf", __real__ result);
3379 check ("imag(cacosh(-10.0 + i Inf)) = pi/2", __imag__ result, M_PI_2);
3380 result = FUNC(cacosh) (BUILD_COMPLEX (-10.0, minus_infty));
3381 check_isinfp ("real(cacosh(-10.0 - i Inf)) = +Inf", __real__ result);
3382 check ("imag(cacosh(-10.0 - i Inf)) = -pi/2", __imag__ result, -M_PI_2);
3383 result = FUNC(cacosh) (BUILD_COMPLEX (0, plus_infty));
3384 check_isinfp ("real(cacosh(0 + i Inf)) = +Inf", __real__ result);
3385 check ("imag(cacosh(0 + i Inf)) = pi/2", __imag__ result, M_PI_2);
3386 result = FUNC(cacosh) (BUILD_COMPLEX (0, minus_infty));
3387 check_isinfp ("real(cacosh(0 - i Inf)) = +Inf", __real__ result);
3388 check ("imag(cacosh(0 - i Inf)) = -pi/2", __imag__ result, -M_PI_2);
3389 result = FUNC(cacosh) (BUILD_COMPLEX (0.1, plus_infty));
3390 check_isinfp ("real(cacosh(0.1 + i Inf)) = +Inf", __real__ result);
3391 check ("imag(cacosh(0.1 + i Inf)) = pi/2", __imag__ result, M_PI_2);
3392 result = FUNC(cacosh) (BUILD_COMPLEX (0.1, minus_infty));
3393 check_isinfp ("real(cacosh(0.1 - i Inf)) = +Inf", __real__ result);
3394 check ("imag(cacosh(0.1 - i Inf)) = -pi/2", __imag__ result, -M_PI_2);
3396 result = FUNC(cacosh) (BUILD_COMPLEX (minus_infty, 0));
3397 check_isinfp ("real(cacosh(-Inf + i0)) = +Inf", __real__ result);
3398 check ("imag(cacosh(-Inf + i0)) = pi", __imag__ result, M_PI);
3399 result = FUNC(cacosh) (BUILD_COMPLEX (minus_infty, minus_zero));
3400 check_isinfp ("real(cacosh(-Inf - i0)) = +Inf", __real__ result);
3401 check ("imag(cacosh(-Inf - i0)) = -pi", __imag__ result, -M_PI);
3402 result = FUNC(cacosh) (BUILD_COMPLEX (minus_infty, 100));
3403 check_isinfp ("real(cacosh(-Inf + i100)) = +Inf", __real__ result);
3404 check ("imag(cacosh(-Inf + i100)) = pi", __imag__ result, M_PI);
3405 result = FUNC(cacosh) (BUILD_COMPLEX (minus_infty, -100));
3406 check_isinfp ("real(cacosh(-Inf - i100)) = +Inf", __real__ result);
3407 check ("imag(cacosh(-Inf - i100)) = -pi", __imag__ result, -M_PI);
3409 result = FUNC(cacosh) (BUILD_COMPLEX (plus_infty, 0));
3410 check_isinfp ("real(cacosh(+Inf + i0)) = +Inf", __real__ result);
3411 check ("imag(cacosh(+Inf + i0)) = 0", __imag__ result, 0);
3412 result = FUNC(cacosh) (BUILD_COMPLEX (plus_infty, minus_zero));
3413 check_isinfp ("real(cacosh(+Inf - i0)) = +Inf", __real__ result);
3414 check ("imag(cacosh(+Inf - i0)) = -0", __imag__ result, minus_zero);
3415 result = FUNC(cacosh) (BUILD_COMPLEX (plus_infty, 0.5));
3416 check_isinfp ("real(cacosh(+Inf + i0.5)) = +Inf", __real__ result);
3417 check ("imag(cacosh(+Inf + i0.5)) = 0", __imag__ result, 0);
3418 result = FUNC(cacosh) (BUILD_COMPLEX (plus_infty, -0.5));
3419 check_isinfp ("real(cacosh(+Inf - i0.5)) = +Inf", __real__ result);
3420 check ("imag(cacosh(+Inf - i0.5)) = -0", __imag__ result, minus_zero);
3422 result = FUNC(cacosh) (BUILD_COMPLEX (plus_infty, nan_value));
3423 check_isinfp ("real(cacosh(+Inf + i NaN)) = +Inf", __real__ result);
3424 check_isnan ("imag(cacosh(+Inf + i NaN)) = NaN", __imag__ result);
3425 result = FUNC(cacosh) (BUILD_COMPLEX (minus_infty, nan_value));
3426 check_isinfp ("real(cacosh(-Inf + i NaN)) = +Inf", __real__ result);
3427 check_isnan ("imag(cacosh(-Inf + i NaN)) = NaN", __imag__ result);
3429 result = FUNC(cacosh) (BUILD_COMPLEX (0, nan_value));
3430 check_isnan ("real(cacosh(0 + i NaN)) = NaN", __real__ result);
3431 check_isnan ("imag(cacosh(0 + i NaN)) = NaN", __imag__ result);
3432 result = FUNC(cacosh) (BUILD_COMPLEX (minus_zero, nan_value));
3433 check_isnan ("real(cacosh(-0 + i NaN)) = NaN", __real__ result);
3434 check_isnan ("imag(cacosh(-0 + i NaN)) = NaN", __imag__ result);
3436 result = FUNC(cacosh) (BUILD_COMPLEX (nan_value, plus_infty));
3437 check_isinfp ("real(cacosh(NaN + i Inf)) = +Inf", __real__ result);
3438 check_isnan ("imag(cacosh(NaN + i Inf)) = NaN", __imag__ result);
3439 result = FUNC(cacosh) (BUILD_COMPLEX (nan_value, minus_infty));
3440 check_isinfp ("real(cacosh(NaN - i Inf)) = +Inf", __real__ result);
3441 check_isnan ("imag(cacosh(NaN - i Inf)) = NaN", __imag__ result);
3443 result = FUNC(cacosh) (BUILD_COMPLEX (10.5, nan_value));
3444 check_isnan_maybe_exc ("real(cacosh(10.5 + i NaN)) = NaN plus maybe invalid exception",
3445 __real__ result, INVALID_EXCEPTION);
3446 check_isnan ("imag(cacosh(10.5 + i NaN)) = NaN plus maybe invalid exception",
3447 __imag__ result);
3448 result = FUNC(cacosh) (BUILD_COMPLEX (-10.5, nan_value));
3449 check_isnan_maybe_exc ("real(cacosh(-10.5 + i NaN)) = NaN plus maybe invalid exception",
3450 __real__ result, INVALID_EXCEPTION);
3451 check_isnan ("imag(cacosh(-10.5 + i NaN)) = NaN plus maybe invalid exception",
3452 __imag__ result);
3454 result = FUNC(cacosh) (BUILD_COMPLEX (nan_value, 0.75));
3455 check_isnan_maybe_exc ("real(cacosh(NaN + i0.75)) = NaN plus maybe invalid exception",
3456 __real__ result, INVALID_EXCEPTION);
3457 check_isnan ("imag(cacosh(NaN + i0.75)) = NaN plus maybe invalid exception",
3458 __imag__ result);
3459 result = FUNC(cacosh) (BUILD_COMPLEX (-10.5, nan_value));
3460 check_isnan_maybe_exc ("real(cacosh(NaN - i0.75)) = NaN plus maybe invalid exception",
3461 __real__ result, INVALID_EXCEPTION);
3462 check_isnan ("imag(cacosh(NaN - i0.75)) = NaN plus maybe invalid exception",
3463 __imag__ result);
3465 result = FUNC(cacosh) (BUILD_COMPLEX (nan_value, nan_value));
3466 check_isnan ("real(cacosh(NaN + i NaN)) = NaN", __real__ result);
3467 check_isnan ("imag(cacosh(NaN + i NaN)) = NaN", __imag__ result);
3471 static void
3472 casin_test (void)
3474 __complex__ MATHTYPE result;
3476 result = FUNC(casin) (BUILD_COMPLEX (0, 0));
3477 check ("real(casin(0 + i0)) = 0", __real__ result, 0);
3478 check ("imag(casin(0 + i0)) = 0", __imag__ result, 0);
3479 result = FUNC(casin) (BUILD_COMPLEX (minus_zero, 0));
3480 check ("real(casin(-0 + i0)) = -0", __real__ result, minus_zero);
3481 check ("imag(casin(-0 + i0)) = 0", __imag__ result, 0);
3482 result = FUNC(casin) (BUILD_COMPLEX (0, minus_zero));
3483 check ("real(casin(0 - i0)) = 0", __real__ result, 0);
3484 check ("imag(casin(0 - i0)) = -0", __imag__ result, minus_zero);
3485 result = FUNC(casin) (BUILD_COMPLEX (minus_zero, minus_zero));
3486 check ("real(casin(-0 - i0)) = -0", __real__ result, minus_zero);
3487 check ("imag(casin(-0 - i0)) = -0", __imag__ result, minus_zero);
3489 result = FUNC(casin) (BUILD_COMPLEX (plus_infty, plus_infty));
3490 check ("real(casin(+Inf + i Inf)) = pi/4", __real__ result, M_PI_4);
3491 check_isinfp ("imag(casin(+Inf + i Inf)) = +Inf", __imag__ result);
3492 result = FUNC(casin) (BUILD_COMPLEX (plus_infty, minus_infty));
3493 check ("real(casin(+Inf - i Inf)) = pi/4", __real__ result, M_PI_4);
3494 check_isinfn ("imag(casin(+Inf - i Inf)) = -Inf", __imag__ result);
3495 result = FUNC(casin) (BUILD_COMPLEX (minus_infty, plus_infty));
3496 check ("real(casin(-Inf + i Inf)) = -pi/4", __real__ result, -M_PI_4);
3497 check_isinfp ("imag(casin(-Inf + i Inf)) = +Inf", __imag__ result);
3498 result = FUNC(casin) (BUILD_COMPLEX (minus_infty, minus_infty));
3499 check ("real(casin(-Inf - i Inf)) = -pi/4", __real__ result, -M_PI_4);
3500 check_isinfn ("imag(casin(-Inf - i Inf)) = -Inf", __imag__ result);
3502 result = FUNC(casin) (BUILD_COMPLEX (-10.0, plus_infty));
3503 check ("real(casin(-10.0 + i Inf)) = -0", __real__ result, minus_zero);
3504 check_isinfp ("imag(casin(-10.0 + i Inf)) = +Inf", __imag__ result);
3505 result = FUNC(casin) (BUILD_COMPLEX (-10.0, minus_infty));
3506 check ("real(casin(-10.0 - i Inf)) = -0", __real__ result, minus_zero);
3507 check_isinfn ("imag(casin(-10.0 - i Inf)) = -Inf", __imag__ result);
3508 result = FUNC(casin) (BUILD_COMPLEX (0, plus_infty));
3509 check ("real(casin(0 + i Inf)) = 0", __real__ result, 0.0);
3510 check_isinfp ("imag(casin(0 + i Inf)) = +Inf", __imag__ result);
3511 result = FUNC(casin) (BUILD_COMPLEX (0, minus_infty));
3512 check ("real(casin(0 - i Inf)) = 0", __real__ result, 0.0);
3513 check_isinfn ("imag(casin(0 - i Inf)) = -Inf", __imag__ result);
3514 result = FUNC(casin) (BUILD_COMPLEX (minus_zero, plus_infty));
3515 check ("real(casin(-0 + i Inf)) = -0", __real__ result, minus_zero);
3516 check_isinfp ("imag(casin(-0 + i Inf)) = +Inf", __imag__ result);
3517 result = FUNC(casin) (BUILD_COMPLEX (minus_zero, minus_infty));
3518 check ("real(casin(-0 - i Inf)) = -0", __real__ result, minus_zero);
3519 check_isinfn ("imag(casin(-0 - i Inf)) = -Inf", __imag__ result);
3520 result = FUNC(casin) (BUILD_COMPLEX (0.1, plus_infty));
3521 check ("real(casin(0.1 + i Inf)) = 0", __real__ result, 0);
3522 check_isinfp ("imag(casin(0.1 + i Inf)) = +Inf", __imag__ result);
3523 result = FUNC(casin) (BUILD_COMPLEX (0.1, minus_infty));
3524 check ("real(casin(0.1 - i Inf)) = 0", __real__ result, 0);
3525 check_isinfn ("imag(casin(0.1 - i Inf)) = -Inf", __imag__ result);
3527 result = FUNC(casin) (BUILD_COMPLEX (minus_infty, 0));
3528 check ("real(casin(-Inf + i0)) = -pi/2", __real__ result, -M_PI_2);
3529 check_isinfp ("imag(casin(-Inf + i0)) = +Inf", __imag__ result);
3530 result = FUNC(casin) (BUILD_COMPLEX (minus_infty, minus_zero));
3531 check ("real(casin(-Inf - i0)) = -pi/2", __real__ result, -M_PI_2);
3532 check_isinfn ("imag(casin(-Inf - i0)) = -Inf", __imag__ result);
3533 result = FUNC(casin) (BUILD_COMPLEX (minus_infty, 100));
3534 check ("real(casin(-Inf + i100)) = -pi/2", __real__ result, -M_PI_2);
3535 check_isinfp ("imag(casin(-Inf + i100)) = +Inf", __imag__ result);
3536 result = FUNC(casin) (BUILD_COMPLEX (minus_infty, -100));
3537 check ("real(casin(-Inf - i100)) = -pi/2", __real__ result, -M_PI_2);
3538 check_isinfn ("imag(casin(-Inf - i100)) = -Inf", __imag__ result);
3540 result = FUNC(casin) (BUILD_COMPLEX (plus_infty, 0));
3541 check ("real(casin(+Inf + i0)) = pi/2", __real__ result, M_PI_2);
3542 check_isinfp ("imag(casin(+Inf + i0)) = +Inf", __imag__ result);
3543 result = FUNC(casin) (BUILD_COMPLEX (plus_infty, minus_zero));
3544 check ("real(casin(+Inf - i0)) = pi/2", __real__ result, M_PI_2);
3545 check_isinfn ("imag(casin(+Inf - i0)) = -Inf", __imag__ result);
3546 result = FUNC(casin) (BUILD_COMPLEX (plus_infty, 0.5));
3547 check ("real(casin(+Inf + i0.5)) = pi/2", __real__ result, M_PI_2);
3548 check_isinfp ("imag(casin(+Inf + i0.5)) = +Inf", __imag__ result);
3549 result = FUNC(casin) (BUILD_COMPLEX (plus_infty, -0.5));
3550 check ("real(casin(+Inf - i0.5)) = pi/2", __real__ result, M_PI_2);
3551 check_isinfn ("imag(casin(+Inf - i0.5)) = -Inf", __imag__ result);
3553 result = FUNC(casin) (BUILD_COMPLEX (nan_value, plus_infty));
3554 check_isnan ("real(casin(NaN + i Inf)) = NaN", __real__ result);
3555 check_isinfp ("imag(casin(NaN + i Inf)) = +Inf", __imag__ result);
3556 result = FUNC(casin) (BUILD_COMPLEX (nan_value, minus_infty));
3557 check_isnan ("real(casin(NaN - i Inf)) = NaN", __real__ result);
3558 check_isinfn ("imag(casin(NaN - i Inf)) = -Inf", __imag__ result);
3560 result = FUNC(casin) (BUILD_COMPLEX (0.0, nan_value));
3561 check ("real(casin(0 + i NaN)) = 0", __real__ result, 0.0);
3562 check_isnan ("imag(casin(0 + i NaN)) = NaN", __imag__ result);
3563 result = FUNC(casin) (BUILD_COMPLEX (minus_zero, nan_value));
3564 check ("real(casin(-0 + i NaN)) = -0", __real__ result, minus_zero);
3565 check_isnan ("imag(casin(-0 + i NaN)) = NaN", __imag__ result);
3567 result = FUNC(casin) (BUILD_COMPLEX (plus_infty, nan_value));
3568 check_isnan ("real(casin(+Inf + i NaN)) = NaN", __real__ result);
3569 check_isinfp ("imag(casin(+Inf + i NaN)) = +-Inf",
3570 FUNC(fabs) (__imag__ result));
3571 result = FUNC(casin) (BUILD_COMPLEX (minus_infty, nan_value));
3572 check_isnan ("real(casin(-Inf + i NaN)) = NaN", __real__ result);
3573 check_isinfp ("imag(casin(-Inf + NaN)) = +-Inf",
3574 FUNC(fabs) (__imag__ result));
3576 result = FUNC(casin) (BUILD_COMPLEX (nan_value, 10.5));
3577 check_isnan_maybe_exc ("real(casin(NaN + i10.5)) = NaN plus maybe invalid exception",
3578 __real__ result, INVALID_EXCEPTION);
3579 check_isnan ("imag(casin(NaN + i10.5)) = NaN plus maybe invalid exception",
3580 __imag__ result);
3581 result = FUNC(casin) (BUILD_COMPLEX (nan_value, -10.5));
3582 check_isnan_maybe_exc ("real(casin(NaN - i10.5)) = NaN plus maybe invalid exception",
3583 __real__ result, INVALID_EXCEPTION);
3584 check_isnan ("imag(casin(NaN - i10.5)) = NaN plus maybe invalid exception",
3585 __imag__ result);
3587 result = FUNC(casin) (BUILD_COMPLEX (0.75, nan_value));
3588 check_isnan_maybe_exc ("real(casin(0.75 + i NaN)) = NaN plus maybe invalid exception",
3589 __real__ result, INVALID_EXCEPTION);
3590 check_isnan ("imag(casin(0.75 + i NaN)) = NaN plus maybe invalid exception",
3591 __imag__ result);
3592 result = FUNC(casin) (BUILD_COMPLEX (-0.75, nan_value));
3593 check_isnan_maybe_exc ("real(casin(-0.75 + i NaN)) = NaN plus maybe invalid exception",
3594 __real__ result, INVALID_EXCEPTION);
3595 check_isnan ("imag(casin(-0.75 + i NaN)) = NaN plus maybe invalid exception",
3596 __imag__ result);
3598 result = FUNC(casin) (BUILD_COMPLEX (nan_value, nan_value));
3599 check_isnan ("real(casin(NaN + i NaN)) = NaN", __real__ result);
3600 check_isnan ("imag(casin(NaN + i NaN)) = NaN", __imag__ result);
3604 static void
3605 casinh_test (void)
3607 __complex__ MATHTYPE result;
3609 result = FUNC(casinh) (BUILD_COMPLEX (0, 0));
3610 check ("real(casinh(0 + i0)) = 0", __real__ result, 0);
3611 check ("imag(casinh(0 + i0)) = 0", __imag__ result, 0);
3612 result = FUNC(casinh) (BUILD_COMPLEX (minus_zero, 0));
3613 check ("real(casinh(-0 + i0)) = -0", __real__ result, minus_zero);
3614 check ("imag(casinh(-0 + i0)) = 0", __imag__ result, 0);
3615 result = FUNC(casinh) (BUILD_COMPLEX (0, minus_zero));
3616 check ("real(casinh(0 - i0)) = 0", __real__ result, 0);
3617 check ("imag(casinh(0 - i0)) = -0", __imag__ result, minus_zero);
3618 result = FUNC(casinh) (BUILD_COMPLEX (minus_zero, minus_zero));
3619 check ("real(casinh(-0 - i0)) = -0", __real__ result, minus_zero);
3620 check ("imag(casinh(-0 - i0)) = -0", __imag__ result, minus_zero);
3622 result = FUNC(casinh) (BUILD_COMPLEX (plus_infty, plus_infty));
3623 check_isinfp ("real(casinh(+Inf + i Inf)) = +Inf", __real__ result);
3624 check ("imag(casinh(+Inf + i Inf)) = pi/4", __imag__ result, M_PI_4);
3625 result = FUNC(casinh) (BUILD_COMPLEX (plus_infty, minus_infty));
3626 check_isinfp ("real(casinh(+Inf - i Inf)) = +Inf", __real__ result);
3627 check ("imag(casinh(+Inf - i Inf)) = -pi/4", __imag__ result, -M_PI_4);
3628 result = FUNC(casinh) (BUILD_COMPLEX (minus_infty, plus_infty));
3629 check_isinfn ("real(casinh(-Inf + i Inf)) = -Inf", __real__ result);
3630 check ("imag(casinh(-Inf + i Inf)) = pi/4", __imag__ result, M_PI_4);
3631 result = FUNC(casinh) (BUILD_COMPLEX (minus_infty, minus_infty));
3632 check_isinfn ("real(casinh(-Inf - i Inf)) = -Inf", __real__ result);
3633 check ("imag(casinh(-Inf - i Inf)) = -pi/4", __imag__ result, -M_PI_4);
3635 result = FUNC(casinh) (BUILD_COMPLEX (-10.0, plus_infty));
3636 check_isinfn ("real(casinh(-10.0 + i Inf)) = -Inf", __real__ result);
3637 check ("imag(casinh(-10.0 + i Inf)) = pi/2", __imag__ result, M_PI_2);
3638 result = FUNC(casinh) (BUILD_COMPLEX (-10.0, minus_infty));
3639 check_isinfn ("real(casinh(-10.0 - i Inf)) = -Inf", __real__ result);
3640 check ("imag(casinh(-10.0 - i Inf)) = -pi/2", __imag__ result, -M_PI_2);
3641 result = FUNC(casinh) (BUILD_COMPLEX (0, plus_infty));
3642 check_isinfp ("real(casinh(0 + i Inf)) = +Inf", __real__ result);
3643 check ("imag(casinh(0 + i Inf)) = pi/2", __imag__ result, M_PI_2);
3644 result = FUNC(casinh) (BUILD_COMPLEX (0, minus_infty));
3645 check_isinfp ("real(casinh(0 - i Inf)) = +Inf", __real__ result);
3646 check ("imag(casinh(0 - i Inf)) = -pi/2", __imag__ result, -M_PI_2);
3647 result = FUNC(casinh) (BUILD_COMPLEX (minus_zero, plus_infty));
3648 check_isinfn ("real(casinh(-0 + i Inf)) = -Inf", __real__ result);
3649 check ("imag(casinh(-0 + i Inf)) = pi/2", __imag__ result, M_PI_2);
3650 result = FUNC(casinh) (BUILD_COMPLEX (minus_zero, minus_infty));
3651 check_isinfn ("real(casinh(-0 - i Inf)) = -Inf", __real__ result);
3652 check ("imag(casinh(-0 - i Inf)) = -pi/2", __imag__ result, -M_PI_2);
3653 result = FUNC(casinh) (BUILD_COMPLEX (0.1, plus_infty));
3654 check_isinfp ("real(casinh(0.1 + i Inf)) = +Inf", __real__ result);
3655 check ("imag(casinh(0.1 + i Inf)) = pi/2", __imag__ result, M_PI_2);
3656 result = FUNC(casinh) (BUILD_COMPLEX (0.1, minus_infty));
3657 check_isinfp ("real(casinh(0.1 - i Inf)) = +Inf", __real__ result);
3658 check ("imag(casinh(0.1 - i Inf)) = -pi/2", __imag__ result, -M_PI_2);
3660 result = FUNC(casinh) (BUILD_COMPLEX (minus_infty, 0));
3661 check_isinfn ("real(casinh(-Inf + i0)) = -Inf", __real__ result);
3662 check ("imag(casinh(-Inf + i0)) = 0", __imag__ result, 0);
3663 result = FUNC(casinh) (BUILD_COMPLEX (minus_infty, minus_zero));
3664 check_isinfn ("real(casinh(-Inf - i0)) = -Inf", __real__ result);
3665 check ("imag(casinh(-Inf - i0)) = -0", __imag__ result, minus_zero);
3666 result = FUNC(casinh) (BUILD_COMPLEX (minus_infty, 100));
3667 check_isinfn ("real(casinh(-Inf + i100)) = -Inf", __real__ result);
3668 check ("imag(casinh(-Inf + i100)) = 0", __imag__ result, 0);
3669 result = FUNC(casinh) (BUILD_COMPLEX (minus_infty, -100));
3670 check_isinfn ("real(casinh(-Inf - i100)) = -Inf", __real__ result);
3671 check ("imag(casinh(-Inf - i100)) = -0", __imag__ result, minus_zero);
3673 result = FUNC(casinh) (BUILD_COMPLEX (plus_infty, 0));
3674 check_isinfp ("real(casinh(+Inf + i0)) = +Inf", __real__ result);
3675 check ("imag(casinh(+Inf + i0)) = 0", __imag__ result, 0);
3676 result = FUNC(casinh) (BUILD_COMPLEX (plus_infty, minus_zero));
3677 check_isinfp ("real(casinh(+Inf - i0)) = +Inf", __real__ result);
3678 check ("imag(casinh(+Inf - i0)) = -0", __imag__ result, minus_zero);
3679 result = FUNC(casinh) (BUILD_COMPLEX (plus_infty, 0.5));
3680 check_isinfp ("real(casinh(+Inf + i0.5)) = +Inf", __real__ result);
3681 check ("imag(casinh(+Inf + i0.5)) = 0", __imag__ result, 0);
3682 result = FUNC(casinh) (BUILD_COMPLEX (plus_infty, -0.5));
3683 check_isinfp ("real(casinh(+Inf - i0.5)) = +Inf", __real__ result);
3684 check ("imag(casinh(+Inf - i0.5)) = -0", __imag__ result, minus_zero);
3686 result = FUNC(casinh) (BUILD_COMPLEX (plus_infty, nan_value));
3687 check_isinfp ("real(casinh(+Inf + i NaN)) = +Inf", __real__ result);
3688 check_isnan ("imag(casinh(+Inf + i NaN)) = NaN", __imag__ result);
3689 result = FUNC(casinh) (BUILD_COMPLEX (minus_infty, nan_value));
3690 check_isinfn ("real(casinh(-Inf + i NaN)) = -Inf", __real__ result);
3691 check_isnan ("imag(casinh(-Inf + i NaN)) = NaN", __imag__ result);
3693 result = FUNC(casinh) (BUILD_COMPLEX (nan_value, 0));
3694 check_isnan ("real(casinh(NaN + i0)) = NaN", __real__ result);
3695 check ("imag(casinh(NaN + i0)) = 0", __imag__ result, 0);
3696 result = FUNC(casinh) (BUILD_COMPLEX (nan_value, minus_zero));
3697 check_isnan ("real(casinh(NaN - i0)) = NaN", __real__ result);
3698 check ("imag(casinh(NaN - i0)) = -0", __imag__ result, minus_zero);
3700 result = FUNC(casinh) (BUILD_COMPLEX (nan_value, plus_infty));
3701 check_isinfp ("real(casinh(NaN + i Inf)) = +-Inf",
3702 FUNC(fabs) (__real__ result));
3703 check_isnan ("imag(casinh(NaN + i Inf)) = NaN", __imag__ result);
3704 result = FUNC(casinh) (BUILD_COMPLEX (nan_value, minus_infty));
3705 check_isinfp ("real(casinh(NaN - i Inf)) = +-Inf",
3706 FUNC(fabs) (__real__ result));
3707 check_isnan ("imag(casinh(NaN - i Inf)) = NaN", __imag__ result);
3709 result = FUNC(casinh) (BUILD_COMPLEX (10.5, nan_value));
3710 check_isnan_maybe_exc ("real(casinh(10.5 + i NaN)) = NaN plus maybe invalid exception",
3711 __real__ result, INVALID_EXCEPTION);
3712 check_isnan ("imag(casinh(10.5 + i NaN)) = NaN plus maybe invalid exception",
3713 __imag__ result);
3714 result = FUNC(casinh) (BUILD_COMPLEX (-10.5, nan_value));
3715 check_isnan_maybe_exc ("real(casinh(-10.5 + i NaN)) = NaN plus maybe invalid exception",
3716 __real__ result, INVALID_EXCEPTION);
3717 check_isnan ("imag(casinh(-10.5 + i NaN)) = NaN plus maybe invalid exception",
3718 __imag__ result);
3720 result = FUNC(casinh) (BUILD_COMPLEX (nan_value, 0.75));
3721 check_isnan_maybe_exc ("real(casinh(NaN + i0.75)) = NaN plus maybe invalid exception",
3722 __real__ result, INVALID_EXCEPTION);
3723 check_isnan ("imag(casinh(NaN + i0.75)) = NaN plus maybe invalid exception",
3724 __imag__ result);
3725 result = FUNC(casinh) (BUILD_COMPLEX (-0.75, nan_value));
3726 check_isnan_maybe_exc ("real(casinh(NaN - i0.75)) = NaN plus maybe invalid exception",
3727 __real__ result, INVALID_EXCEPTION);
3728 check_isnan ("imag(casinh(NaN - i0.75)) = NaN plus maybe invalid exception",
3729 __imag__ result);
3731 result = FUNC(casinh) (BUILD_COMPLEX (nan_value, nan_value));
3732 check_isnan ("real(casinh(NaN + i NaN)) = NaN", __real__ result);
3733 check_isnan ("imag(casinh(NaN + i NaN)) = NaN", __imag__ result);
3737 static void
3738 catan_test (void)
3740 __complex__ MATHTYPE result;
3742 result = FUNC(catan) (BUILD_COMPLEX (0, 0));
3743 check ("real(catan(0 + i0)) = 0", __real__ result, 0);
3744 check ("imag(catan(0 + i0)) = 0", __imag__ result, 0);
3745 result = FUNC(catan) (BUILD_COMPLEX (minus_zero, 0));
3746 check ("real(catan(-0 + i0)) = -0", __real__ result, minus_zero);
3747 check ("imag(catan(-0 + i0)) = 0", __imag__ result, 0);
3748 result = FUNC(catan) (BUILD_COMPLEX (0, minus_zero));
3749 check ("real(catan(0 - i0)) = 0", __real__ result, 0);
3750 check ("imag(catan(0 - i0)) = -0", __imag__ result, minus_zero);
3751 result = FUNC(catan) (BUILD_COMPLEX (minus_zero, minus_zero));
3752 check ("real(catan(-0 - i0)) = -0", __real__ result, minus_zero);
3753 check ("imag(catan(-0 - i0)) = -0", __imag__ result, minus_zero);
3755 result = FUNC(catan) (BUILD_COMPLEX (plus_infty, plus_infty));
3756 check ("real(catan(+Inf + i Inf)) = pi/2", __real__ result, M_PI_2);
3757 check ("imag(catan(+Inf + i Inf)) = 0", __imag__ result, 0);
3758 result = FUNC(catan) (BUILD_COMPLEX (plus_infty, minus_infty));
3759 check ("real(catan(+Inf - i Inf)) = pi/2", __real__ result, M_PI_2);
3760 check ("imag(catan(+Inf - i Inf)) = -0", __imag__ result, minus_zero);
3761 result = FUNC(catan) (BUILD_COMPLEX (minus_infty, plus_infty));
3762 check ("real(catan(-Inf + i Inf)) = -pi/2", __real__ result, -M_PI_2);
3763 check ("imag(catan(-Inf + i Inf)) = 0", __imag__ result, 0.0);
3764 result = FUNC(catan) (BUILD_COMPLEX (minus_infty, minus_infty));
3765 check ("real(catan(-Inf - i Inf)) = -pi/2", __real__ result, -M_PI_2);
3766 check ("imag(catan(-Inf - i Inf)) = -0", __imag__ result, minus_zero);
3768 result = FUNC(catan) (BUILD_COMPLEX (plus_infty, -10.0));
3769 check ("real(catan(+Inf - i10.0)) = pi/2", __real__ result, M_PI_2);
3770 check ("imag(catan(+Inf - i10.0)) = -0", __imag__ result, minus_zero);
3771 result = FUNC(catan) (BUILD_COMPLEX (minus_infty, -10.0));
3772 check ("real(catan(-Inf - i10.0)) = -pi/2", __real__ result, -M_PI_2);
3773 check ("imag(catan(-Inf - i10.0)) = -0", __imag__ result, minus_zero);
3774 result = FUNC(catan) (BUILD_COMPLEX (plus_infty, minus_zero));
3775 check ("real(catan(Inf - i0)) = pi/2", __real__ result, M_PI_2);
3776 check ("imag(catan(Inf - i0)) = -0", __imag__ result, minus_zero);
3777 result = FUNC(catan) (BUILD_COMPLEX (minus_infty, minus_zero));
3778 check ("real(catan(-Inf - i0)) = -pi/2", __real__ result, -M_PI_2);
3779 check ("imag(catan(-Inf - i0)) = -0", __imag__ result, minus_zero);
3780 result = FUNC(catan) (BUILD_COMPLEX (plus_infty, 0.0));
3781 check ("real(catan(Inf + i0)) = pi/2", __real__ result, M_PI_2);
3782 check ("imag(catan(Inf + i0)) = 0", __imag__ result, 0.0);
3783 result = FUNC(catan) (BUILD_COMPLEX (minus_infty, 0.0));
3784 check ("real(catan(-Inf + i0)) = -pi/2", __real__ result, -M_PI_2);
3785 check ("imag(catan(-Inf + i0)) = 0", __imag__ result, 0.0);
3786 result = FUNC(catan) (BUILD_COMPLEX (plus_infty, 0.1));
3787 check ("real(catan(+Inf + i0.1)) = pi/2", __real__ result, M_PI_2);
3788 check ("imag(catan(+Inf + i0.1)) = 0", __imag__ result, 0);
3789 result = FUNC(catan) (BUILD_COMPLEX (minus_infty, 0.1));
3790 check ("real(catan(-Inf + i0.1)) = -pi/2", __real__ result, -M_PI_2);
3791 check ("imag(catan(-Inf + i0.1)) = 0", __imag__ result, 0);
3793 result = FUNC(catan) (BUILD_COMPLEX (0.0, minus_infty));
3794 check ("real(catan(0 - i Inf)) = pi/2", __real__ result, M_PI_2);
3795 check ("imag(catan(0 - i Inf)) = -0", __imag__ result, minus_zero);
3796 result = FUNC(catan) (BUILD_COMPLEX (minus_zero, minus_infty));
3797 check ("real(catan(-0 - i Inf)) = -pi/2", __real__ result, -M_PI_2);
3798 check ("imag(catan(-0 - i Inf)) = -0", __imag__ result, minus_zero);
3799 result = FUNC(catan) (BUILD_COMPLEX (100.0, minus_infty));
3800 check ("real(catan(100 - i Inf)) = pi/2", __real__ result, M_PI_2);
3801 check ("imag(catan(100 - i Inf)) = -0", __imag__ result, minus_zero);
3802 result = FUNC(catan) (BUILD_COMPLEX (-100.0, minus_infty));
3803 check ("real(catan(-100 - i Inf)) = -pi/2", __real__ result, -M_PI_2);
3804 check ("imag(catan(-100 - i Inf)) = -0", __imag__ result, minus_zero);
3806 result = FUNC(catan) (BUILD_COMPLEX (0.0, plus_infty));
3807 check ("real(catan(0 + i Inf)) = pi/2", __real__ result, M_PI_2);
3808 check ("imag(catan(0 + i Inf)) = 0", __imag__ result, 0);
3809 result = FUNC(catan) (BUILD_COMPLEX (minus_zero, plus_infty));
3810 check ("real(catan(-0 + i Inf)) = -pi/2", __real__ result, -M_PI_2);
3811 check ("imag(catan(-0 + i Inf)) = 0", __imag__ result, 0);
3812 result = FUNC(catan) (BUILD_COMPLEX (0.5, plus_infty));
3813 check ("real(catan(0.5 + i Inf)) = pi/2", __real__ result, M_PI_2);
3814 check ("imag(catan(0.5 + i Inf)) = 0", __imag__ result, 0);
3815 result = FUNC(catan) (BUILD_COMPLEX (-0.5, plus_infty));
3816 check ("real(catan(-0.5 + i Inf)) = -pi/2", __real__ result, -M_PI_2);
3817 check ("imag(catan(-0.5 + i Inf)) = 0", __imag__ result, 0);
3819 result = FUNC(catan) (BUILD_COMPLEX (nan_value, 0.0));
3820 check_isnan ("real(catan(NaN + i0)) = NaN", __real__ result);
3821 check ("imag(catan(NaN + i0)) = 0", __imag__ result, 0.0);
3822 result = FUNC(catan) (BUILD_COMPLEX (nan_value, minus_zero));
3823 check_isnan ("real(catan(NaN - i0)) = NaN", __real__ result);
3824 check ("imag(catan(NaN - i0)) = -0", __imag__ result, minus_zero);
3826 result = FUNC(catan) (BUILD_COMPLEX (nan_value, plus_infty));
3827 check_isnan ("real(catan(NaN + i Inf)) = NaN", __real__ result);
3828 check ("imag(catan(NaN + i Inf)) = 0", __imag__ result, 0);
3829 result = FUNC(catan) (BUILD_COMPLEX (nan_value, minus_infty));
3830 check_isnan ("real(catan(NaN - i Inf)) = NaN", __real__ result);
3831 check ("imag(catan(NaN - i Inf)) = -0", __imag__ result, minus_zero);
3833 result = FUNC(catan) (BUILD_COMPLEX (0.0, nan_value));
3834 check_isnan ("real(catan(0 + i NaN)) = NaN", __real__ result);
3835 check_isnan ("imag(catan(0 + i NaN)) = NaN", __imag__ result);
3836 result = FUNC(catan) (BUILD_COMPLEX (minus_zero, nan_value));
3837 check_isnan ("real(catan(-0 + i NaN)) = NaN", __real__ result);
3838 check_isnan ("imag(catan(-0 + i NaN)) = NaN", __imag__ result);
3840 result = FUNC(catan) (BUILD_COMPLEX (plus_infty, nan_value));
3841 check ("real(catan(+Inf + i NaN)) = pi/2", __real__ result, M_PI_2);
3842 check ("imag(catan(+Inf + i NaN)) = +-0", FUNC(fabs) (__imag__ result), 0);
3843 result = FUNC(catan) (BUILD_COMPLEX (minus_infty, nan_value));
3844 check ("real(catan(-Inf + i NaN)) = -pi/2", __real__ result, -M_PI_2);
3845 check ("imag(catan(-Inf + i NaN)) = +-0", FUNC(fabs) (__imag__ result), 0);
3847 result = FUNC(catan) (BUILD_COMPLEX (nan_value, 10.5));
3848 check_isnan_maybe_exc ("real(catan(NaN + i10.5)) = NaN plus maybe invalid exception",
3849 __real__ result, INVALID_EXCEPTION);
3850 check_isnan ("imag(catan(NaN + i10.5)) = NaN plus maybe invalid exception",
3851 __imag__ result);
3852 result = FUNC(catan) (BUILD_COMPLEX (nan_value, -10.5));
3853 check_isnan_maybe_exc ("real(catan(NaN - i10.5)) = NaN plus maybe invalid exception",
3854 __real__ result, INVALID_EXCEPTION);
3855 check_isnan ("imag(catan(NaN - i10.5)) = NaN plus maybe invalid exception",
3856 __imag__ result);
3858 result = FUNC(catan) (BUILD_COMPLEX (0.75, nan_value));
3859 check_isnan_maybe_exc ("real(catan(0.75 + i NaN)) = NaN plus maybe invalid exception",
3860 __real__ result, INVALID_EXCEPTION);
3861 check_isnan ("imag(catan(0.75 + i NaN)) = NaN plus maybe invalid exception",
3862 __imag__ result);
3863 result = FUNC(catan) (BUILD_COMPLEX (-0.75, nan_value));
3864 check_isnan_maybe_exc ("real(catan(-0.75 + i NaN)) = NaN plus maybe invalid exception",
3865 __real__ result, INVALID_EXCEPTION);
3866 check_isnan ("imag(catan(-0.75 + i NaN)) = NaN plus maybe invalid exception",
3867 __imag__ result);
3869 result = FUNC(catan) (BUILD_COMPLEX (nan_value, nan_value));
3870 check_isnan ("real(catan(NaN + i NaN)) = NaN", __real__ result);
3871 check_isnan ("imag(catan(NaN + i NaN)) = NaN", __imag__ result);
3875 static void
3876 catanh_test (void)
3878 __complex__ MATHTYPE result;
3880 result = FUNC(catanh) (BUILD_COMPLEX (0, 0));
3881 check ("real(catanh(0 + i0)) = 0", __real__ result, 0);
3882 check ("imag(catanh(0 + i0)) = 0", __imag__ result, 0);
3883 result = FUNC(catanh) (BUILD_COMPLEX (minus_zero, 0));
3884 check ("real(catanh(-0 + i0)) = -0", __real__ result, minus_zero);
3885 check ("imag(catanh(-0 + i0)) = 0", __imag__ result, 0);
3886 result = FUNC(catanh) (BUILD_COMPLEX (0, minus_zero));
3887 check ("real(catanh(0 - i0)) = 0", __real__ result, 0);
3888 check ("imag(catanh(0 - i0)) = -0", __imag__ result, minus_zero);
3889 result = FUNC(catanh) (BUILD_COMPLEX (minus_zero, minus_zero));
3890 check ("real(catanh(-0 - i0)) = -0", __real__ result, minus_zero);
3891 check ("imag(catanh(-0 - i0)) = -0", __imag__ result, minus_zero);
3893 result = FUNC(catanh) (BUILD_COMPLEX (plus_infty, plus_infty));
3894 check ("real(catanh(+Inf + i Inf)) = 0", __real__ result, 0);
3895 check ("imag(catanh(+Inf + i Inf)) = pi/2", __imag__ result, M_PI_2);
3896 result = FUNC(catanh) (BUILD_COMPLEX (plus_infty, minus_infty));
3897 check ("real(catanh(+Inf - i Inf)) = 0", __real__ result, 0);
3898 check ("imag(catanh(+Inf - i Inf)) = -pi/2", __imag__ result, -M_PI_2);
3899 result = FUNC(catanh) (BUILD_COMPLEX (minus_infty, plus_infty));
3900 check ("real(catanh(-Inf + i Inf)) = -0", __real__ result, minus_zero);
3901 check ("imag(catanh(-Inf + i Inf)) = pi/2", __imag__ result, M_PI_2);
3902 result = FUNC(catanh) (BUILD_COMPLEX (minus_infty, minus_infty));
3903 check ("real(catanh(-Inf - i Inf)) = -0", __real__ result, minus_zero);
3904 check ("imag(catanh(-Inf - i Inf)) = -pi/2", __imag__ result, -M_PI_2);
3906 result = FUNC(catanh) (BUILD_COMPLEX (-10.0, plus_infty));
3907 check ("real(catanh(-10.0 + i Inf)) = -0", __real__ result, minus_zero);
3908 check ("imag(catanh(-10.0 + i Inf)) = pi/2", __imag__ result, M_PI_2);
3909 result = FUNC(catanh) (BUILD_COMPLEX (-10.0, minus_infty));
3910 check ("real(catanh(-10.0 - i Inf)) = -0", __real__ result, minus_zero);
3911 check ("imag(catanh(-10.0 - i Inf)) = -pi/2", __imag__ result, -M_PI_2);
3912 result = FUNC(catanh) (BUILD_COMPLEX (minus_zero, plus_infty));
3913 check ("real(catanh(-0 + i Inf)) = -0", __real__ result, minus_zero);
3914 check ("imag(catanh(-0 + i Inf)) = pi/2", __imag__ result, M_PI_2);
3915 result = FUNC(catanh) (BUILD_COMPLEX (minus_zero, minus_infty));
3916 check ("real(catanh(-0 - i Inf)) = -0", __real__ result, minus_zero);
3917 check ("imag(catanh(-0 - i Inf)) = -pi/2", __imag__ result, -M_PI_2);
3918 result = FUNC(catanh) (BUILD_COMPLEX (0, plus_infty));
3919 check ("real(catanh(0 + i Inf)) = 0", __real__ result, 0);
3920 check ("imag(catanh(0 + i Inf)) = pi/2", __imag__ result, M_PI_2);
3921 result = FUNC(catanh) (BUILD_COMPLEX (0, minus_infty));
3922 check ("real(catanh(0 - i Inf)) = 0", __real__ result, 0);
3923 check ("imag(catanh(0 - i Inf)) = -pi/2", __imag__ result, -M_PI_2);
3924 result = FUNC(catanh) (BUILD_COMPLEX (0.1, plus_infty));
3925 check ("real(catanh(0.1 + i Inf)) = 0", __real__ result, 0);
3926 check ("imag(catanh(0.1 + i Inf)) = pi/2", __imag__ result, M_PI_2);
3927 result = FUNC(catanh) (BUILD_COMPLEX (0.1, minus_infty));
3928 check ("real(catanh(0.1 - i Inf)) = 0", __real__ result, 0);
3929 check ("imag(catanh(0.1 - i Inf)) = -pi/2", __imag__ result, -M_PI_2);
3931 result = FUNC(catanh) (BUILD_COMPLEX (minus_infty, 0));
3932 check ("real(catanh(-Inf + i0)) = -0", __real__ result, minus_zero);
3933 check ("imag(catanh(-Inf + i0)) = pi/2", __imag__ result, M_PI_2);
3934 result = FUNC(catanh) (BUILD_COMPLEX (minus_infty, minus_zero));
3935 check ("real(catanh(-Inf - i0)) = -0", __real__ result, minus_zero);
3936 check ("imag(catanh(-Inf - i0)) = -pi/2", __imag__ result, -M_PI_2);
3937 result = FUNC(catanh) (BUILD_COMPLEX (minus_infty, 100));
3938 check ("real(catanh(-Inf + i100)) = -0", __real__ result, minus_zero);
3939 check ("imag(catanh(-Inf + i100)) = pi/2", __imag__ result, M_PI_2);
3940 result = FUNC(catanh) (BUILD_COMPLEX (minus_infty, -100));
3941 check ("real(catanh(-Inf - i100)) = -0", __real__ result, minus_zero);
3942 check ("imag(catanh(-Inf - i100)) = -pi/2", __imag__ result, -M_PI_2);
3944 result = FUNC(catanh) (BUILD_COMPLEX (plus_infty, 0));
3945 check ("real(catanh(+Inf + i0)) = 0", __real__ result, 0);
3946 check ("imag(catanh(+Inf + i0)) = pi/2", __imag__ result, M_PI_2);
3947 result = FUNC(catanh) (BUILD_COMPLEX (plus_infty, minus_zero));
3948 check ("real(catanh(+Inf - i0)) = 0", __real__ result, 0);
3949 check ("imag(catanh(+Inf - i0)) = -pi/2", __imag__ result, -M_PI_2);
3950 result = FUNC(catanh) (BUILD_COMPLEX (plus_infty, 0.5));
3951 check ("real(catanh(+Inf + i0.5)) = 0", __real__ result, 0);
3952 check ("imag(catanh(+Inf + i0.5)) = pi/2", __imag__ result, M_PI_2);
3953 result = FUNC(catanh) (BUILD_COMPLEX (plus_infty, -0.5));
3954 check ("real(catanh(+Inf - i0.5)) = 0", __real__ result, 0);
3955 check ("imag(catanh(+Inf - i0.5)) = -pi/2", __imag__ result, -M_PI_2);
3957 result = FUNC(catanh) (BUILD_COMPLEX (0, nan_value));
3958 check ("real(catanh(0 + i NaN)) = 0", __real__ result, 0);
3959 check_isnan ("imag(catanh(0 + i NaN)) = NaN", __imag__ result);
3960 result = FUNC(catanh) (BUILD_COMPLEX (minus_zero, nan_value));
3961 check ("real(catanh(-0 + i NaN)) = -0", __real__ result, minus_zero);
3962 check_isnan ("imag(catanh(-0 + i NaN)) = NaN", __imag__ result);
3964 result = FUNC(catanh) (BUILD_COMPLEX (plus_infty, nan_value));
3965 check ("real(catanh(+Inf + i NaN)) = 0", __real__ result, 0);
3966 check_isnan ("imag(catanh(+Inf + i NaN)) = NaN", __imag__ result);
3967 result = FUNC(catanh) (BUILD_COMPLEX (minus_infty, nan_value));
3968 check ("real(catanh(-Inf + i NaN)) = -0", __real__ result, minus_zero);
3969 check_isnan ("imag(catanh(-Inf + i NaN)) = NaN", __imag__ result);
3971 result = FUNC(catanh) (BUILD_COMPLEX (nan_value, 0));
3972 check_isnan ("real(catanh(NaN + i0)) = NaN", __real__ result);
3973 check_isnan ("imag(catanh(NaN + i0)) = NaN", __imag__ result);
3974 result = FUNC(catanh) (BUILD_COMPLEX (nan_value, minus_zero));
3975 check_isnan ("real(catanh(NaN - i0)) = NaN", __real__ result);
3976 check_isnan ("imag(catanh(NaN - i0)) = NaN", __imag__ result);
3978 result = FUNC(catanh) (BUILD_COMPLEX (nan_value, plus_infty));
3979 check ("real(catanh(NaN + i Inf)) = +-0", FUNC(fabs) (__real__ result), 0);
3980 check ("imag(catanh(NaN + i Inf)) = pi/2", __imag__ result, M_PI_2);
3981 result = FUNC(catanh) (BUILD_COMPLEX (nan_value, minus_infty));
3982 check ("real(catanh(NaN - i Inf)) = +-0", FUNC(fabs) (__real__ result), 0);
3983 check ("imag(catanh(NaN - i Inf)) = -pi/2", __imag__ result, -M_PI_2);
3985 result = FUNC(catanh) (BUILD_COMPLEX (10.5, nan_value));
3986 check_isnan_maybe_exc ("real(catanh(10.5 + i NaN)) = NaN plus maybe invalid exception",
3987 __real__ result, INVALID_EXCEPTION);
3988 check_isnan ("imag(catanh(10.5 + i NaN)) = NaN plus maybe invalid exception",
3989 __imag__ result);
3990 result = FUNC(catanh) (BUILD_COMPLEX (-10.5, nan_value));
3991 check_isnan_maybe_exc ("real(catanh(-10.5 + i NaN)) = NaN plus maybe invalid exception",
3992 __real__ result, INVALID_EXCEPTION);
3993 check_isnan ("imag(catanh(-10.5 + i NaN)) = NaN plus maybe invalid exception",
3994 __imag__ result);
3996 result = FUNC(catanh) (BUILD_COMPLEX (nan_value, 0.75));
3997 check_isnan_maybe_exc ("real(catanh(NaN + i0.75)) = NaN plus maybe invalid exception",
3998 __real__ result, INVALID_EXCEPTION);
3999 check_isnan ("imag(catanh(NaN + i0.75)) = NaN plus maybe invalid exception",
4000 __imag__ result);
4001 result = FUNC(catanh) (BUILD_COMPLEX (nan_value, -0.75));
4002 check_isnan_maybe_exc ("real(catanh(NaN - i0.75)) = NaN plus maybe invalid exception",
4003 __real__ result, INVALID_EXCEPTION);
4004 check_isnan ("imag(catanh(NaN - i0.75)) = NaN plus maybe invalid exception",
4005 __imag__ result);
4007 result = FUNC(catanh) (BUILD_COMPLEX (nan_value, nan_value));
4008 check_isnan ("real(catanh(NaN + i NaN)) = NaN", __real__ result);
4009 check_isnan ("imag(catanh(NaN + i NaN)) = NaN", __imag__ result);
4013 static void
4014 ctanh_test (void)
4016 __complex__ MATHTYPE result;
4018 result = FUNC(ctanh) (BUILD_COMPLEX (0, 0));
4019 check ("real(ctanh(0 + i0)) = 0", __real__ result, 0);
4020 check ("imag(ctanh(0 + i0)) = 0", __imag__ result, 0);
4021 result = FUNC(ctanh) (BUILD_COMPLEX (0, minus_zero));
4022 check ("real(ctanh(0 - i0)) = 0", __real__ result, 0);
4023 check ("imag(ctanh(0 - i0)) = -0", __imag__ result, minus_zero);
4024 result = FUNC(ctanh) (BUILD_COMPLEX (minus_zero, 0));
4025 check ("real(ctanh(-0 + i0)) = -0", __real__ result, minus_zero);
4026 check ("imag(ctanh(-0 + i0)) = 0", __imag__ result, 0);
4027 result = FUNC(ctanh) (BUILD_COMPLEX (minus_zero, minus_zero));
4028 check ("real(ctanh(-0 - i0)) = -0", __real__ result, minus_zero);
4029 check ("imag(ctanh(-0 - i0)) = -0", __imag__ result, minus_zero);
4031 result = FUNC(ctanh) (BUILD_COMPLEX (plus_infty, 0));
4032 check ("real(ctanh(+Inf + i0)) = 1", __real__ result, 1);
4033 check ("imag(ctanh(+Inf + i0)) = 0", __imag__ result, 0);
4034 result = FUNC(ctanh) (BUILD_COMPLEX (plus_infty, 1));
4035 check ("real(ctanh(+Inf + i1)) = 1", __real__ result, 1);
4036 check ("imag(ctanh(+Inf + i1)) = 0", __imag__ result, 0);
4037 result = FUNC(ctanh) (BUILD_COMPLEX (plus_infty, minus_zero));
4038 check ("real(ctanh(+Inf - i0)) = 1", __real__ result, 1);
4039 check ("imag(ctanh(+Inf - i0)) = -0", __imag__ result, minus_zero);
4040 result = FUNC(ctanh) (BUILD_COMPLEX (plus_infty, -1));
4041 check ("real(ctanh(+Inf - i1)) = 1", __real__ result, 1);
4042 check ("imag(ctanh(+Inf - i1)) = -0", __imag__ result, minus_zero);
4043 result = FUNC(ctanh) (BUILD_COMPLEX (minus_infty, 0));
4044 check ("real(ctanh(-Inf + i0)) = -1", __real__ result, -1);
4045 check ("imag(ctanh(-Inf + i0)) = 0", __imag__ result, 0);
4046 result = FUNC(ctanh) (BUILD_COMPLEX (minus_infty, 1));
4047 check ("real(ctanh(-Inf + i1)) = -1", __real__ result, -1);
4048 check ("imag(ctanh(-Inf + i1)) = 0", __imag__ result, 0);
4049 result = FUNC(ctanh) (BUILD_COMPLEX (minus_infty, minus_zero));
4050 check ("real(ctanh(-Inf - i0)) = -1", __real__ result, -1);
4051 check ("imag(ctanh(-Inf - i0)) = -0", __imag__ result, minus_zero);
4052 result = FUNC(ctanh) (BUILD_COMPLEX (minus_infty, -1));
4053 check ("real(ctanh(-Inf - i1)) = -1", __real__ result, -1);
4054 check ("imag(ctanh(-Inf - i1)) = -0", __imag__ result, minus_zero);
4056 result = FUNC(ctanh) (BUILD_COMPLEX (0, plus_infty));
4057 check_isnan_exc ("real(ctanh(0 + i Inf)) = NaN plus invalid exception",
4058 __real__ result, INVALID_EXCEPTION);
4059 check_isnan ("imag(ctanh(0 + i Inf)) = NaN plus invalid exception",
4060 __imag__ result);
4061 result = FUNC(ctanh) (BUILD_COMPLEX (2, plus_infty));
4062 check_isnan_exc ("real(ctanh(2 + i Inf)) = NaN plus invalid exception",
4063 __real__ result, INVALID_EXCEPTION);
4064 check_isnan ("imag(ctanh(2 + i Inf)) = NaN plus invalid exception",
4065 __imag__ result);
4066 result = FUNC(ctanh) (BUILD_COMPLEX (0, minus_infty));
4067 check_isnan_exc ("real(ctanh(0 - i Inf)) = NaN plus invalid exception",
4068 __real__ result, INVALID_EXCEPTION);
4069 check_isnan ("imag(ctanh(0 - i Inf)) = NaN plus invalid exception",
4070 __imag__ result);
4071 result = FUNC(ctanh) (BUILD_COMPLEX (2, minus_infty));
4072 check_isnan_exc ("real(ctanh(2 - i Inf)) = NaN plus invalid exception",
4073 __real__ result, INVALID_EXCEPTION);
4074 check_isnan ("imag(ctanh(2 - i Inf)) = NaN plus invalid exception",
4075 __imag__ result);
4076 result = FUNC(ctanh) (BUILD_COMPLEX (minus_zero, plus_infty));
4077 check_isnan_exc ("real(ctanh(-0 + i Inf)) = NaN plus invalid exception",
4078 __real__ result, INVALID_EXCEPTION);
4079 check_isnan ("imag(ctanh(-0 + i Inf)) = NaN plus invalid exception",
4080 __imag__ result);
4081 result = FUNC(ctanh) (BUILD_COMPLEX (-2, plus_infty));
4082 check_isnan_exc ("real(ctanh(-2 + i Inf)) = NaN plus invalid exception",
4083 __real__ result, INVALID_EXCEPTION);
4084 check_isnan ("imag(ctanh(-2 + i Inf)) = NaN plus invalid exception",
4085 __imag__ result);
4086 result = FUNC(ctanh) (BUILD_COMPLEX (minus_zero, minus_infty));
4087 check_isnan_exc ("real(ctanh(-0 - i Inf)) = NaN plus invalid exception",
4088 __real__ result, INVALID_EXCEPTION);
4089 check_isnan ("imag(ctanh(-0 - i Inf)) = NaN plus invalid exception",
4090 __imag__ result);
4091 result = FUNC(ctanh) (BUILD_COMPLEX (-2, minus_infty));
4092 check_isnan_exc ("real(ctanh(-2 - i Inf)) = NaN plus invalid exception",
4093 __real__ result, INVALID_EXCEPTION);
4094 check_isnan ("imag(ctanh(-2 - i Inf)) = NaN plus invalid exception",
4095 __imag__ result);
4097 result = FUNC(ctanh) (BUILD_COMPLEX (plus_infty, nan_value));
4098 check ("real(ctanh(+Inf + i NaN)) = 1", __real__ result, 1);
4099 check ("imag(ctanh(+Inf + i NaN)) = +-0", FUNC(fabs) (__imag__ result), 0);
4100 result = FUNC(ctanh) (BUILD_COMPLEX (minus_infty, nan_value));
4101 check ("real(ctanh(-Inf + i NaN)) = -1", __real__ result, -1);
4102 check ("imag(ctanh(-Inf + i NaN)) = +-0", FUNC(fabs) (__imag__ result), 0);
4104 result = FUNC(ctanh) (BUILD_COMPLEX (nan_value, 0));
4105 check_isnan ("real(ctanh(NaN + i0)) = NaN", __real__ result);
4106 check ("imag(ctanh(NaN + i0)) = 0", __imag__ result, 0);
4107 result = FUNC(ctanh) (BUILD_COMPLEX (nan_value, minus_zero));
4108 check_isnan ("real(ctanh(NaN - i0)) = NaN", __real__ result);
4109 check ("imag(ctanh(NaN - i0)) = -0", __imag__ result, minus_zero);
4111 result = FUNC(ctanh) (BUILD_COMPLEX (nan_value, 0.5));
4112 check_isnan_maybe_exc ("real(ctanh(NaN + i0.5)) = NaN plus maybe invalid exception",
4113 __real__ result, INVALID_EXCEPTION);
4114 check_isnan ("imag(ctanh(NaN + i0.5)) = NaN plus maybe invalid exception",
4115 __imag__ result);
4116 result = FUNC(ctanh) (BUILD_COMPLEX (nan_value, -4.5));
4117 check_isnan_maybe_exc ("real(ctanh(NaN - i4.5)) = NaN plus maybe invalid exception",
4118 __real__ result, INVALID_EXCEPTION);
4119 check_isnan ("imag(ctanh(NaN - i4.5)) = NaN plus maybe invalid exception",
4120 __imag__ result);
4122 result = FUNC(ctanh) (BUILD_COMPLEX (0, nan_value));
4123 check_isnan_maybe_exc ("real(ctanh(0 + i NaN)) = NaN plus maybe invalid exception",
4124 __real__ result, INVALID_EXCEPTION);
4125 check_isnan ("imag(ctanh(0 + i NaN)) = NaN plus maybe invalid exception",
4126 __imag__ result);
4127 result = FUNC(ctanh) (BUILD_COMPLEX (5, nan_value));
4128 check_isnan_maybe_exc ("real(ctanh(5 + i NaN)) = NaN plus maybe invalid exception",
4129 __real__ result, INVALID_EXCEPTION);
4130 check_isnan ("imag(ctanh(5 + i NaN)) = NaN plus maybe invalid exception",
4131 __imag__ result);
4132 result = FUNC(ctanh) (BUILD_COMPLEX (minus_zero, nan_value));
4133 check_isnan_maybe_exc ("real(ctanh(-0 + i NaN)) = NaN plus maybe invalid exception",
4134 __real__ result, INVALID_EXCEPTION);
4135 check_isnan ("imag(ctanh(-0 + i NaN)) = NaN plus maybe invalid exception",
4136 __imag__ result);
4137 result = FUNC(ctanh) (BUILD_COMPLEX (-0.25, nan_value));
4138 check_isnan_maybe_exc ("real(ctanh(-0.25 + i NaN)) = NaN plus maybe invalid exception",
4139 __real__ result, INVALID_EXCEPTION);
4140 check_isnan ("imag(ctanh(-0.25 + i NaN)) = NaN plus maybe invalid exception",
4141 __imag__ result);
4143 result = FUNC(ctanh) (BUILD_COMPLEX (nan_value, nan_value));
4144 check_isnan ("real(ctanh(NaN + i NaN)) = NaN", __real__ result);
4145 check_isnan ("imag(ctanh(NaN + i NaN)) = NaN", __imag__ result);
4149 static void
4150 clog_test (void)
4152 __complex__ MATHTYPE result;
4154 result = FUNC(clog) (BUILD_COMPLEX (minus_zero, 0));
4155 check_isinfn_exc ("real(clog(-0 + i0)) = -Inf plus divide-by-zero exception",
4156 __real__ result, DIVIDE_BY_ZERO_EXCEPTION);
4157 check ("imag(clog(-0 + i0)) = pi plus divide-by-zero exception",
4158 __imag__ result, M_PI);
4159 result = FUNC(clog) (BUILD_COMPLEX (minus_zero, minus_zero));
4160 check_isinfn_exc ("real(clog(-0 - i0)) = -Inf plus divide-by-zero exception",
4161 __real__ result, DIVIDE_BY_ZERO_EXCEPTION);
4162 check ("imag(clog(-0 - i0)) = -pi plus divide-by-zero exception",
4163 __imag__ result, -M_PI);
4165 result = FUNC(clog) (BUILD_COMPLEX (0, 0));
4166 check_isinfn_exc ("real(clog(0 + i0)) = -Inf plus divide-by-zero exception",
4167 __real__ result, DIVIDE_BY_ZERO_EXCEPTION);
4168 check ("imag(clog(0 + i0)) = 0 plus divide-by-zero exception",
4169 __imag__ result, 0);
4170 result = FUNC(clog) (BUILD_COMPLEX (0, minus_zero));
4171 check_isinfn_exc ("real(clog(0 - i0)) = -Inf plus divide-by-zero exception",
4172 __real__ result, DIVIDE_BY_ZERO_EXCEPTION);
4173 check ("imag(clog(0 - i0)) = -0 plus divide-by-zero exception",
4174 __imag__ result, minus_zero);
4176 result = FUNC(clog) (BUILD_COMPLEX (minus_infty, plus_infty));
4177 check_isinfp ("real(clog(-Inf + i Inf)) = +Inf", __real__ result);
4178 check ("imag(clog(-Inf + i Inf)) = 3*pi/4", __imag__ result, M_PI - M_PI_4);
4179 result = FUNC(clog) (BUILD_COMPLEX (minus_infty, minus_infty));
4180 check_isinfp ("real(clog(-Inf - i Inf)) = +Inf", __real__ result);
4181 check ("imag(clog(-Inf - i Inf)) = -3*pi/4", __imag__ result, M_PI_4 - M_PI);
4183 result = FUNC(clog) (BUILD_COMPLEX (plus_infty, plus_infty));
4184 check_isinfp ("real(clog(+Inf + i Inf)) = +Inf", __real__ result);
4185 check ("imag(clog(+Inf + i Inf)) = pi/4", __imag__ result, M_PI_4);
4186 result = FUNC(clog) (BUILD_COMPLEX (plus_infty, minus_infty));
4187 check_isinfp ("real(clog(+Inf - i Inf)) = +Inf", __real__ result);
4188 check ("imag(clog(+Inf - i Inf)) = -pi/4", __imag__ result, -M_PI_4);
4190 result = FUNC(clog) (BUILD_COMPLEX (0, plus_infty));
4191 check_isinfp ("real(clog(0 + i Inf)) = +Inf", __real__ result);
4192 check ("imag(clog(0 + i Inf)) = pi/2", __imag__ result, M_PI_2);
4193 result = FUNC(clog) (BUILD_COMPLEX (3, plus_infty));
4194 check_isinfp ("real(clog(3 + i Inf)) = +Inf", __real__ result);
4195 check ("imag(clog(3 + i Inf)) = pi/2", __imag__ result, M_PI_2);
4196 result = FUNC(clog) (BUILD_COMPLEX (minus_zero, plus_infty));
4197 check_isinfp ("real(clog(-0 + i Inf)) = +Inf", __real__ result);
4198 check ("imag(clog(-0 + i Inf)) = pi/2", __imag__ result, M_PI_2);
4199 result = FUNC(clog) (BUILD_COMPLEX (-3, plus_infty));
4200 check_isinfp ("real(clog(-3 + i Inf)) = +Inf", __real__ result);
4201 check ("imag(clog(-3 + i Inf)) = pi/2", __imag__ result, M_PI_2);
4202 result = FUNC(clog) (BUILD_COMPLEX (0, minus_infty));
4203 check_isinfp ("real(clog(0 - i Inf)) = +Inf", __real__ result);
4204 check ("imag(clog(0 - i Inf)) = -pi/2", __imag__ result, -M_PI_2);
4205 result = FUNC(clog) (BUILD_COMPLEX (3, minus_infty));
4206 check_isinfp ("real(clog(3 - i Inf)) = +Inf", __real__ result);
4207 check ("imag(clog(3 - i Inf)) = -pi/2", __imag__ result, -M_PI_2);
4208 result = FUNC(clog) (BUILD_COMPLEX (minus_zero, minus_infty));
4209 check_isinfp ("real(clog(-0 - i Inf)) = +Inf", __real__ result);
4210 check ("imag(clog(-0 - i Inf)) = -pi/2", __imag__ result, -M_PI_2);
4211 result = FUNC(clog) (BUILD_COMPLEX (-3, minus_infty));
4212 check_isinfp ("real(clog(-3 - i Inf)) = +Inf", __real__ result);
4213 check ("imag(clog(-3 - i Inf)) = -pi/2", __imag__ result, -M_PI_2);
4215 result = FUNC(clog) (BUILD_COMPLEX (minus_infty, 0));
4216 check_isinfp ("real(clog(-Inf + i0)) = +Inf", __real__ result);
4217 check ("imag(clog(-Inf + i0)) = pi", __imag__ result, M_PI);
4218 result = FUNC(clog) (BUILD_COMPLEX (minus_infty, 1));
4219 check_isinfp ("real(clog(-Inf + i1)) = +Inf", __real__ result);
4220 check ("imag(clog(-Inf + i1)) = pi", __imag__ result, M_PI);
4221 result = FUNC(clog) (BUILD_COMPLEX (minus_infty, minus_zero));
4222 check_isinfp ("real(clog(-Inf - i0)) = +Inf", __real__ result);
4223 check ("imag(clog(-Inf - i0)) = -pi", __imag__ result, -M_PI);
4224 result = FUNC(clog) (BUILD_COMPLEX (minus_infty, -1));
4225 check_isinfp ("real(clog(-Inf - i1)) = +Inf", __real__ result);
4226 check ("imag(clog(-Inf - i1)) = -pi", __imag__ result, -M_PI);
4228 result = FUNC(clog) (BUILD_COMPLEX (plus_infty, 0));
4229 check_isinfp ("real(clog(+Inf + i0)) = +Inf", __real__ result);
4230 check ("imag(clog(+Inf + i0)) = 0", __imag__ result, 0);
4231 result = FUNC(clog) (BUILD_COMPLEX (plus_infty, 1));
4232 check_isinfp ("real(clog(+Inf + i1)) = +Inf", __real__ result);
4233 check ("imag(clog(+Inf + i1)) = 0", __imag__ result, 0);
4234 result = FUNC(clog) (BUILD_COMPLEX (plus_infty, minus_zero));
4235 check_isinfp ("real(clog(+Inf - i0)) = +Inf", __real__ result);
4236 check ("imag(clog(+Inf - i0)) = -0", __imag__ result, minus_zero);
4237 result = FUNC(clog) (BUILD_COMPLEX (plus_infty, -1));
4238 check_isinfp ("real(clog(+Inf - i1)) = +Inf", __real__ result);
4239 check ("imag(clog(+Inf - i1)) = -0", __imag__ result, minus_zero);
4241 result = FUNC(clog) (BUILD_COMPLEX (plus_infty, nan_value));
4242 check_isinfp ("real(clog(+Inf + i NaN)) = +Inf", __real__ result);
4243 check_isnan ("imag(clog(+Inf + i NaN)) = NaN", __imag__ result);
4244 result = FUNC(clog) (BUILD_COMPLEX (minus_infty, nan_value));
4245 check_isinfp ("real(clog(-Inf + i NaN)) = +Inf", __real__ result);
4246 check_isnan ("imag(clog(-Inf + i NaN)) = NaN", __imag__ result);
4248 result = FUNC(clog) (BUILD_COMPLEX (nan_value, plus_infty));
4249 check_isinfp ("real(clog(NaN + i Inf)) = +Inf", __real__ result);
4250 check_isnan ("imag(clog(NaN + i Inf)) = NaN", __imag__ result);
4251 result = FUNC(clog) (BUILD_COMPLEX (nan_value, minus_infty));
4252 check_isinfp ("real(clog(NaN - i Inf)) = +Inf", __real__ result);
4253 check_isnan ("imag(clog(NaN - i Inf)) = NaN", __imag__ result);
4255 result = FUNC(clog) (BUILD_COMPLEX (0, nan_value));
4256 check_isnan_maybe_exc ("real(clog(0 + i NaN)) = NaN plus maybe invalid exception",
4257 __real__ result, INVALID_EXCEPTION);
4258 check_isnan ("imag(clog(0 + i NaN)) = NaN plus maybe invalid exception",
4259 __imag__ result);
4260 result = FUNC(clog) (BUILD_COMPLEX (3, nan_value));
4261 check_isnan_maybe_exc ("real(clog(3 + i NaN)) = NaN plus maybe invalid exception",
4262 __real__ result, INVALID_EXCEPTION);
4263 check_isnan ("imag(clog(3 + i NaN)) = NaN plus maybe invalid exception",
4264 __imag__ result);
4265 result = FUNC(clog) (BUILD_COMPLEX (minus_zero, nan_value));
4266 check_isnan_maybe_exc ("real(clog(-0 + i NaN)) = NaN plus maybe invalid exception",
4267 __real__ result, INVALID_EXCEPTION);
4268 check_isnan ("imag(clog(-0 + i NaN)) = NaN plus maybe invalid exception",
4269 __imag__ result);
4270 result = FUNC(clog) (BUILD_COMPLEX (-3, nan_value));
4271 check_isnan_maybe_exc ("real(clog(-3 + i NaN)) = NaN plus maybe invalid exception",
4272 __real__ result, INVALID_EXCEPTION);
4273 check_isnan ("imag(clog(-3 + i NaN)) = NaN plus maybe invalid exception",
4274 __imag__ result);
4276 result = FUNC(clog) (BUILD_COMPLEX (nan_value, 0));
4277 check_isnan_maybe_exc ("real(clog(NaN + i0)) = NaN plus maybe invalid exception",
4278 __real__ result, INVALID_EXCEPTION);
4279 check_isnan ("imag(clog(NaN + i0)) = NaN plus maybe invalid exception",
4280 __imag__ result);
4281 result = FUNC(clog) (BUILD_COMPLEX (nan_value, 5));
4282 check_isnan_maybe_exc ("real(clog(NaN + i5)) = NaN plus maybe invalid exception",
4283 __real__ result, INVALID_EXCEPTION);
4284 check_isnan ("imag(clog(NaN + i5)) = NaN plus maybe invalid exception",
4285 __imag__ result);
4286 result = FUNC(clog) (BUILD_COMPLEX (nan_value, minus_zero));
4287 check_isnan_maybe_exc ("real(clog(NaN - i0)) = NaN plus maybe invalid exception",
4288 __real__ result, INVALID_EXCEPTION);
4289 check_isnan ("imag(clog(NaN - i0)) = NaN plus maybe invalid exception",
4290 __imag__ result);
4291 result = FUNC(clog) (BUILD_COMPLEX (nan_value, -5));
4292 check_isnan_maybe_exc ("real(clog(NaN - i5)) = NaN plus maybe invalid exception",
4293 __real__ result, INVALID_EXCEPTION);
4294 check_isnan ("imag(clog(NaN - i5)) = NaN plus maybe invalid exception",
4295 __imag__ result);
4297 result = FUNC(clog) (BUILD_COMPLEX (nan_value, nan_value));
4298 check_isnan ("real(clog(NaN + i NaN)) = NaN", __real__ result);
4299 check_isnan ("imag(clog(NaN + i NaN)) = NaN", __imag__ result);
4303 static void
4304 clog10_test (void)
4306 __complex__ MATHTYPE result;
4308 result = FUNC(clog10) (BUILD_COMPLEX (minus_zero, 0));
4309 check_isinfn_exc ("real(clog10(-0 + i0)) = -Inf plus divide-by-zero exception",
4310 __real__ result, DIVIDE_BY_ZERO_EXCEPTION);
4311 check ("imag(clog10(-0 + i0)) = pi plus divide-by-zero exception",
4312 __imag__ result, M_PI);
4313 result = FUNC(clog10) (BUILD_COMPLEX (minus_zero, minus_zero));
4314 check_isinfn_exc ("real(clog10(-0 - i0)) = -Inf plus divide-by-zero exception",
4315 __real__ result, DIVIDE_BY_ZERO_EXCEPTION);
4316 check ("imag(clog10(-0 - i0)) = -pi plus divide-by-zero exception",
4317 __imag__ result, -M_PI);
4319 result = FUNC(clog10) (BUILD_COMPLEX (0, 0));
4320 check_isinfn_exc ("real(clog10(0 + i0)) = -Inf plus divide-by-zero exception",
4321 __real__ result, DIVIDE_BY_ZERO_EXCEPTION);
4322 check ("imag(clog10(0 + i0)) = 0 plus divide-by-zero exception",
4323 __imag__ result, 0);
4324 result = FUNC(clog10) (BUILD_COMPLEX (0, minus_zero));
4325 check_isinfn_exc ("real(clog10(0 - i0)) = -Inf plus divide-by-zero exception",
4326 __real__ result, DIVIDE_BY_ZERO_EXCEPTION);
4327 check ("imag(clog10(0 - i0)) = -0 plus divide-by-zero exception",
4328 __imag__ result, minus_zero);
4330 result = FUNC(clog10) (BUILD_COMPLEX (minus_infty, plus_infty));
4331 check_isinfp ("real(clog10(-Inf + i Inf)) = +Inf", __real__ result);
4332 check ("imag(clog10(-Inf + i Inf)) = 3*pi/4", __imag__ result, M_PI - M_PI_4);
4333 result = FUNC(clog10) (BUILD_COMPLEX (minus_infty, minus_infty));
4334 check_isinfp ("real(clog10(-Inf - i Inf)) = +Inf", __real__ result);
4335 check ("imag(clog10(-Inf - i Inf)) = -3*pi/4", __imag__ result, M_PI_4 - M_PI);
4337 result = FUNC(clog10) (BUILD_COMPLEX (plus_infty, plus_infty));
4338 check_isinfp ("real(clog10(+Inf + i Inf)) = +Inf", __real__ result);
4339 check ("imag(clog10(+Inf + i Inf)) = pi/4", __imag__ result, M_PI_4);
4340 result = FUNC(clog10) (BUILD_COMPLEX (plus_infty, minus_infty));
4341 check_isinfp ("real(clog10(+Inf - i Inf)) = +Inf", __real__ result);
4342 check ("imag(clog10(+Inf - i Inf)) = -pi/4", __imag__ result, -M_PI_4);
4344 result = FUNC(clog10) (BUILD_COMPLEX (0, plus_infty));
4345 check_isinfp ("real(clog10(0 + i Inf)) = +Inf", __real__ result);
4346 check ("imag(clog10(0 + i Inf)) = pi/2", __imag__ result, M_PI_2);
4347 result = FUNC(clog10) (BUILD_COMPLEX (3, plus_infty));
4348 check_isinfp ("real(clog10(3 + i Inf)) = +Inf", __real__ result);
4349 check ("imag(clog10(3 + i Inf)) = pi/2", __imag__ result, M_PI_2);
4350 result = FUNC(clog10) (BUILD_COMPLEX (minus_zero, plus_infty));
4351 check_isinfp ("real(clog10(-0 + i Inf)) = +Inf", __real__ result);
4352 check ("imag(clog10(-0 + i Inf)) = pi/2", __imag__ result, M_PI_2);
4353 result = FUNC(clog10) (BUILD_COMPLEX (-3, plus_infty));
4354 check_isinfp ("real(clog10(-3 + i Inf)) = +Inf", __real__ result);
4355 check ("imag(clog10(-3 + i Inf)) = pi/2", __imag__ result, M_PI_2);
4356 result = FUNC(clog10) (BUILD_COMPLEX (0, minus_infty));
4357 check_isinfp ("real(clog10(0 - i Inf)) = +Inf", __real__ result);
4358 check ("imag(clog10(0 - i Inf)) = -pi/2", __imag__ result, -M_PI_2);
4359 result = FUNC(clog10) (BUILD_COMPLEX (3, minus_infty));
4360 check_isinfp ("real(clog10(3 - i Inf)) = +Inf", __real__ result);
4361 check ("imag(clog10(3 - i Inf)) = -pi/2", __imag__ result, -M_PI_2);
4362 result = FUNC(clog10) (BUILD_COMPLEX (minus_zero, minus_infty));
4363 check_isinfp ("real(clog10(-0 - i Inf)) = +Inf", __real__ result);
4364 check ("imag(clog10(-0 - i Inf)) = -pi/2", __imag__ result, -M_PI_2);
4365 result = FUNC(clog10) (BUILD_COMPLEX (-3, minus_infty));
4366 check_isinfp ("real(clog10(-3 - i Inf)) = +Inf", __real__ result);
4367 check ("imag(clog10(-3 - i Inf)) = -pi/2", __imag__ result, -M_PI_2);
4369 result = FUNC(clog10) (BUILD_COMPLEX (minus_infty, 0));
4370 check_isinfp ("real(clog10(-Inf + i0)) = +Inf", __real__ result);
4371 check ("imag(clog10(-Inf + i0)) = pi", __imag__ result, M_PI);
4372 result = FUNC(clog10) (BUILD_COMPLEX (minus_infty, 1));
4373 check_isinfp ("real(clog10(-Inf + i1)) = +Inf", __real__ result);
4374 check ("imag(clog10(-Inf + i1)) = pi", __imag__ result, M_PI);
4375 result = FUNC(clog10) (BUILD_COMPLEX (minus_infty, minus_zero));
4376 check_isinfp ("real(clog10(-Inf - i0)) = +Inf", __real__ result);
4377 check ("imag(clog10(-Inf - i0)) = -pi", __imag__ result, -M_PI);
4378 result = FUNC(clog10) (BUILD_COMPLEX (minus_infty, -1));
4379 check_isinfp ("real(clog10(-Inf - i1)) = +Inf", __real__ result);
4380 check ("imag(clog10(-Inf - i1)) = -pi", __imag__ result, -M_PI);
4382 result = FUNC(clog10) (BUILD_COMPLEX (plus_infty, 0));
4383 check_isinfp ("real(clog10(+Inf + i0)) = +Inf", __real__ result);
4384 check ("imag(clog10(+Inf + i0)) = 0", __imag__ result, 0);
4385 result = FUNC(clog10) (BUILD_COMPLEX (plus_infty, 1));
4386 check_isinfp ("real(clog10(+Inf + i1)) = +Inf", __real__ result);
4387 check ("imag(clog10(+Inf + i1)) = 0", __imag__ result, 0);
4388 result = FUNC(clog10) (BUILD_COMPLEX (plus_infty, minus_zero));
4389 check_isinfp ("real(clog10(+Inf - i0)) = +Inf", __real__ result);
4390 check ("imag(clog10(+Inf - i0)) = -0", __imag__ result, minus_zero);
4391 result = FUNC(clog10) (BUILD_COMPLEX (plus_infty, -1));
4392 check_isinfp ("real(clog10(+Inf - i1)) = +Inf", __real__ result);
4393 check ("imag(clog10(+Inf - i1)) = -0", __imag__ result, minus_zero);
4395 result = FUNC(clog10) (BUILD_COMPLEX (plus_infty, nan_value));
4396 check_isinfp ("real(clog10(+Inf + i NaN)) = +Inf", __real__ result);
4397 check_isnan ("imag(clog10(+Inf + i NaN)) = NaN", __imag__ result);
4398 result = FUNC(clog10) (BUILD_COMPLEX (minus_infty, nan_value));
4399 check_isinfp ("real(clog10(-Inf + i NaN)) = +Inf", __real__ result);
4400 check_isnan ("imag(clog10(-Inf + i NaN)) = NaN", __imag__ result);
4402 result = FUNC(clog10) (BUILD_COMPLEX (nan_value, plus_infty));
4403 check_isinfp ("real(clog10(NaN + i Inf)) = +Inf", __real__ result);
4404 check_isnan ("imag(clog10(NaN + i Inf)) = NaN", __imag__ result);
4405 result = FUNC(clog10) (BUILD_COMPLEX (nan_value, minus_infty));
4406 check_isinfp ("real(clog10(NaN - i Inf)) = +Inf", __real__ result);
4407 check_isnan ("imag(clog10(NaN - i Inf)) = NaN", __imag__ result);
4409 result = FUNC(clog10) (BUILD_COMPLEX (0, nan_value));
4410 check_isnan_maybe_exc ("real(clog10(0 + i NaN)) = NaN plus maybe invalid exception",
4411 __real__ result, INVALID_EXCEPTION);
4412 check_isnan ("imag(clog10(0 + i NaN)) = NaN plus maybe invalid exception",
4413 __imag__ result);
4414 result = FUNC(clog10) (BUILD_COMPLEX (3, nan_value));
4415 check_isnan_maybe_exc ("real(clog10(3 + i NaN)) = NaN plus maybe invalid exception",
4416 __real__ result, INVALID_EXCEPTION);
4417 check_isnan ("imag(clog10(3 + i NaN)) = NaN plus maybe invalid exception",
4418 __imag__ result);
4419 result = FUNC(clog10) (BUILD_COMPLEX (minus_zero, nan_value));
4420 check_isnan_maybe_exc ("real(clog10(-0 + i NaN)) = NaN plus maybe invalid exception",
4421 __real__ result, INVALID_EXCEPTION);
4422 check_isnan ("imag(clog10(-0 + i NaN)) = NaN plus maybe invalid exception",
4423 __imag__ result);
4424 result = FUNC(clog10) (BUILD_COMPLEX (-3, nan_value));
4425 check_isnan_maybe_exc ("real(clog10(-3 + i NaN)) = NaN plus maybe invalid exception",
4426 __real__ result, INVALID_EXCEPTION);
4427 check_isnan ("imag(clog10(-3 + i NaN)) = NaN plus maybe invalid exception",
4428 __imag__ result);
4430 result = FUNC(clog10) (BUILD_COMPLEX (nan_value, 0));
4431 check_isnan_maybe_exc ("real(clog10(NaN + i0)) = NaN plus maybe invalid exception",
4432 __real__ result, INVALID_EXCEPTION);
4433 check_isnan ("imag(clog10(NaN + i0)) = NaN plus maybe invalid exception",
4434 __imag__ result);
4435 result = FUNC(clog10) (BUILD_COMPLEX (nan_value, 5));
4436 check_isnan_maybe_exc ("real(clog10(NaN + i5)) = NaN plus maybe invalid exception",
4437 __real__ result, INVALID_EXCEPTION);
4438 check_isnan ("imag(clog10(NaN + i5)) = NaN plus maybe invalid exception",
4439 __imag__ result);
4440 result = FUNC(clog10) (BUILD_COMPLEX (nan_value, minus_zero));
4441 check_isnan_maybe_exc ("real(clog10(NaN - i0)) = NaN plus maybe invalid exception",
4442 __real__ result, INVALID_EXCEPTION);
4443 check_isnan ("imag(clog10(NaN - i0)) = NaN plus maybe invalid exception",
4444 __imag__ result);
4445 result = FUNC(clog10) (BUILD_COMPLEX (nan_value, -5));
4446 check_isnan_maybe_exc ("real(clog10(NaN - i5)) = NaN plus maybe invalid exception",
4447 __real__ result, INVALID_EXCEPTION);
4448 check_isnan ("imag(clog10(NaN - i5)) = NaN plus maybe invalid exception",
4449 __imag__ result);
4451 result = FUNC(clog10) (BUILD_COMPLEX (nan_value, nan_value));
4452 check_isnan ("real(clog10(NaN + i NaN)) = NaN", __real__ result);
4453 check_isnan ("imag(clog10(NaN + i NaN)) = NaN", __imag__ result);
4457 static void
4458 csqrt_test (void)
4460 __complex__ MATHTYPE result;
4462 result = FUNC(csqrt) (BUILD_COMPLEX (0, 0));
4463 check ("real(csqrt(0 + i0)) = 0", __real__ result, 0);
4464 check ("imag(csqrt(0 + i0)) = 0", __imag__ result, 0);
4465 result = FUNC(csqrt) (BUILD_COMPLEX (0, minus_zero));
4466 check ("real(csqrt(0 - i0)) = 0", __real__ result, 0);
4467 check ("imag(csqrt(0 - i0)) = -0", __imag__ result, minus_zero);
4468 result = FUNC(csqrt) (BUILD_COMPLEX (minus_zero, 0));
4469 check ("real(csqrt(-0 + i0)) = 0", __real__ result, 0);
4470 check ("imag(csqrt(-0 + i0)) = 0", __imag__ result, 0);
4471 result = FUNC(csqrt) (BUILD_COMPLEX (minus_zero, minus_zero));
4472 check ("real(csqrt(-0 - i0)) = 0", __real__ result, 0);
4473 check ("imag(csqrt(-0 - i0)) = -0", __imag__ result, minus_zero);
4475 result = FUNC(csqrt) (BUILD_COMPLEX (minus_infty, 0));
4476 check ("real(csqrt(-Inf + i0)) = 0", __real__ result, 0);
4477 check_isinfp ("imag(csqrt(-Inf + i0)) = +Inf", __imag__ result);
4478 result = FUNC(csqrt) (BUILD_COMPLEX (minus_infty, 6));
4479 check ("real(csqrt(-Inf + i6)) = 0", __real__ result, 0);
4480 check_isinfp ("imag(csqrt(-Inf + i6)) = +Inf", __imag__ result);
4481 result = FUNC(csqrt) (BUILD_COMPLEX (minus_infty, minus_zero));
4482 check ("real(csqrt(-Inf - i0)) = 0", __real__ result, 0);
4483 check_isinfn ("imag(csqrt(-Inf - i0)) = -Inf", __imag__ result);
4484 result = FUNC(csqrt) (BUILD_COMPLEX (minus_infty, -6));
4485 check ("real(csqrt(-Inf - i6)) = 0", __real__ result, 0);
4486 check_isinfn ("imag(csqrt(-Inf - i6)) = -Inf", __imag__ result);
4488 result = FUNC(csqrt) (BUILD_COMPLEX (plus_infty, 0));
4489 check_isinfp ("real(csqrt(+Inf + i0)) = +Inf", __real__ result);
4490 check ("imag(csqrt(+Inf + i0)) = 0", __imag__ result, 0);
4491 result = FUNC(csqrt) (BUILD_COMPLEX (plus_infty, 6));
4492 check_isinfp ("real(csqrt(+Inf + i6)) = +Inf", __real__ result);
4493 check ("imag(csqrt(+Inf + i6)) = 0", __imag__ result, 0);
4494 result = FUNC(csqrt) (BUILD_COMPLEX (plus_infty, minus_zero));
4495 check_isinfp ("real(csqrt(+Inf - i0)) = +Inf", __real__ result);
4496 check ("imag(csqrt(+Inf - i0)) = -0", __imag__ result, minus_zero);
4497 result = FUNC(csqrt) (BUILD_COMPLEX (plus_infty, -6));
4498 check_isinfp ("real(csqrt(+Inf - i6)) = +Inf", __real__ result);
4499 check ("imag(csqrt(+Inf - i6)) = -0", __imag__ result, minus_zero);
4501 result = FUNC(csqrt) (BUILD_COMPLEX (0, plus_infty));
4502 check_isinfp ("real(csqrt(0 + i Inf)) = +Inf", __real__ result);
4503 check_isinfp ("imag(csqrt(0 + i Inf)) = +Inf", __imag__ result);
4504 result = FUNC(csqrt) (BUILD_COMPLEX (4, plus_infty));
4505 check_isinfp ("real(csqrt(4 + i Inf)) = +Inf", __real__ result);
4506 check_isinfp ("imag(csqrt(4 + i Inf)) = +Inf", __imag__ result);
4507 result = FUNC(csqrt) (BUILD_COMPLEX (plus_infty, plus_infty));
4508 check_isinfp ("real(csqrt(+Inf + i Inf)) = +Inf", __real__ result);
4509 check_isinfp ("imag(csqrt(+Inf + i Inf)) = +Inf", __imag__ result);
4510 result = FUNC(csqrt) (BUILD_COMPLEX (minus_zero, plus_infty));
4511 check_isinfp ("real(csqrt(-0 + i Inf)) = +Inf", __real__ result);
4512 check_isinfp ("imag(csqrt(-0 + i Inf)) = +Inf", __imag__ result);
4513 result = FUNC(csqrt) (BUILD_COMPLEX (-4, plus_infty));
4514 check_isinfp ("real(csqrt(-4 + i Inf)) = +Inf", __real__ result);
4515 check_isinfp ("imag(csqrt(-4 + i Inf)) = +Inf", __imag__ result);
4516 result = FUNC(csqrt) (BUILD_COMPLEX (minus_infty, plus_infty));
4517 check_isinfp ("real(csqrt(-Inf + i Inf)) = +Inf", __real__ result);
4518 check_isinfp ("imag(csqrt(-Inf + i Inf)) = +Inf", __imag__ result);
4519 result = FUNC(csqrt) (BUILD_COMPLEX (0, minus_infty));
4520 check_isinfp ("real(csqrt(0 - i Inf)) = +Inf", __real__ result);
4521 check_isinfn ("imag(csqrt(0 - i Inf)) = -Inf", __imag__ result);
4522 result = FUNC(csqrt) (BUILD_COMPLEX (4, minus_infty));
4523 check_isinfp ("real(csqrt(4 - i Inf)) = +Inf", __real__ result);
4524 check_isinfn ("imag(csqrt(4 - i Inf)) = -Inf", __imag__ result);
4525 result = FUNC(csqrt) (BUILD_COMPLEX (plus_infty, minus_infty));
4526 check_isinfp ("real(csqrt(+Inf - i Inf)) = +Inf", __real__ result);
4527 check_isinfn ("imag(csqrt(+Inf - i Inf)) = -Inf", __imag__ result);
4528 result = FUNC(csqrt) (BUILD_COMPLEX (minus_zero, minus_infty));
4529 check_isinfp ("real(csqrt(-0 - i Inf)) = +Inf", __real__ result);
4530 check_isinfn ("imag(csqrt(-0 - i Inf)) = -Inf", __imag__ result);
4531 result = FUNC(csqrt) (BUILD_COMPLEX (-4, minus_infty));
4532 check_isinfp ("real(csqrt(-4 - i Inf)) = +Inf", __real__ result);
4533 check_isinfn ("imag(csqrt(-4 - i Inf)) = -Inf", __imag__ result);
4534 result = FUNC(csqrt) (BUILD_COMPLEX (minus_infty, minus_infty));
4535 check_isinfp ("real(csqrt(-Inf - i Inf)) = +Inf", __real__ result);
4536 check_isinfn ("imag(csqrt(-Inf - i Inf)) = -Inf", __imag__ result);
4538 result = FUNC(csqrt) (BUILD_COMPLEX (minus_infty, nan_value));
4539 check_isnan ("real(csqrt(-Inf + i NaN)) = NaN", __real__ result);
4540 check_isinfp ("imag(csqrt(-Inf + i NaN)) = +-Inf",
4541 FUNC(fabs) (__imag__ result));
4543 result = FUNC(csqrt) (BUILD_COMPLEX (plus_infty, nan_value));
4544 check_isinfp ("real(csqrt(+Inf + i NaN)) = +Inf", __real__ result);
4545 check_isnan ("imag(csqrt(+Inf + i NaN)) = NaN", __imag__ result);
4547 result = FUNC(csqrt) (BUILD_COMPLEX (0, nan_value));
4548 check_isnan_maybe_exc ("real(csqrt(0 + i NaN)) = NaN plus maybe invalid exception",
4549 __real__ result, INVALID_EXCEPTION);
4550 check_isnan ("imag(csqrt(0 + i NaN)) = NaN plus maybe invalid exception",
4551 __imag__ result);
4552 result = FUNC(csqrt) (BUILD_COMPLEX (1, nan_value));
4553 check_isnan_maybe_exc ("real(csqrt(1 + i NaN)) = NaN plus maybe invalid exception",
4554 __real__ result, INVALID_EXCEPTION);
4555 check_isnan ("imag(csqrt(1 + i NaN)) = NaN plus maybe invalid exception",
4556 __imag__ result);
4557 result = FUNC(csqrt) (BUILD_COMPLEX (minus_zero, nan_value));
4558 check_isnan_maybe_exc ("real(csqrt(-0 + i NaN)) = NaN plus maybe invalid exception",
4559 __real__ result, INVALID_EXCEPTION);
4560 check_isnan ("imag(csqrt(-0 + i NaN)) = NaN plus maybe invalid exception",
4561 __imag__ result);
4562 result = FUNC(csqrt) (BUILD_COMPLEX (-1, nan_value));
4563 check_isnan_maybe_exc ("real(csqrt(-1 + i NaN)) = NaN plus maybe invalid exception",
4564 __real__ result, INVALID_EXCEPTION);
4565 check_isnan ("imag(csqrt(-1 + i NaN)) = NaN plus maybe invalid exception",
4566 __imag__ result);
4568 result = FUNC(csqrt) (BUILD_COMPLEX (nan_value, 0));
4569 check_isnan_maybe_exc ("real(csqrt(NaN + i0)) = NaN plus maybe invalid exception",
4570 __real__ result, INVALID_EXCEPTION);
4571 check_isnan ("imag(csqrt(NaN + i0)) = NaN plus maybe invalid exception",
4572 __imag__ result);
4573 result = FUNC(csqrt) (BUILD_COMPLEX (nan_value, 8));
4574 check_isnan_maybe_exc ("real(csqrt(NaN + i8)) = NaN plus maybe invalid exception",
4575 __real__ result, INVALID_EXCEPTION);
4576 check_isnan ("imag(csqrt(NaN + i8)) = NaN plus maybe invalid exception",
4577 __imag__ result);
4578 result = FUNC(csqrt) (BUILD_COMPLEX (nan_value, minus_zero));
4579 check_isnan_maybe_exc ("real(csqrt(NaN - i0)) = NaN plus maybe invalid exception",
4580 __real__ result, INVALID_EXCEPTION);
4581 check_isnan ("imag(csqrt(NaN - i0)) = NaN plus maybe invalid exception",
4582 __imag__ result);
4583 result = FUNC(csqrt) (BUILD_COMPLEX (nan_value, -8));
4584 check_isnan_maybe_exc ("real(csqrt(NaN - i8)) = NaN plus maybe invalid exception",
4585 __real__ result, INVALID_EXCEPTION);
4586 check_isnan ("imag(csqrt(NaN - i8)) = NaN plus maybe invalid exception",
4587 __imag__ result);
4589 result = FUNC(csqrt) (BUILD_COMPLEX (nan_value, nan_value));
4590 check_isnan ("real(csqrt(NaN + i NaN)) = NaN", __real__ result);
4591 check_isnan ("imag(csqrt(NaN + i NaN)) = NaN", __imag__ result);
4595 static void
4596 cpow_test (void)
4598 __complex__ MATHTYPE result;
4600 result = FUNC (cpow) (BUILD_COMPLEX (1, 0), BUILD_COMPLEX (0, 0));
4601 check ("real(cpow (1 + i0), (0 + i0)) = 0", __real__ result, 1);
4602 check ("imag(cpow (1 + i0), (0 + i0)) = 0", __imag__ result, 0);
4604 result = FUNC (cpow) (BUILD_COMPLEX (2, 0), BUILD_COMPLEX (10, 0));
4605 check_eps ("real(cpow (2 + i0), (10 + i0)) = 1024", __real__ result, 1024,
4606 CHOOSE (2e-16L, 0, 0));
4607 check ("imag(cpow (2 + i0), (10 + i0)) = 0", __imag__ result, 0);
4612 static void
4613 nearbyint_test (void)
4615 check ("nearbyint(+0) = 0", FUNC(nearbyint) (0.0), 0.0);
4616 check ("nearbyint(-0) = -0", FUNC(nearbyint) (minus_zero), minus_zero);
4617 check_isinfp ("nearbyint(+Inf) = +Inf", FUNC(nearbyint) (plus_infty));
4618 check_isinfn ("nearbyint(-Inf) = -Inf", FUNC(nearbyint) (minus_infty));
4622 static void
4623 rint_test (void)
4625 check ("rint(0) = 0", FUNC(rint) (0.0), 0.0);
4626 check ("rint(-0) = -0", FUNC(rint) (minus_zero), minus_zero);
4627 check_isinfp ("rint(+Inf) = +Inf", FUNC(rint) (plus_infty));
4628 check_isinfn ("rint(-Inf) = -Inf", FUNC(rint) (minus_infty));
4632 static void
4633 lrint_test (void)
4635 /* XXX this test is incomplete. We need to have a way to specifiy
4636 the rounding method and test the critical cases. So far, only
4637 unproblematic numbers are tested. */
4639 check_long ("lrint(0) = 0", lrint (0.0), 0);
4640 check_long ("lrint(-0) = 0", lrint (minus_zero), 0);
4641 check_long ("lrint(0.2) = 0", lrint (0.2), 0);
4642 check_long ("lrint(-0.2) = 0", lrint (-0.2), 0);
4644 check_long ("lrint(1.4) = 1", lrint (1.4), 1);
4645 check_long ("lrint(-1.4) = -1", lrint (-1.4), -1);
4647 check_long ("lrint(8388600.3) = 8388600", lrint (8388600.3), 8388600);
4648 check_long ("lrint(-8388600.3) = -8388600", lrint (-8388600.3),
4649 -8388600);
4653 static void
4654 llrint_test (void)
4656 /* XXX this test is incomplete. We need to have a way to specifiy
4657 the rounding method and test the critical cases. So far, only
4658 unproblematic numbers are tested. */
4660 check_longlong ("llrint(0) = 0", llrint (0.0), 0);
4661 check_longlong ("llrint(-0) = 0", llrint (minus_zero), 0);
4662 check_longlong ("llrint(0.2) = 0", llrint (0.2), 0);
4663 check_longlong ("llrint(-0.2) = 0", llrint (-0.2), 0);
4665 check_longlong ("llrint(1.4) = 1", llrint (1.4), 1);
4666 check_longlong ("llrint(-1.4) = -1", llrint (-1.4), -1);
4668 check_longlong ("llrint(8388600.3) = 8388600", llrint (8388600.3),
4669 8388600);
4670 check_longlong ("llrint(-8388600.3) = -8388600", llrint (-8388600.3),
4671 -8388600);
4675 static void
4676 round_test (void)
4678 check ("round(0) = 0", FUNC(round) (0), 0);
4679 check ("round(-0) = -0", FUNC(round) (minus_zero), minus_zero);
4680 check ("round(0.2) = 0", FUNC(round) (0.2), 0.0);
4681 check ("round(-0.2) = -0", FUNC(round) (-0.2), minus_zero);
4682 check ("round(0.5) = 1", FUNC(round) (0.5), 1.0);
4683 check ("round(-0.5) = -1", FUNC(round) (-0.5), -1.0);
4684 check ("round(0.8) = 1", FUNC(round) (0.8), 1.0);
4685 check ("round(-0.8) = -1", FUNC(round) (-0.8), -1.0);
4686 check ("round(1.5) = 2", FUNC(round) (1.5), 2.0);
4687 check ("round(-1.5) = -2", FUNC(round) (-1.5), -2.0);
4688 check ("round(2097152.5) = 2097153", FUNC(round) (2097152.5), 2097153);
4689 check ("round(-2097152.5) = -2097153", FUNC(round) (-2097152.5), -2097153);
4693 static void
4694 lround_test (void)
4696 check_long ("lround(0) = 0", FUNC(lround) (0), 0);
4697 check_long ("lround(-0) = 0", FUNC(lround) (minus_zero), 0);
4698 check_long ("lround(0.2) = 0", FUNC(lround) (0.2), 0.0);
4699 check_long ("lround(-0.2) = 0", FUNC(lround) (-0.2), 0);
4700 check_long ("lround(0.5) = 1", FUNC(lround) (0.5), 1);
4701 check_long ("lround(-0.5) = -1", FUNC(lround) (-0.5), -1);
4702 check_long ("lround(0.8) = 1", FUNC(lround) (0.8), 1);
4703 check_long ("lround(-0.8) = -1", FUNC(lround) (-0.8), -1);
4704 check_long ("lround(1.5) = 2", FUNC(lround) (1.5), 2);
4705 check_long ("lround(-1.5) = -2", FUNC(lround) (-1.5), -2);
4706 check_long ("lround(22514.5) = 22514", FUNC(lround) (1.5), 2);
4707 check_long ("lround(-22514.5) = -22514", FUNC(lround) (-1.5), -2);
4708 #ifndef TEST_FLOAT
4709 check_long ("lround(2097152.5) = 2097153", FUNC(lround) (2097152.5),
4710 2097153);
4711 check_long ("lround(-2097152.5) = -2097153", FUNC(lround) (-2097152.5),
4712 -2097153);
4713 #endif
4717 static void
4718 llround_test (void)
4720 check_longlong ("llround(0) = 0", FUNC(llround) (0), 0);
4721 check_longlong ("llround(-0) = 0", FUNC(llround) (minus_zero), 0);
4722 check_longlong ("llround(0.2) = 0", FUNC(llround) (0.2), 0.0);
4723 check_longlong ("llround(-0.2) = 0", FUNC(llround) (-0.2), 0);
4724 check_longlong ("llround(0.5) = 1", FUNC(llround) (0.5), 1);
4725 check_longlong ("llround(-0.5) = -1", FUNC(llround) (-0.5), -1);
4726 check_longlong ("llround(0.8) = 1", FUNC(llround) (0.8), 1);
4727 check_longlong ("llround(-0.8) = -1", FUNC(llround) (-0.8), -1);
4728 check_longlong ("llround(1.5) = 2", FUNC(llround) (1.5), 2);
4729 check_longlong ("llround(-1.5) = -2", FUNC(llround) (-1.5), -2);
4730 check_longlong ("llround(22514.5) = 22514", FUNC(llround) (1.5), 2);
4731 check_longlong ("llround(-22514.5) = -22514", FUNC(llround) (-1.5), -2);
4732 #ifndef TEST_FLOAT
4733 check_longlong ("llround(2097152.5) = 2097153",
4734 FUNC(llround) (2097152.5), 2097153);
4735 check_longlong ("llround(-2097152.5) = -2097153",
4736 FUNC(llround) (-2097152.5), -2097153);
4737 check_longlong ("llround(34359738368.5) = 34359738369",
4738 FUNC(llround) (34359738368.5), 34359738369ll);
4739 check_longlong ("llround(-34359738368.5) = -34359738369",
4740 FUNC(llround) (-34359738368.5), -34359738369ll);
4741 #endif
4745 static void
4746 inverse_func_pair_test (const char *test_name,
4747 mathfunc f1, mathfunc inverse,
4748 MATHTYPE x, MATHTYPE epsilon)
4750 MATHTYPE a, b, difference;
4751 int result;
4753 a = f1 (x);
4754 (void) &a;
4755 b = inverse (a);
4756 (void) &b;
4758 output_new_test (test_name);
4759 result = check_equal (b, x, epsilon, &difference);
4760 output_result (test_name, result,
4761 b, x, difference, PRINT, PRINT);
4765 static void
4766 inverse_functions (void)
4768 inverse_func_pair_test ("asin(sin(x)) == x",
4769 FUNC(sin), FUNC(asin), 1.0, CHOOSE (2e-18L, 0, 3e-7L));
4770 inverse_func_pair_test ("sin(asin(x)) == x",
4771 FUNC(asin), FUNC(sin), 1.0, 0.0);
4773 inverse_func_pair_test ("acos(cos(x)) == x",
4774 FUNC(cos), FUNC(acos), 1.0, CHOOSE (4e-18L, 1e-15L, 0));
4775 inverse_func_pair_test ("cos(acos(x)) == x",
4776 FUNC(acos), FUNC(cos), 1.0, 0.0);
4777 inverse_func_pair_test ("atan(tan(x)) == x",
4778 FUNC(tan), FUNC(atan), 1.0, CHOOSE (2e-18L, 0, 0));
4779 inverse_func_pair_test ("tan(atan(x)) == x",
4780 FUNC(atan), FUNC(tan), 1.0, CHOOSE (2e-18L, 1e-15L, 0));
4782 inverse_func_pair_test ("asinh(sinh(x)) == x",
4783 FUNC(sinh), FUNC(asinh), 1.0, CHOOSE (1e-18L, 0, 1e-7));
4784 inverse_func_pair_test ("sinh(asinh(x)) == x",
4785 FUNC(asinh), FUNC(sinh), 1.0, CHOOSE (2e-18L, 0, 0));
4787 inverse_func_pair_test ("acosh(cosh(x)) == x",
4788 FUNC(cosh), FUNC(acosh), 1.0, CHOOSE (1e-18L, 1e-15L, 0));
4789 inverse_func_pair_test ("cosh(acosh(x)) == x",
4790 FUNC(acosh), FUNC(cosh), 1.0, 0.0);
4792 inverse_func_pair_test ("atanh(tanh(x)) == x",
4793 FUNC(tanh), FUNC(atanh), 1.0, CHOOSE (1e-18L, 1e-15L, 0));
4794 inverse_func_pair_test ("tanh(atanh(x)) == x",
4795 FUNC(atanh), FUNC(tanh), 1.0, 0.0);
4799 /* Test sin and cos with the identity: sin(x)^2 + cos(x)^2 = 1. */
4800 static void
4801 identities1_test (MATHTYPE x, MATHTYPE epsilon)
4803 MATHTYPE res1, res2, res3, diff;
4804 int result;
4806 res1 = FUNC(sin) (x);
4807 (void) &res1;
4808 res2 = FUNC(cos) (x);
4809 (void) &res2;
4810 res3 = res1 * res1 + res2 * res2;
4811 (void) &res3;
4813 output_new_test ("sin^2 + cos^2 == 1");
4814 result = check_equal (res3, 1.0, epsilon, &diff);
4815 output_result_ext ("sin^2 + cos^2 == 1", result,
4816 res3, 1.0, diff, x, PRINT, PRINT);
4820 /* Test sin, cos, tan with the following relation: tan = sin/cos. */
4821 static void
4822 identities2_test (MATHTYPE x, MATHTYPE epsilon)
4824 #ifndef TEST_INLINE
4825 MATHTYPE res1, res2, res3, res4, diff;
4826 int result;
4828 res1 = FUNC(sin) (x);
4829 (void) &res1;
4830 res2 = FUNC(cos) (x);
4831 (void) &res2;
4832 res3 = FUNC(tan) (x);
4833 (void) &res3;
4834 res4 = res1 / res2;
4835 (void) &res4;
4837 output_new_test ("sin/cos == tan");
4838 result = check_equal (res4, res3, epsilon, &diff);
4839 output_result_ext ("sin/cos == tan", result,
4840 res4, res3, diff, x, PRINT, PRINT);
4841 #endif
4845 /* Test cosh and sinh with the identity cosh^2 - sinh^2 = 1. */
4846 static void
4847 identities3_test (MATHTYPE x, MATHTYPE epsilon)
4849 MATHTYPE res1, res2, res3, diff;
4850 int result;
4852 res1 = FUNC(sinh) (x);
4853 (void) &res1;
4854 res2 = FUNC(cosh) (x);
4855 (void) &res2;
4856 res3 = res2 * res2 - res1 * res1;
4857 (void) &res3;
4859 output_new_test ("cosh^2 - sinh^2 == 1");
4860 result = check_equal (res3, 1.0, epsilon, &diff);
4861 output_result_ext ("cosh^2 - sinh^2 == 1", result,
4862 res3, 1.0, diff, x, PRINT, PRINT);
4866 static void
4867 identities (void)
4869 identities1_test (0.2L, CHOOSE (1e-18L, 0, 2e-7));
4870 identities1_test (0.9L, CHOOSE (1e-18L, 0, 1e-7));
4871 identities1_test (0, 0);
4872 identities1_test (-1, CHOOSE (1e-18L, 0, 1e-7));
4874 identities2_test (0.2L, CHOOSE (1e-19L, 1e-16, 0));
4875 identities2_test (0.9L, CHOOSE (0, 1e-15, 2e-7));
4876 identities2_test (0, 0);
4877 identities2_test (-1, CHOOSE (1e-18L, 1e-15, 2e-7));
4879 identities3_test (0.2L, CHOOSE (1e-18L, 0, 1e-7));
4880 identities3_test (0.9L, CHOOSE (1e-18L, 1e-15, 1e-6));
4881 identities3_test (0, CHOOSE (0, 0, 1e-6));
4882 identities3_test (-1, CHOOSE (1e-18L, 7e-16, 1e-6));
4887 Let's test that basic arithmetic is working
4888 tests: Infinity and NaN
4890 static void
4891 basic_tests (void)
4893 /* variables are declared volatile to forbid some compiler
4894 optimizations */
4895 volatile MATHTYPE Inf_var, NaN_var, zero_var, one_var;
4896 MATHTYPE x1, x2;
4898 zero_var = 0.0;
4899 one_var = 1.0;
4900 NaN_var = nan_value;
4901 Inf_var = one_var / zero_var;
4903 (void) &zero_var;
4904 (void) &one_var;
4905 (void) &NaN_var;
4906 (void) &Inf_var;
4908 /* Clear all exceptions. The previous computations raised exceptions. */
4909 feclearexcept (FE_ALL_EXCEPT);
4911 check_isinfp ("isinf (inf) == +1", Inf_var);
4912 check_isinfn ("isinf (-inf) == -1", -Inf_var);
4913 check_bool ("!isinf (1)", !(FUNC(isinf) (one_var)));
4914 check_bool ("!isinf (NaN)", !(FUNC(isinf) (NaN_var)));
4916 check_isnan ("isnan (NaN)", NaN_var);
4917 check_isnan ("isnan (-NaN)", -NaN_var);
4918 check_bool ("!isnan (1)", !(FUNC(isnan) (one_var)));
4919 check_bool ("!isnan (inf)", !(FUNC(isnan) (Inf_var)));
4921 check_bool ("inf == inf", Inf_var == Inf_var);
4922 check_bool ("-inf == -inf", -Inf_var == -Inf_var);
4923 check_bool ("inf != -inf", Inf_var != -Inf_var);
4924 check_bool ("NaN != NaN", NaN_var != NaN_var);
4927 the same tests but this time with NAN from <bits/nan.h>
4928 NAN is a double const
4930 check_bool ("isnan (NAN)", isnan (NAN));
4931 check_bool ("isnan (-NAN)", isnan (-NAN));
4932 check_bool ("!isinf (NAN)", !(isinf (NAN)));
4933 check_bool ("!isinf (-NAN)", !(isinf (-NAN)));
4934 check_bool ("NAN != NAN", NAN != NAN);
4937 And again with the value returned by the `nan' function.
4939 check_bool ("isnan (NAN)", FUNC(isnan) (FUNC(nan) ("")));
4940 check_bool ("isnan (-NAN)", FUNC(isnan) (-FUNC(nan) ("")));
4941 check_bool ("!isinf (NAN)", !(FUNC(isinf) (FUNC(nan) (""))));
4942 check_bool ("!isinf (-NAN)", !(FUNC(isinf) (-FUNC(nan) (""))));
4943 check_bool ("NAN != NAN", FUNC(nan) ("") != FUNC(nan) (""));
4945 /* test if EPSILON is ok */
4946 x1 = MATHCONST (1.0);
4947 x2 = x1 + CHOOSE (LDBL_EPSILON, DBL_EPSILON, FLT_EPSILON);
4948 check_bool ("1 != 1+EPSILON", x1 != x2);
4950 x1 = MATHCONST (1.0);
4951 x2 = x1 - CHOOSE (LDBL_EPSILON, DBL_EPSILON, FLT_EPSILON);
4952 check_bool ("1 != 1-EPSILON", x1 != x2);
4954 /* test if HUGE_VALx is ok */
4955 x1 = CHOOSE (HUGE_VALL, HUGE_VAL, HUGE_VALF);
4956 check_bool ("isinf (HUGE_VALx) == +1", ISINF (x1) == +1);
4957 x1 = -CHOOSE (HUGE_VALL, HUGE_VAL, HUGE_VALF);
4958 check_bool ("isinf (-HUGE_VALx) == -1", ISINF (x1) == -1);
4963 static void
4964 initialize (void)
4966 fpstack_test ("start *init*");
4967 plus_zero = 0.0;
4968 nan_value = plus_zero / plus_zero; /* Suppress GCC warning */
4970 minus_zero = FUNC (copysign) (0.0, -1.0);
4971 plus_infty = CHOOSE (HUGE_VALL, HUGE_VAL, HUGE_VALF);
4972 minus_infty = -CHOOSE (HUGE_VALL, HUGE_VAL, HUGE_VALF);
4974 (void) &plus_zero;
4975 (void) &nan_value;
4976 (void) &minus_zero;
4977 (void) &plus_infty;
4978 (void) &minus_infty;
4980 /* Clear all exceptions. From now on we must not get random exceptions. */
4981 feclearexcept (FE_ALL_EXCEPT);
4983 /* Test to make sure we start correctly. */
4984 fpstack_test ("end *init*");
4988 static struct option long_options[] =
4990 {"verbose", optional_argument, NULL, 'v'},
4991 {"silent", no_argument, NULL, 's'},
4992 {0, 0, 0, 0}
4996 static void
4997 parse_options (int argc, char *argv[])
4999 int c;
5000 int option_index;
5002 verbose = 1;
5004 while (1)
5006 c = getopt_long (argc, argv, "v::s",
5007 long_options, &option_index);
5009 /* Detect the end of the options. */
5010 if (c == -1)
5011 break;
5013 switch (c)
5015 case 'v':
5016 if (optarg)
5017 verbose = (unsigned int) strtoul (optarg, NULL, 0);
5018 else
5019 verbose = 4;
5020 break;
5021 case 's':
5022 verbose = 0;
5023 default:
5024 break;
5031 main (int argc, char *argv[])
5034 parse_options (argc, argv);
5036 initialize ();
5037 printf (TEST_MSG);
5039 basic_tests ();
5041 /* keep the tests a wee bit ordered (according to ISO 9X) */
5042 /* classification functions */
5043 fpclassify_test ();
5044 isfinite_test ();
5045 isnormal_test ();
5046 signbit_test ();
5048 /* trigonometric functions */
5049 acos_test ();
5050 asin_test ();
5051 atan_test ();
5052 atan2_test ();
5053 cos_test ();
5054 sin_test ();
5055 sincos_test ();
5056 tan_test ();
5058 /* hyperbolic functions */
5059 acosh_test ();
5060 asinh_test ();
5061 atanh_test ();
5062 cosh_test ();
5063 sinh_test ();
5064 tanh_test ();
5066 /* exponential and logarithmic functions */
5067 exp_test ();
5068 exp2_test ();
5069 expm1_test ();
5070 frexp_test ();
5071 ldexp_test ();
5072 log_test ();
5073 log10_test ();
5074 log1p_test ();
5075 log2_test ();
5076 logb_test ();
5077 modf_test ();
5078 ilogb_test ();
5079 scalb_test ();
5080 scalbn_test ();
5082 /* power and absolute value functions */
5083 cbrt_test ();
5084 fabs_test ();
5085 hypot_test ();
5086 pow_test ();
5087 sqrt_test ();
5089 /* error and gamma functions */
5090 erf_test ();
5091 erfc_test ();
5092 gamma_test ();
5093 lgamma_test ();
5095 /* nearest integer functions */
5096 ceil_test ();
5097 floor_test ();
5098 nearbyint_test ();
5099 rint_test ();
5100 lrint_test ();
5101 llrint_test ();
5102 round_test ();
5103 lround_test ();
5104 llround_test ();
5105 trunc_test ();
5107 /* remainder functions */
5108 fmod_test ();
5109 remainder_test ();
5110 remquo_test ();
5112 /* manipulation functions */
5113 copysign_test ();
5114 nextafter_test ();
5116 /* maximum, minimum and positive difference functions */
5117 fdim_test ();
5118 fmin_test ();
5119 fmax_test ();
5121 /* complex functions */
5122 cexp_test ();
5123 csin_test ();
5124 csinh_test ();
5125 ccos_test ();
5126 ccosh_test ();
5127 clog_test ();
5128 clog10_test ();
5129 cacos_test ();
5130 cacosh_test ();
5131 casin_test ();
5132 casinh_test ();
5133 catan_test ();
5134 catanh_test ();
5135 ctanh_test ();
5136 csqrt_test ();
5137 cpow_test ();
5139 /* special tests */
5140 identities ();
5141 inverse_functions ();
5143 if (noErrors)
5145 printf ("\n%d errors occured.\n", noErrors);
5146 exit (1);
5148 printf ("\n All tests passed successfully.\n");
5149 exit (0);