Update.
[glibc.git] / math / libm-test.c
blob0486718b8a85d7e88c8a7f2713de72d59acbee32
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);
859 check_eps ("asin (0.5) == pi/6", FUNC(asin) (0.5), M_PI_6,
860 CHOOSE(3.5e-18, 0, 2e-7));
861 check ("asin (1.0) == pi/2", FUNC(asin) (1.0), M_PI_2);
865 static void
866 asinh_test (void)
869 check ("asinh(+0) == +0", FUNC(asinh) (0), 0);
870 #ifndef TEST_INLINE
871 check ("asinh(-0) == -0", FUNC(asinh) (minus_zero), minus_zero);
872 check_isinfp ("asinh(+inf) == +inf", FUNC(asinh) (plus_infty));
873 check_isinfn ("asinh(-inf) == -inf", FUNC(asinh) (minus_infty));
874 #endif
879 static void
880 atan_test (void)
882 check ("atan (0) == 0", FUNC(atan) (0), 0);
883 check ("atan (-0) == -0", FUNC(atan) (minus_zero), minus_zero);
885 check ("atan (+inf) == pi/2", FUNC(atan) (plus_infty), M_PI_2);
886 check ("atan (-inf) == -pi/2", FUNC(atan) (minus_infty), -M_PI_2);
890 static void
891 atan2_test (void)
893 MATHTYPE x;
895 x = random_greater (0);
896 check ("atan2 (0,x) == 0 for x > 0",
897 FUNC(atan2) (0, x), 0);
898 x = random_greater (0);
899 check ("atan2 (-0,x) == -0 for x > 0",
900 FUNC(atan2) (minus_zero, x), minus_zero);
902 check ("atan2 (+0,+0) == +0", FUNC(atan2) (0, 0), 0);
903 check ("atan2 (-0,+0) == -0", FUNC(atan2) (minus_zero, 0), minus_zero);
905 x = -random_greater (0);
906 check ("atan2 (+0,x) == +pi for x < 0", FUNC(atan2) (0, x), M_PI);
908 x = -random_greater (0);
909 check ("atan2 (-0,x) == -pi for x < 0", FUNC(atan2) (minus_zero, x), -M_PI);
911 check ("atan2 (+0,-0) == +pi", FUNC(atan2) (0, minus_zero), M_PI);
912 check ("atan2 (-0,-0) == -pi", FUNC(atan2) (minus_zero, minus_zero), -M_PI);
914 x = random_greater (0);
915 check ("atan2 (y,+0) == pi/2 for y > 0", FUNC(atan2) (x, 0), M_PI_2);
917 x = random_greater (0);
918 check ("atan2 (y,-0) == pi/2 for y > 0", FUNC(atan2) (x, minus_zero), M_PI_2);
920 x = random_less (0);
921 check ("atan2 (y,+0) == -pi/2 for y < 0", FUNC(atan2) (x, 0), -M_PI_2);
923 x = random_less (0);
924 check ("atan2 (y,-0) == -pi/2 for y < 0", FUNC(atan2) (x, minus_zero), -M_PI_2);
926 x = random_greater (0);
927 check ("atan2 (y,inf) == +0 for finite y > 0",
928 FUNC(atan2) (x, plus_infty), 0);
930 x = -random_greater (0);
931 check ("atan2 (y,inf) == -0 for finite y < 0",
932 FUNC(atan2) (x, plus_infty), minus_zero);
934 x = random_value (-1e4, 1e4);
935 check ("atan2(+inf, x) == pi/2 for finite x",
936 FUNC(atan2) (plus_infty, x), M_PI_2);
938 x = random_value (-1e4, 1e4);
939 check ("atan2(-inf, x) == -pi/2 for finite x",
940 FUNC(atan2) (minus_infty, x), -M_PI_2);
942 x = random_greater (0);
943 check ("atan2 (y,-inf) == +pi for finite y > 0",
944 FUNC(atan2) (x, minus_infty), M_PI);
946 x = -random_greater (0);
947 check ("atan2 (y,-inf) == -pi for finite y < 0",
948 FUNC(atan2) (x, minus_infty), -M_PI);
950 check ("atan2 (+inf,+inf) == +pi/4",
951 FUNC(atan2) (plus_infty, plus_infty), M_PI_4);
953 check ("atan2 (-inf,+inf) == -pi/4",
954 FUNC(atan2) (minus_infty, plus_infty), -M_PI_4);
956 check ("atan2 (+inf,-inf) == +3*pi/4",
957 FUNC(atan2) (plus_infty, minus_infty), 3 * M_PI_4);
959 check ("atan2 (-inf,-inf) == -3*pi/4",
960 FUNC(atan2) (minus_infty, minus_infty), -3 * M_PI_4);
962 /* FIXME: Add some specific tests */
966 static void
967 atanh_test (void)
969 #ifndef TEST_INLINE
970 MATHTYPE x;
971 #endif
973 check ("atanh(+0) == +0", FUNC(atanh) (0), 0);
974 #ifndef TEST_INLINE
975 check ("atanh(-0) == -0", FUNC(atanh) (minus_zero), minus_zero);
977 check_isinfp_exc ("atanh(+1) == +inf plus divide-by-zero exception",
978 FUNC(atanh) (1), DIVIDE_BY_ZERO_EXCEPTION);
979 check_isinfn_exc ("atanh(-1) == -inf plus divide-by-zero exception",
980 FUNC(atanh) (-1), DIVIDE_BY_ZERO_EXCEPTION);
982 x = random_greater (1.0);
983 check_isnan_exc_ext ("atanh (x) == NaN plus invalid exception if |x| > 1",
984 FUNC(atanh) (x), INVALID_EXCEPTION, x);
986 x = random_less (1.0);
987 check_isnan_exc_ext ("atanh (x) == NaN plus invalid exception if |x| > 1",
988 FUNC(atanh) (x), INVALID_EXCEPTION, x);
990 #endif
994 static void
995 cbrt_test (void)
997 check ("cbrt (+0) == +0", FUNC(cbrt) (0.0), 0.0);
998 check ("cbrt (-0) == -0", FUNC(cbrt) (minus_zero), minus_zero);
1000 #ifndef TEST_INLINE
1001 check_isinfp ("cbrt (+inf) == +inf", FUNC(cbrt) (plus_infty));
1002 check_isinfn ("cbrt (-inf) == -inf", FUNC(cbrt) (minus_infty));
1003 check_isnan ("cbrt (NaN) == NaN", FUNC(cbrt) (nan_value));
1004 #endif
1005 check_eps ("cbrt (-0.001) == -0.1", FUNC(cbrt) (-0.001), -0.1,
1006 CHOOSE (5e-18L, 0, 0));
1007 check_eps ("cbrt (8) == 2", FUNC(cbrt) (8), 2, CHOOSE (5e-17L, 0, 0));
1008 check_eps ("cbrt (-27) == -3", FUNC(cbrt) (-27.0), -3.0,
1009 CHOOSE (3e-16L, 5e-16, 0));
1010 check_eps ("cbrt (0.970299) == 0.99", FUNC(cbrt) (0.970299), 0.99,
1011 CHOOSE (2e-17L, 0, 0));
1015 static void
1016 ceil_test (void)
1018 check ("ceil (+0) == +0", FUNC(ceil) (0.0), 0.0);
1019 check ("ceil (-0) == -0", FUNC(ceil) (minus_zero), minus_zero);
1020 check_isinfp ("ceil (+inf) == +inf", FUNC(ceil) (plus_infty));
1021 check_isinfn ("ceil (-inf) == -inf", FUNC(ceil) (minus_infty));
1023 check ("ceil (pi) == 4", FUNC(ceil) (M_PI), 4.0);
1024 check ("ceil (-pi) == -3", FUNC(ceil) (-M_PI), -3.0);
1028 static void
1029 cos_test (void)
1032 check ("cos (+0) == 1", FUNC(cos) (0), 1);
1033 check ("cos (-0) == 1", FUNC(cos) (minus_zero), 1);
1034 check_isnan_exc ("cos (+inf) == NaN plus invalid exception",
1035 FUNC(cos) (plus_infty),
1036 INVALID_EXCEPTION);
1037 check_isnan_exc ("cos (-inf) == NaN plus invalid exception",
1038 FUNC(cos) (minus_infty),
1039 INVALID_EXCEPTION);
1041 check_eps ("cos (pi/3) == 0.5", FUNC(cos) (M_PI_6 * 2.0),
1042 0.5, CHOOSE (4e-18L, 1e-15L, 1e-7L));
1043 check_eps ("cos (pi/2) == 0", FUNC(cos) (M_PI_2),
1044 0, CHOOSE (1e-19L, 1e-16L, 1e-7L));
1048 static void
1049 cosh_test (void)
1051 check ("cosh (+0) == 1", FUNC(cosh) (0), 1);
1052 check ("cosh (-0) == 1", FUNC(cosh) (minus_zero), 1);
1054 #ifndef TEST_INLINE
1055 check_isinfp ("cosh (+inf) == +inf", FUNC(cosh) (plus_infty));
1056 check_isinfp ("cosh (-inf) == +inf", FUNC(cosh) (minus_infty));
1057 #endif
1061 static void
1062 erf_test (void)
1064 errno = 0;
1065 FUNC(erf) (0);
1066 if (errno == ENOSYS)
1067 /* Function not implemented. */
1068 return;
1070 check ("erf (+0) == +0", FUNC(erf) (0), 0);
1071 check ("erf (-0) == -0", FUNC(erf) (minus_zero), minus_zero);
1072 check ("erf (+inf) == +1", FUNC(erf) (plus_infty), 1);
1073 check ("erf (-inf) == -1", FUNC(erf) (minus_infty), -1);
1077 static void
1078 erfc_test (void)
1080 errno = 0;
1081 FUNC(erfc) (0);
1082 if (errno == ENOSYS)
1083 /* Function not implemented. */
1084 return;
1086 check ("erfc (+inf) == 0", FUNC(erfc) (plus_infty), 0.0);
1087 check ("erfc (-inf) == 2", FUNC(erfc) (minus_infty), 2.0);
1088 check ("erfc (+0) == 1", FUNC(erfc) (0.0), 1.0);
1089 check ("erfc (-0) == 1", FUNC(erfc) (minus_zero), 1.0);
1093 static void
1094 exp_test (void)
1096 check ("exp (+0) == 1", FUNC(exp) (0), 1);
1097 check ("exp (-0) == 1", FUNC(exp) (minus_zero), 1);
1099 #ifndef TEST_INLINE
1100 check_isinfp ("exp (+inf) == +inf", FUNC(exp) (plus_infty));
1101 check ("exp (-inf) == 0", FUNC(exp) (minus_infty), 0);
1102 #endif
1103 check_eps ("exp (1) == e", FUNC(exp) (1), M_E, CHOOSE (4e-18L, 5e-16, 0));
1107 static void
1108 exp2_test (void)
1110 errno = 0;
1111 FUNC(exp2) (0);
1112 if (errno == ENOSYS)
1113 /* Function not implemented. */
1114 return;
1116 check ("exp2 (+0) == 1", FUNC(exp2) (0), 1);
1117 check ("exp2 (-0) == 1", FUNC(exp2) (minus_zero), 1);
1119 check_isinfp ("exp2 (+inf) == +inf", FUNC(exp2) (plus_infty));
1120 check ("exp2 (-inf) == 0", FUNC(exp2) (minus_infty), 0);
1121 check ("exp2 (10) == 1024", FUNC(exp2) (10), 1024);
1122 check ("exp2 (-1) == 0.5", FUNC(exp2) (-1), 0.5);
1123 check_isinfp ("exp2 (1e6) == +inf", FUNC(exp2) (1e6));
1124 check ("exp2 (-1e6) == 0", FUNC(exp2) (-1e6), 0);
1128 static void
1129 expm1_test (void)
1131 check ("expm1 (+0) == 0", FUNC(expm1) (0), 0);
1132 #ifndef TEST_INLINE
1133 check ("expm1 (-0) == -0", FUNC(expm1) (minus_zero), minus_zero);
1135 check_isinfp ("expm1 (+inf) == +inf", FUNC(expm1) (plus_infty));
1136 check ("expm1 (-inf) == -1", FUNC(expm1) (minus_infty), -1);
1137 #endif
1139 check_eps ("expm1 (1) == e-1", FUNC(expm1) (1), M_E - 1.0,
1140 CHOOSE (4e-18L, 0, 2e-7));
1146 static void
1147 check_frexp (const char *test_name, MATHTYPE computed, MATHTYPE expected,
1148 int comp_int, int exp_int)
1150 MATHTYPE diff;
1151 int result;
1153 result = (check_equal (computed, expected, 0, &diff)
1154 && (comp_int == exp_int));
1156 if (result)
1158 if (verbose > 2)
1159 printf ("Pass: %s\n", test_name);
1161 else
1163 if (verbose)
1164 printf ("Fail: %s\n", test_name);
1165 if (verbose > 1)
1167 printf ("Result:\n");
1168 printf (" is: %.20" PRINTF_EXPR " *2^%d\n", computed, comp_int);
1169 printf (" should be: %.20" PRINTF_EXPR " *2^%d\n", expected, exp_int);
1170 printf (" difference: %.20" PRINTF_EXPR "\n", diff);
1172 noErrors++;
1174 fpstack_test (test_name);
1175 output_result (test_name, result,
1176 computed, expected, diff, PRINT, PRINT);
1180 static void
1181 frexp_test (void)
1183 int x_int;
1184 MATHTYPE result;
1186 result = FUNC(frexp) (plus_infty, &x_int);
1187 check_isinfp ("frexp (+inf, expr) == +inf", result);
1189 result = FUNC(frexp) (minus_infty, &x_int);
1190 check_isinfn ("frexp (-inf, expr) == -inf", result);
1192 result = FUNC(frexp) (nan_value, &x_int);
1193 check_isnan ("frexp (Nan, expr) == NaN", result);
1195 result = FUNC(frexp) (0, &x_int);
1196 check_frexp ("frexp: +0 == 0 * 2^0", result, 0, x_int, 0);
1198 result = FUNC(frexp) (minus_zero, &x_int);
1199 check_frexp ("frexp: -0 == -0 * 2^0", result, minus_zero, x_int, 0);
1201 result = FUNC(frexp) (12.8L, &x_int);
1202 check_frexp ("frexp: 12.8 == 0.8 * 2^4", result, 0.8L, x_int, 4);
1204 result = FUNC(frexp) (-27.34L, &x_int);
1205 check_frexp ("frexp: -27.34 == -0.854375 * 2^5", result, -0.854375L, x_int, 5);
1210 #if __GLIBC__ < 2 || (__GLIBC__ == 2 && __GLIBC_MINOR__ < 1)
1211 /* All floating-point numbers can be put in one of these categories. */
1212 enum
1214 FP_NAN,
1215 #define FP_NAN FP_NAN
1216 FP_INFINITE,
1217 #define FP_INFINITE FP_INFINITE
1218 FP_ZERO,
1219 #define FP_ZERO FP_ZERO
1220 FP_SUBNORMAL,
1221 #define FP_SUBNORMAL FP_SUBNORMAL
1222 FP_NORMAL
1223 #define FP_NORMAL FP_NORMAL
1225 #endif
1228 static void
1229 fpclassify_test (void)
1231 MATHTYPE x;
1233 /* fpclassify is a macro, don't give it constants as parameter */
1234 check_bool ("fpclassify (NaN) == FP_NAN", fpclassify (nan_value) == FP_NAN);
1235 check_bool ("fpclassify (+inf) == FP_INFINITE",
1236 fpclassify (plus_infty) == FP_INFINITE);
1237 check_bool ("fpclassify (-inf) == FP_INFINITE",
1238 fpclassify (minus_infty) == FP_INFINITE);
1239 check_bool ("fpclassify (+0) == FP_ZERO",
1240 fpclassify (plus_zero) == FP_ZERO);
1241 check_bool ("fpclassify (-0) == FP_ZERO",
1242 fpclassify (minus_zero) == FP_ZERO);
1244 x = 1000.0;
1245 check_bool ("fpclassify (1000) == FP_NORMAL",
1246 fpclassify (x) == FP_NORMAL);
1250 static void
1251 isfinite_test (void)
1253 check_bool ("isfinite (0) != 0", isfinite (0));
1254 check_bool ("isfinite (-0) != 0", isfinite (minus_zero));
1255 check_bool ("isfinite (10) != 0", isfinite (10));
1256 check_bool ("isfinite (+inf) == 0", isfinite (plus_infty) == 0);
1257 check_bool ("isfinite (-inf) == 0", isfinite (minus_infty) == 0);
1258 check_bool ("isfinite (NaN) == 0", isfinite (nan_value) == 0);
1262 static void
1263 isnormal_test (void)
1265 check_bool ("isnormal (0) == 0", isnormal (0) == 0);
1266 check_bool ("isnormal (-0) == 0", isnormal (minus_zero) == 0);
1267 check_bool ("isnormal (10) != 0", isnormal (10));
1268 check_bool ("isnormal (+inf) == 0", isnormal (plus_infty) == 0);
1269 check_bool ("isnormal (-inf) == 0", isnormal (minus_infty) == 0);
1270 check_bool ("isnormal (NaN) == 0", isnormal (nan_value) == 0);
1275 static void
1276 signbit_test (void)
1278 MATHTYPE x;
1280 check_bool ("signbit (+0) == 0", signbit (0) == 0);
1281 check_bool ("signbit (-0) != 0", signbit (minus_zero));
1282 check_bool ("signbit (+inf) == 0", signbit (plus_infty) == 0);
1283 check_bool ("signbit (-inf) != 0", signbit (minus_infty));
1285 x = random_less (0);
1286 check_bool ("signbit (x) != 0 for x < 0", signbit (x));
1288 x = random_greater (0);
1289 check_bool ("signbit (x) == 0 for x > 0", signbit (x) == 0);
1295 gamma has different semantics depending on _LIB_VERSION:
1296 if _LIB_VERSION is _SVID, gamma is just an alias for lgamma,
1297 otherwise gamma is the real gamma function as definied in ISO C 9X.
1299 static void
1300 gamma_test (void)
1302 int save_lib_version = _LIB_VERSION;
1303 errno = 0;
1304 FUNC(gamma) (1);
1305 if (errno == ENOSYS)
1306 /* Function not implemented. */
1307 return;
1308 feclearexcept (FE_ALL_EXCEPT);
1311 _LIB_VERSION = _SVID_;
1313 check_isinfp ("gamma (+inf) == +inf", FUNC(gamma) (plus_infty));
1314 check_isinfp_exc ("gamma (0) == +inf plus divide by zero exception",
1315 FUNC(gamma) (0), DIVIDE_BY_ZERO_EXCEPTION);
1317 check_isinfp_exc ("gamma (x) == +inf plus divide by zero exception for integer x <= 0",
1318 FUNC(gamma) (-3), DIVIDE_BY_ZERO_EXCEPTION);
1319 check_isnan_exc ("gamma (-inf) == NaN plus invalid exception",
1320 FUNC(gamma) (minus_infty), INVALID_EXCEPTION);
1322 signgam = 0;
1323 check ("gamma (1) == 0", FUNC(gamma) (1), 0);
1324 check_int ("gamma (0) sets signgam to 1", signgam, 1);
1326 signgam = 0;
1327 check ("gamma (3) == M_LN2", FUNC(gamma) (3), M_LN2);
1328 check_int ("gamma (3) sets signgam to 1", signgam, 1);
1330 signgam = 0;
1331 check_eps ("gamma (0.5) == log(sqrt(pi))", FUNC(gamma) (0.5),
1332 FUNC(log) (FUNC(sqrt) (M_PI)), CHOOSE (0, 1e-15, 1e-7));
1333 check_int ("gamma (0.5) sets signgam to 1", signgam, 1);
1335 signgam = 0;
1336 check_eps ("gamma (-0.5) == log(2*sqrt(pi))", FUNC(gamma) (-0.5),
1337 FUNC(log) (2*FUNC(sqrt) (M_PI)), CHOOSE (0, 1e-15, 0));
1339 check_int ("gamma (-0.5) sets signgam to -1", signgam, -1);
1342 _LIB_VERSION = _IEEE_;
1344 check_isinfp ("gamma (+inf) == +inf", FUNC(gamma) (plus_infty));
1345 check_isnan_exc ("gamma (0) == NaN plus invalid exception",
1346 FUNC(gamma) (0), INVALID_EXCEPTION);
1348 check_isnan_exc_ext ("gamma (x) == NaN plus invalid exception for integer x <= 0",
1349 FUNC(gamma) (-2), INVALID_EXCEPTION, -2);
1350 check_isnan_exc ("gamma (-inf) == NaN plus invalid exception",
1351 FUNC(gamma) (minus_infty), INVALID_EXCEPTION);
1353 check_eps ("gamma (0.5) == sqrt(pi)", FUNC(gamma) (0.5), FUNC(sqrt) (M_PI),
1354 CHOOSE (0, 5e-16, 2e-7));
1355 check_eps ("gamma (-0.5) == -2*sqrt(pi)", FUNC(gamma) (-0.5),
1356 -2*FUNC(sqrt) (M_PI), CHOOSE (0, 5e-16, 3e-7));
1358 check ("gamma (1) == 1", FUNC(gamma) (1), 1);
1359 check ("gamma (4) == 6", FUNC(gamma) (4), 6);
1361 _LIB_VERSION = save_lib_version;
1365 static void
1366 lgamma_test (void)
1368 errno = 0;
1369 FUNC(lgamma) (0);
1370 if (errno == ENOSYS)
1371 /* Function not implemented. */
1372 return;
1373 feclearexcept (FE_ALL_EXCEPT);
1375 check_isinfp ("lgamma (+inf) == +inf", FUNC(lgamma) (plus_infty));
1376 check_isinfp_exc ("lgamma (0) == +inf plus divide by zero exception",
1377 FUNC(lgamma) (0), DIVIDE_BY_ZERO_EXCEPTION);
1379 check_isinfp_exc ("lgamma (x) == +inf plus divide by zero exception for integer x <= 0",
1380 FUNC(lgamma) (-3), DIVIDE_BY_ZERO_EXCEPTION);
1381 check_isnan_exc ("lgamma (-inf) == NaN plus invalid exception",
1382 FUNC(lgamma) (minus_infty), INVALID_EXCEPTION);
1384 signgam = 0;
1385 check ("lgamma (1) == 0", FUNC(lgamma) (1), 0);
1386 check_int ("lgamma (0) sets signgam to 1", signgam, 1);
1388 signgam = 0;
1389 check ("lgamma (3) == M_LN2", FUNC(lgamma) (3), M_LN2);
1390 check_int ("lgamma (3) sets signgam to 1", signgam, 1);
1392 signgam = 0;
1393 check_eps ("lgamma (0.5) == log(sqrt(pi))", FUNC(lgamma) (0.5),
1394 FUNC(log) (FUNC(sqrt) (M_PI)), CHOOSE (0, 1e-15, 1e-7));
1395 check_int ("lgamma (0.5) sets signgam to 1", signgam, 1);
1397 signgam = 0;
1398 check_eps ("lgamma (-0.5) == log(2*sqrt(pi))", FUNC(lgamma) (-0.5),
1399 FUNC(log) (2*FUNC(sqrt) (M_PI)), CHOOSE (0, 1e-15, 0));
1401 check_int ("lgamma (-0.5) sets signgam to -1", signgam, -1);
1406 static void
1407 ilogb_test (void)
1409 int i;
1411 check_int ("ilogb (1) == 0", FUNC(ilogb) (1), 0);
1412 check_int ("ilogb (e) == 1", FUNC(ilogb) (M_E), 1);
1413 check_int ("ilogb (1024) == 10", FUNC(ilogb) (1024), 10);
1414 check_int ("ilogb (-2000) == 10", FUNC(ilogb) (-2000), 10);
1416 /* XXX We have a problem here: the standard does not tell us whether
1417 exceptions are allowed/required. ignore them for now. */
1418 i = FUNC (ilogb) (0.0);
1419 feclearexcept (FE_ALL_EXCEPT);
1420 check_int ("ilogb (0) == FP_ILOGB0", i, FP_ILOGB0);
1421 i = FUNC(ilogb) (nan_value);
1422 feclearexcept (FE_ALL_EXCEPT);
1423 check_int ("ilogb (NaN) == FP_ILOGBNAN", i, FP_ILOGBNAN);
1428 static void
1429 ldexp_test (void)
1431 MATHTYPE x;
1433 check ("ldexp (0, 0) == 0", FUNC(ldexp) (0, 0), 0);
1435 check_isinfp ("ldexp (+inf, 1) == +inf", FUNC(ldexp) (plus_infty, 1));
1436 check_isinfn ("ldexp (-inf, 1) == -inf", FUNC(ldexp) (minus_infty, 1));
1437 check_isnan ("ldexp (NaN, 1) == NaN", FUNC(ldexp) (nan_value, 1));
1439 check ("ldexp (0.8, 4) == 12.8", FUNC(ldexp) (0.8L, 4), 12.8L);
1440 check ("ldexp (-0.854375, 5) == -27.34", FUNC(ldexp) (-0.854375L, 5), -27.34L);
1442 x = random_greater (0.0);
1443 check_ext ("ldexp (x, 0) == x", FUNC(ldexp) (x, 0L), x, x);
1448 static void
1449 log_test (void)
1451 check_isinfn_exc ("log (+0) == -inf plus divide-by-zero exception",
1452 FUNC(log) (0), DIVIDE_BY_ZERO_EXCEPTION);
1453 check_isinfn_exc ("log (-0) == -inf plus divide-by-zero exception",
1454 FUNC(log) (minus_zero), DIVIDE_BY_ZERO_EXCEPTION);
1456 check ("log (1) == 0", FUNC(log) (1), 0);
1458 check_isnan_exc ("log (x) == NaN plus invalid exception if x < 0",
1459 FUNC(log) (-1), INVALID_EXCEPTION);
1460 check_isinfp ("log (+inf) == +inf", FUNC(log) (plus_infty));
1462 check_eps ("log (e) == 1", FUNC(log) (M_E), 1, CHOOSE (1e-18L, 0, 9e-8L));
1463 check_eps ("log (1/e) == -1", FUNC(log) (1.0 / M_E), -1,
1464 CHOOSE (2e-18L, 0, 0));
1465 check ("log (2) == M_LN2", FUNC(log) (2), M_LN2);
1466 check_eps ("log (10) == M_LN10", FUNC(log) (10), M_LN10,
1467 CHOOSE (1e-18L, 0, 0));
1471 static void
1472 log10_test (void)
1474 check_isinfn_exc ("log10 (+0) == -inf plus divide-by-zero exception",
1475 FUNC(log10) (0), DIVIDE_BY_ZERO_EXCEPTION);
1476 check_isinfn_exc ("log10 (-0) == -inf plus divide-by-zero exception",
1477 FUNC(log10) (minus_zero), DIVIDE_BY_ZERO_EXCEPTION);
1479 check ("log10 (1) == +0", FUNC(log10) (1), 0);
1481 check_isnan_exc ("log10 (x) == NaN plus invalid exception if x < 0",
1482 FUNC(log10) (-1), INVALID_EXCEPTION);
1484 check_isinfp ("log10 (+inf) == +inf", FUNC(log10) (plus_infty));
1486 check_eps ("log10 (0.1) == -1", FUNC(log10) (0.1L), -1,
1487 CHOOSE (1e-18L, 0, 0));
1488 check_eps ("log10 (10) == 1", FUNC(log10) (10.0), 1,
1489 CHOOSE (1e-18L, 0, 0));
1490 check_eps ("log10 (100) == 2", FUNC(log10) (100.0), 2,
1491 CHOOSE (1e-18L, 0, 0));
1492 check ("log10 (10000) == 4", FUNC(log10) (10000.0), 4);
1493 check_eps ("log10 (e) == M_LOG10E", FUNC(log10) (M_E), M_LOG10E,
1494 CHOOSE (1e-18, 0, 9e-8));
1498 static void
1499 log1p_test (void)
1501 check ("log1p (+0) == +0", FUNC(log1p) (0), 0);
1502 check ("log1p (-0) == -0", FUNC(log1p) (minus_zero), minus_zero);
1504 check_isinfn_exc ("log1p (-1) == -inf plus divide-by-zero exception",
1505 FUNC(log1p) (-1), DIVIDE_BY_ZERO_EXCEPTION);
1506 check_isnan_exc ("log1p (x) == NaN plus invalid exception if x < -1",
1507 FUNC(log1p) (-2), INVALID_EXCEPTION);
1509 check_isinfp ("log1p (+inf) == +inf", FUNC(log1p) (plus_infty));
1511 check_eps ("log1p (e-1) == 1", FUNC(log1p) (M_E - 1.0), 1,
1512 CHOOSE (1e-18L, 0, 6e-8));
1517 static void
1518 log2_test (void)
1520 check_isinfn_exc ("log2 (+0) == -inf plus divide-by-zero exception",
1521 FUNC(log2) (0), DIVIDE_BY_ZERO_EXCEPTION);
1522 check_isinfn_exc ("log2 (-0) == -inf plus divide-by-zero exception",
1523 FUNC(log2) (minus_zero), DIVIDE_BY_ZERO_EXCEPTION);
1525 check ("log2 (1) == +0", FUNC(log2) (1), 0);
1527 check_isnan_exc ("log2 (x) == NaN plus invalid exception if x < 0",
1528 FUNC(log2) (-1), INVALID_EXCEPTION);
1530 check_isinfp ("log2 (+inf) == +inf", FUNC(log2) (plus_infty));
1532 check_eps ("log2 (e) == M_LOG2E", FUNC(log2) (M_E), M_LOG2E,
1533 CHOOSE (1e-18L, 0, 0));
1534 check ("log2 (2) == 1", FUNC(log2) (2.0), 1);
1535 check_eps ("log2 (16) == 4", FUNC(log2) (16.0), 4, CHOOSE (1e-18L, 0, 0));
1536 check ("log2 (256) == 8", FUNC(log2) (256.0), 8);
1541 static void
1542 logb_test (void)
1544 check_isinfp ("logb (+inf) == +inf", FUNC(logb) (plus_infty));
1545 check_isinfp ("logb (-inf) == +inf", FUNC(logb) (minus_infty));
1547 check_isinfn_exc ("logb (+0) == -inf plus divide-by-zero exception",
1548 FUNC(logb) (0), DIVIDE_BY_ZERO_EXCEPTION);
1550 check_isinfn_exc ("logb (-0) == -inf plus divide-by-zero exception",
1551 FUNC(logb) (minus_zero), DIVIDE_BY_ZERO_EXCEPTION);
1553 check ("logb (1) == 0", FUNC(logb) (1), 0);
1554 check ("logb (e) == 1", FUNC(logb) (M_E), 1);
1555 check ("logb (1024) == 10", FUNC(logb) (1024), 10);
1556 check ("logb (-2000) == 10", FUNC(logb) (-2000), 10);
1561 static void
1562 modf_test (void)
1564 MATHTYPE result, intpart;
1566 result = FUNC(modf) (plus_infty, &intpart);
1567 check ("modf (+inf, &x) returns +0", result, 0);
1568 check_isinfp ("modf (+inf, &x) set x to +inf", intpart);
1570 result = FUNC(modf) (minus_infty, &intpart);
1571 check ("modf (-inf, &x) returns -0", result, minus_zero);
1572 check_isinfn ("modf (-inf, &x) sets x to -inf", intpart);
1574 result = FUNC(modf) (nan_value, &intpart);
1575 check_isnan ("modf (NaN, &x) returns NaN", result);
1576 check_isnan ("modf (NaN, &x) sets x to NaN", intpart);
1578 result = FUNC(modf) (0, &intpart);
1579 check ("modf (0, &x) returns 0", result, 0);
1580 check ("modf (0, &x) sets x to 0", intpart, 0);
1582 result = FUNC(modf) (minus_zero, &intpart);
1583 check ("modf (-0, &x) returns -0", result, minus_zero);
1584 check ("modf (-0, &x) sets x to -0", intpart, minus_zero);
1586 result = FUNC(modf) (2.5, &intpart);
1587 check ("modf (2.5, &x) returns 0.5", result, 0.5);
1588 check ("modf (2.5, &x) sets x to 2", intpart, 2);
1590 result = FUNC(modf) (-2.5, &intpart);
1591 check ("modf (-2.5, &x) returns -0.5", result, -0.5);
1592 check ("modf (-2.5, &x) sets x to -2", intpart, -2);
1597 static void
1598 scalb_test (void)
1600 MATHTYPE x;
1602 check_isnan ("scalb (2, 0.5) == NaN", FUNC(scalb) (2, 0.5));
1603 check_isnan ("scalb (3, -2.5) == NaN", FUNC(scalb) (3, -2.5));
1605 check_isnan ("scalb (0, NaN) == NaN", FUNC(scalb) (0, nan_value));
1606 check_isnan ("scalb (1, NaN) == NaN", FUNC(scalb) (1, nan_value));
1608 x = random_greater (0.0);
1609 check ("scalb (x, 0) == 0", FUNC(scalb) (x, 0), x);
1610 x = random_greater (0.0);
1611 check ("scalb (-x, 0) == 0", FUNC(scalb) (-x, 0), -x);
1613 check_isnan_exc ("scalb (+0, +inf) == NaN plus invalid exception",
1614 FUNC(scalb) (0, plus_infty), INVALID_EXCEPTION);
1615 check_isnan_exc ("scalb (-0, +inf) == NaN plus invalid exception",
1616 FUNC(scalb) (minus_zero, plus_infty), INVALID_EXCEPTION);
1618 check ("scalb (+0, 2) == +0", FUNC(scalb) (0, 2), 0);
1619 check ("scalb (-0, 4) == -0", FUNC(scalb) (minus_zero, -4), minus_zero);
1620 check ("scalb (+0, 0) == +0", FUNC(scalb) (0, 0), 0);
1621 check ("scalb (-0, 0) == -0", FUNC(scalb) (minus_zero, 0), minus_zero);
1622 check ("scalb (+0, -1) == +0", FUNC(scalb) (0, -1), 0);
1623 check ("scalb (-0, -10) == -0", FUNC(scalb) (minus_zero, -10), minus_zero);
1624 check ("scalb (+0, -inf) == +0", FUNC(scalb) (0, minus_infty), 0);
1625 check ("scalb (-0, -inf) == -0", FUNC(scalb) (minus_zero, minus_infty),
1626 minus_zero);
1628 check_isinfp ("scalb (+inf, -1) == +inf", FUNC(scalb) (plus_infty, -1));
1629 check_isinfn ("scalb (-inf, -10) == -inf", FUNC(scalb) (minus_infty, -10));
1630 check_isinfp ("scalb (+inf, 0) == +inf", FUNC(scalb) (plus_infty, 0));
1631 check_isinfn ("scalb (-inf, 0) == -inf", FUNC(scalb) (minus_infty, 0));
1632 check_isinfp ("scalb (+inf, 2) == +inf", FUNC(scalb) (plus_infty, 2));
1633 check_isinfn ("scalb (-inf, 100) == -inf", FUNC(scalb) (minus_infty, 100));
1635 x = random_greater (0.0);
1636 check ("scalb (x, -inf) == 0", FUNC(scalb) (x, minus_infty), 0.0);
1637 check ("scalb (-x, -inf) == -0", FUNC(scalb) (-x, minus_infty), minus_zero);
1639 x = random_greater (0.0);
1640 check_isinfp ("scalb (x, +inf) == +inf", FUNC(scalb) (x, plus_infty));
1641 x = random_greater (0.0);
1642 check_isinfn ("scalb (-x, +inf) == -inf", FUNC(scalb) (-x, plus_infty));
1643 check_isinfp ("scalb (+inf, +inf) == +inf",
1644 FUNC(scalb) (plus_infty, plus_infty));
1645 check_isinfn ("scalb (-inf, +inf) == -inf",
1646 FUNC(scalb) (minus_infty, plus_infty));
1648 check_isnan ("scalb (+inf, -inf) == NaN",
1649 FUNC(scalb) (plus_infty, minus_infty));
1650 check_isnan ("scalb (-inf, -inf) == NaN",
1651 FUNC(scalb) (minus_infty, minus_infty));
1653 check_isnan ("scalb (NaN, 1) == NaN", FUNC(scalb) (nan_value, 1));
1654 check_isnan ("scalb (1, NaN) == NaN", FUNC(scalb) (1, nan_value));
1655 check_isnan ("scalb (NaN, 0) == NaN", FUNC(scalb) (nan_value, 0));
1656 check_isnan ("scalb (0, NaN) == NaN", FUNC(scalb) (0, nan_value));
1657 check_isnan ("scalb (NaN, +inf) == NaN",
1658 FUNC(scalb) (nan_value, plus_infty));
1659 check_isnan ("scalb (+inf, NaN) == NaN",
1660 FUNC(scalb) (plus_infty, nan_value));
1661 check_isnan ("scalb (NaN, NaN) == NaN", FUNC(scalb) (nan_value, nan_value));
1663 check ("scalb (0.8, 4) == 12.8", FUNC(scalb) (0.8L, 4), 12.8L);
1664 check ("scalb (-0.854375, 5) == -27.34", FUNC(scalb) (-0.854375L, 5), -27.34L);
1668 static void
1669 scalbn_test (void)
1671 MATHTYPE x;
1673 check ("scalbn (0, 0) == 0", FUNC(scalbn) (0, 0), 0);
1675 check_isinfp ("scalbn (+inf, 1) == +inf", FUNC(scalbn) (plus_infty, 1));
1676 check_isinfn ("scalbn (-inf, 1) == -inf", FUNC(scalbn) (minus_infty, 1));
1677 check_isnan ("scalbn (NaN, 1) == NaN", FUNC(scalbn) (nan_value, 1));
1679 check ("scalbn (0.8, 4) == 12.8", FUNC(scalbn) (0.8L, 4), 12.8L);
1680 check ("scalbn (-0.854375, 5) == -27.34", FUNC(scalbn) (-0.854375L, 5), -27.34L);
1682 x = random_greater (0.0);
1683 check_ext ("scalbn (x, 0) == x", FUNC(scalbn) (x, 0L), x, x);
1687 static void
1688 sin_test (void)
1690 check ("sin (+0) == +0", FUNC(sin) (0), 0);
1691 check ("sin (-0) == -0", FUNC(sin) (minus_zero), minus_zero);
1692 check_isnan_exc ("sin (+inf) == NaN plus invalid exception",
1693 FUNC(sin) (plus_infty),
1694 INVALID_EXCEPTION);
1695 check_isnan_exc ("sin (-inf) == NaN plus invalid exception",
1696 FUNC(sin) (minus_infty),
1697 INVALID_EXCEPTION);
1699 check_eps ("sin (pi/6) == 0.5", FUNC(sin) (M_PI_6),
1700 0.5,CHOOSE (4e-18L, 0, 0));
1701 check ("sin (pi/2) == 1", FUNC(sin) (M_PI_2), 1);
1705 static void
1706 sinh_test (void)
1708 check ("sinh (+0) == +0", FUNC(sinh) (0), 0);
1710 #ifndef TEST_INLINE
1711 check ("sinh (-0) == -0", FUNC(sinh) (minus_zero), minus_zero);
1713 check_isinfp ("sinh (+inf) == +inf", FUNC(sinh) (plus_infty));
1714 check_isinfn ("sinh (-inf) == -inf", FUNC(sinh) (minus_infty));
1715 #endif
1719 static void
1720 sincos_test (void)
1722 MATHTYPE sin_res, cos_res;
1723 fenv_t fenv;
1725 FUNC(sincos) (0, &sin_res, &cos_res);
1726 fegetenv (&fenv);
1727 check ("sincos (+0, &sin, &cos) puts +0 in sin", sin_res, 0);
1728 fesetenv (&fenv);
1729 check ("sincos (+0, &sin, &cos) puts 1 in cos", cos_res, 1);
1731 FUNC(sincos) (minus_zero, &sin_res, &cos_res);
1732 fegetenv (&fenv);
1733 check ("sincos (-0, &sin, &cos) puts -0 in sin", sin_res, minus_zero);
1734 fesetenv (&fenv);
1735 check ("sincos (-0, &sin, &cos) puts 1 in cos", cos_res, 1);
1737 FUNC(sincos) (plus_infty, &sin_res, &cos_res);
1738 fegetenv (&fenv);
1739 check_isnan_exc ("sincos (+inf, &sin, &cos) puts NaN in sin plus invalid exception",
1740 sin_res, INVALID_EXCEPTION);
1741 fesetenv (&fenv);
1742 check_isnan_exc ("sincos (+inf, &sin, &cos) puts NaN in cos plus invalid exception",
1743 cos_res, INVALID_EXCEPTION);
1745 FUNC(sincos) (minus_infty, &sin_res, &cos_res);
1746 fegetenv (&fenv);
1747 check_isnan_exc ("sincos (-inf,&sin, &cos) puts NaN in sin plus invalid exception",
1748 sin_res, INVALID_EXCEPTION);
1749 fesetenv (&fenv);
1750 check_isnan_exc ("sincos (-inf,&sin, &cos) puts NaN in cos plus invalid exception",
1751 cos_res, INVALID_EXCEPTION);
1753 FUNC(sincos) (M_PI_2, &sin_res, &cos_res);
1754 fegetenv (&fenv);
1755 check ("sincos (pi/2, &sin, &cos) puts 1 in sin", sin_res, 1);
1756 fesetenv (&fenv);
1757 check_eps ("sincos (pi/2, &sin, &cos) puts 0 in cos", cos_res, 0,
1758 CHOOSE (1e-18L, 1e-16, 1e-7));
1760 FUNC(sincos) (M_PI_6, &sin_res, &cos_res);
1761 check_eps ("sincos (pi/6, &sin, &cos) puts 0.5 in sin", sin_res, 0.5,
1762 CHOOSE (5e-18L, 0, 0));
1764 FUNC(sincos) (M_PI_6*2.0, &sin_res, &cos_res);
1765 check_eps ("sincos (pi/3, &sin, &cos) puts 0.5 in cos", cos_res, 0.5,
1766 CHOOSE (5e-18L, 1e-15, 1e-7));
1772 static void
1773 tan_test (void)
1775 check ("tan (+0) == +0", FUNC(tan) (0), 0);
1776 check ("tan (-0) == -0", FUNC(tan) (minus_zero), minus_zero);
1777 check_isnan_exc ("tan (+inf) == NaN plus invalid exception",
1778 FUNC(tan) (plus_infty), INVALID_EXCEPTION);
1779 check_isnan_exc ("tan (-inf) == NaN plus invalid exception",
1780 FUNC(tan) (minus_infty), INVALID_EXCEPTION);
1782 check_eps ("tan (pi/4) == 1", FUNC(tan) (M_PI_4), 1,
1783 CHOOSE (2e-18L, 1e-15L, 2e-7));
1787 static void
1788 tanh_test (void)
1790 check ("tanh (+0) == +0", FUNC(tanh) (0), 0);
1791 #ifndef TEST_INLINE
1792 check ("tanh (-0) == -0", FUNC(tanh) (minus_zero), minus_zero);
1794 check ("tanh (+inf) == +1", FUNC(tanh) (plus_infty), 1);
1795 check ("tanh (-inf) == -1", FUNC(tanh) (minus_infty), -1);
1796 #endif
1800 static void
1801 fabs_test (void)
1803 check ("fabs (+0) == +0", FUNC(fabs) (0), 0);
1804 check ("fabs (-0) == +0", FUNC(fabs) (minus_zero), 0);
1806 check_isinfp ("fabs (+inf) == +inf", FUNC(fabs) (plus_infty));
1807 check_isinfp ("fabs (-inf) == +inf", FUNC(fabs) (minus_infty));
1809 check ("fabs (+38) == 38", FUNC(fabs) (38.0), 38.0);
1810 check ("fabs (-e) == e", FUNC(fabs) (-M_E), M_E);
1814 static void
1815 floor_test (void)
1817 check ("floor (+0) == +0", FUNC(floor) (0.0), 0.0);
1818 check ("floor (-0) == -0", FUNC(floor) (minus_zero), minus_zero);
1819 check_isinfp ("floor (+inf) == +inf", FUNC(floor) (plus_infty));
1820 check_isinfn ("floor (-inf) == -inf", FUNC(floor) (minus_infty));
1822 check ("floor (pi) == 3", FUNC(floor) (M_PI), 3.0);
1823 check ("floor (-pi) == -4", FUNC(floor) (-M_PI), -4.0);
1827 static void
1828 hypot_test (void)
1830 MATHTYPE a;
1832 a = random_greater (0);
1833 check_isinfp_ext ("hypot (+inf, x) == +inf", FUNC(hypot) (plus_infty, a), a);
1834 check_isinfp_ext ("hypot (-inf, x) == +inf", FUNC(hypot) (minus_infty, a), a);
1836 #ifndef TEST_INLINE
1837 check_isinfp ("hypot (+inf, NaN) == +inf", FUNC(hypot) (minus_infty, nan_value));
1838 check_isinfp ("hypot (-inf, NaN) == +inf", FUNC(hypot) (minus_infty, nan_value));
1839 #endif
1841 check_isnan ("hypot (NaN, NaN) == NaN", FUNC(hypot) (nan_value, nan_value));
1843 a = FUNC(hypot) (12.4L, 0.7L);
1844 check ("hypot (x,y) == hypot (y,x)", FUNC(hypot) (0.7L, 12.4L), a);
1845 check ("hypot (x,y) == hypot (-x,y)", FUNC(hypot) (-12.4L, 0.7L), a);
1846 check ("hypot (x,y) == hypot (-y,x)", FUNC(hypot) (-0.7L, 12.4L), a);
1847 check ("hypot (x,y) == hypot (-x,-y)", FUNC(hypot) (-12.4L, -0.7L), a);
1848 check ("hypot (x,y) == hypot (-y,-x)", FUNC(hypot) (-0.7L, -12.4L), a);
1849 check ("hypot (x,0) == fabs (x)", FUNC(hypot) (-0.7L, 0), 0.7L);
1850 check ("hypot (x,0) == fabs (x)", FUNC(hypot) (0.7L, 0), 0.7L);
1851 check ("hypot (x,0) == fabs (x)", FUNC(hypot) (-1.0L, 0), 1.0L);
1852 check ("hypot (x,0) == fabs (x)", FUNC(hypot) (1.0L, 0), 1.0L);
1853 check ("hypot (x,0) == fabs (x)", FUNC(hypot) (-5.7e7L, 0), 5.7e7L);
1854 check ("hypot (x,0) == fabs (x)", FUNC(hypot) (5.7e7L, 0), 5.7e7L);
1858 static void
1859 pow_test (void)
1861 MATHTYPE x;
1863 check ("pow (+0, +0) == 1", FUNC(pow) (0, 0), 1);
1864 check ("pow (+0, -0) == 1", FUNC(pow) (0, minus_zero), 1);
1865 check ("pow (-0, +0) == 1", FUNC(pow) (minus_zero, 0), 1);
1866 check ("pow (-0, -0) == 1", FUNC(pow) (minus_zero, minus_zero), 1);
1868 check ("pow (+10, +0) == 1", FUNC(pow) (10, 0), 1);
1869 check ("pow (+10, -0) == 1", FUNC(pow) (10, minus_zero), 1);
1870 check ("pow (-10, +0) == 1", FUNC(pow) (-10, 0), 1);
1871 check ("pow (-10, -0) == 1", FUNC(pow) (-10, minus_zero), 1);
1873 check ("pow (NaN, +0) == 1", FUNC(pow) (nan_value, 0), 1);
1874 check ("pow (NaN, -0) == 1", FUNC(pow) (nan_value, minus_zero), 1);
1876 #ifndef TEST_INLINE
1877 check_isinfp ("pow (+1.1, +inf) == +inf", FUNC(pow) (1.1, plus_infty));
1878 check_isinfp ("pow (+inf, +inf) == +inf", FUNC(pow) (plus_infty, plus_infty));
1879 check_isinfp ("pow (-1.1, +inf) == +inf", FUNC(pow) (-1.1, plus_infty));
1880 check_isinfp ("pow (-inf, +inf) == +inf", FUNC(pow) (minus_infty, plus_infty));
1882 check ("pow (0.9, +inf) == +0", FUNC(pow) (0.9L, plus_infty), 0);
1883 check ("pow (1e-7, +inf) == +0", FUNC(pow) (1e-7L, plus_infty), 0);
1884 check ("pow (-0.9, +inf) == +0", FUNC(pow) (-0.9L, plus_infty), 0);
1885 check ("pow (-1e-7, +inf) == +0", FUNC(pow) (-1e-7L, plus_infty), 0);
1887 check ("pow (+1.1, -inf) == 0", FUNC(pow) (1.1, minus_infty), 0);
1888 check ("pow (+inf, -inf) == 0", FUNC(pow) (plus_infty, minus_infty), 0);
1889 check ("pow (-1.1, -inf) == 0", FUNC(pow) (-1.1, minus_infty), 0);
1890 check ("pow (-inf, -inf) == 0", FUNC(pow) (minus_infty, minus_infty), 0);
1892 check_isinfp ("pow (0.9, -inf) == +inf", FUNC(pow) (0.9L, minus_infty));
1893 check_isinfp ("pow (1e-7, -inf) == +inf", FUNC(pow) (1e-7L, minus_infty));
1894 check_isinfp ("pow (-0.9, -inf) == +inf", FUNC(pow) (-0.9L, minus_infty));
1895 check_isinfp ("pow (-1e-7, -inf) == +inf", FUNC(pow) (-1e-7L, minus_infty));
1897 check_isinfp ("pow (+inf, 1e-7) == +inf", FUNC(pow) (plus_infty, 1e-7L));
1898 check_isinfp ("pow (+inf, 1) == +inf", FUNC(pow) (plus_infty, 1));
1899 check_isinfp ("pow (+inf, 1e7) == +inf", FUNC(pow) (plus_infty, 1e7L));
1901 check ("pow (+inf, -1e-7) == 0", FUNC(pow) (plus_infty, -1e-7L), 0);
1902 check ("pow (+inf, -1) == 0", FUNC(pow) (plus_infty, -1), 0);
1903 check ("pow (+inf, -1e7) == 0", FUNC(pow) (plus_infty, -1e7L), 0);
1905 check_isinfn ("pow (-inf, 1) == -inf", FUNC(pow) (minus_infty, 1));
1906 check_isinfn ("pow (-inf, 11) == -inf", FUNC(pow) (minus_infty, 11));
1907 check_isinfn ("pow (-inf, 1001) == -inf", FUNC(pow) (minus_infty, 1001));
1909 check_isinfp ("pow (-inf, 2) == +inf", FUNC(pow) (minus_infty, 2));
1910 check_isinfp ("pow (-inf, 12) == +inf", FUNC(pow) (minus_infty, 12));
1911 check_isinfp ("pow (-inf, 1002) == +inf", FUNC(pow) (minus_infty, 1002));
1912 check_isinfp ("pow (-inf, 0.1) == +inf", FUNC(pow) (minus_infty, 0.1));
1913 check_isinfp ("pow (-inf, 1.1) == +inf", FUNC(pow) (minus_infty, 1.1));
1914 check_isinfp ("pow (-inf, 11.1) == +inf", FUNC(pow) (minus_infty, 11.1));
1915 check_isinfp ("pow (-inf, 1001.1) == +inf", FUNC(pow) (minus_infty, 1001.1));
1917 check ("pow (-inf, -1) == -0", FUNC(pow) (minus_infty, -1), minus_zero);
1918 check ("pow (-inf, -11) == -0", FUNC(pow) (minus_infty, -11), minus_zero);
1919 check ("pow (-inf, -1001) == -0", FUNC(pow) (minus_infty, -1001), minus_zero);
1921 check ("pow (-inf, -2) == +0", FUNC(pow) (minus_infty, -2), 0);
1922 check ("pow (-inf, -12) == +0", FUNC(pow) (minus_infty, -12), 0);
1923 check ("pow (-inf, -1002) == +0", FUNC(pow) (minus_infty, -1002), 0);
1924 check ("pow (-inf, -0.1) == +0", FUNC(pow) (minus_infty, -0.1), 0);
1925 check ("pow (-inf, -1.1) == +0", FUNC(pow) (minus_infty, -1.1), 0);
1926 check ("pow (-inf, -11.1) == +0", FUNC(pow) (minus_infty, -11.1), 0);
1927 check ("pow (-inf, -1001.1) == +0", FUNC(pow) (minus_infty, -1001.1), 0);
1929 check_isnan ("pow (NaN, NaN) == NaN", FUNC(pow) (nan_value, nan_value));
1930 check_isnan ("pow (0, NaN) == NaN", FUNC(pow) (0, nan_value));
1931 check_isnan ("pow (1, NaN) == NaN", FUNC(pow) (1, nan_value));
1932 check_isnan ("pow (-1, NaN) == NaN", FUNC(pow) (-1, nan_value));
1933 check_isnan ("pow (NaN, 1) == NaN", FUNC(pow) (nan_value, 1));
1934 check_isnan ("pow (NaN, -1) == NaN", FUNC(pow) (nan_value, -1));
1936 x = random_greater (0.0);
1937 check_isnan_ext ("pow (x, NaN) == NaN", FUNC(pow) (x, nan_value), x);
1939 check_isnan_exc ("pow (+1, +inf) == NaN plus invalid exception",
1940 FUNC(pow) (1, plus_infty), INVALID_EXCEPTION);
1941 check_isnan_exc ("pow (-1, +inf) == NaN plus invalid exception",
1942 FUNC(pow) (-1, plus_infty), INVALID_EXCEPTION);
1943 check_isnan_exc ("pow (+1, -inf) == NaN plus invalid exception",
1944 FUNC(pow) (1, minus_infty), INVALID_EXCEPTION);
1945 check_isnan_exc ("pow (-1, -inf) == NaN plus invalid exception",
1946 FUNC(pow) (-1, minus_infty), INVALID_EXCEPTION);
1948 check_isnan_exc ("pow (-0.1, 1.1) == NaN plus invalid exception",
1949 FUNC(pow) (-0.1, 1.1), INVALID_EXCEPTION);
1950 check_isnan_exc ("pow (-0.1, -1.1) == NaN plus invalid exception",
1951 FUNC(pow) (-0.1, -1.1), INVALID_EXCEPTION);
1952 check_isnan_exc ("pow (-10.1, 1.1) == NaN plus invalid exception",
1953 FUNC(pow) (-10.1, 1.1), INVALID_EXCEPTION);
1954 check_isnan_exc ("pow (-10.1, -1.1) == NaN plus invalid exception",
1955 FUNC(pow) (-10.1, -1.1), INVALID_EXCEPTION);
1957 check_isinfp_exc ("pow (+0, -1) == +inf plus divide-by-zero exception",
1958 FUNC(pow) (0, -1), DIVIDE_BY_ZERO_EXCEPTION);
1959 check_isinfp_exc ("pow (+0, -11) == +inf plus divide-by-zero exception",
1960 FUNC(pow) (0, -11), DIVIDE_BY_ZERO_EXCEPTION);
1961 check_isinfn_exc ("pow (-0, -1) == -inf plus divide-by-zero exception",
1962 FUNC(pow) (minus_zero, -1), DIVIDE_BY_ZERO_EXCEPTION);
1963 check_isinfn_exc ("pow (-0, -11) == -inf plus divide-by-zero exception",
1964 FUNC(pow) (minus_zero, -11), DIVIDE_BY_ZERO_EXCEPTION);
1966 check_isinfp_exc ("pow (+0, -2) == +inf plus divide-by-zero exception",
1967 FUNC(pow) (0, -2), DIVIDE_BY_ZERO_EXCEPTION);
1968 check_isinfp_exc ("pow (+0, -11.1) == +inf plus divide-by-zero exception",
1969 FUNC(pow) (0, -11.1), DIVIDE_BY_ZERO_EXCEPTION);
1970 check_isinfp_exc ("pow (-0, -2) == +inf plus divide-by-zero exception",
1971 FUNC(pow) (minus_zero, -2), DIVIDE_BY_ZERO_EXCEPTION);
1972 check_isinfp_exc ("pow (-0, -11.1) == +inf plus divide-by-zero exception",
1973 FUNC(pow) (minus_zero, -11.1), DIVIDE_BY_ZERO_EXCEPTION);
1974 #endif
1976 check ("pow (+0, 1) == +0", FUNC(pow) (0, 1), 0);
1977 check ("pow (+0, 11) == +0", FUNC(pow) (0, 11), 0);
1978 #ifndef TEST_INLINE
1979 check ("pow (-0, 1) == -0", FUNC(pow) (minus_zero, 1), minus_zero);
1980 check ("pow (-0, 11) == -0", FUNC(pow) (minus_zero, 11), minus_zero);
1981 #endif
1983 check ("pow (+0, 2) == +0", FUNC(pow) (0, 2), 0);
1984 check ("pow (+0, 11.1) == +0", FUNC(pow) (0, 11.1), 0);
1986 #ifndef TEST_INLINE
1987 check ("pow (-0, 2) == +0", FUNC(pow) (minus_zero, 2), 0);
1988 check ("pow (-0, 11.1) == +0", FUNC(pow) (minus_zero, 11.1), 0);
1990 x = random_greater (1.0);
1991 check_isinfp_ext ("pow (x, +inf) == +inf for |x| > 1",
1992 FUNC(pow) (x, plus_infty), x);
1994 x = random_value (-1.0, 1.0);
1995 check_ext ("pow (x, +inf) == +0 for |x| < 1",
1996 FUNC(pow) (x, plus_infty), 0.0, x);
1998 x = random_greater (1.0);
1999 check_ext ("pow (x, -inf) == +0 for |x| > 1",
2000 FUNC(pow) (x, minus_infty), 0.0, x);
2002 x = random_value (-1.0, 1.0);
2003 check_isinfp_ext ("pow (x, -inf) == +inf for |x| < 1",
2004 FUNC(pow) (x, minus_infty), x);
2006 x = random_greater (0.0);
2007 check_isinfp_ext ("pow (+inf, y) == +inf for y > 0",
2008 FUNC(pow) (plus_infty, x), x);
2010 x = random_less (0.0);
2011 check_ext ("pow (+inf, y) == +0 for y < 0",
2012 FUNC(pow) (plus_infty, x), 0.0, x);
2014 x = (rand () % 1000000) * 2.0 + 1; /* Get random odd integer > 0 */
2015 check_isinfn_ext ("pow (-inf, y) == -inf for y an odd integer > 0",
2016 FUNC(pow) (minus_infty, x), x);
2018 x = ((rand () % 1000000) + 1) * 2.0; /* Get random even integer > 1 */
2019 check_isinfp_ext ("pow (-inf, y) == +inf for y > 0 and not an odd integer",
2020 FUNC(pow) (minus_infty, x), x);
2022 x = -((rand () % 1000000) * 2.0 + 1); /* Get random odd integer < 0 */
2023 check_ext ("pow (-inf, y) == -0 for y an odd integer < 0",
2024 FUNC(pow) (minus_infty, x), minus_zero, x);
2026 x = ((rand () % 1000000) + 1) * -2.0; /* Get random even integer < 0 */
2027 check_ext ("pow (-inf, y) == +0 for y < 0 and not an odd integer",
2028 FUNC(pow) (minus_infty, x), 0.0, x);
2029 #endif
2031 x = (rand () % 1000000) * 2.0 + 1; /* Get random odd integer > 0 */
2032 check_ext ("pow (+0, y) == +0 for y an odd integer > 0",
2033 FUNC(pow) (0.0, x), 0.0, x);
2034 #ifndef TEST_INLINE
2035 x = (rand () % 1000000) * 2.0 + 1; /* Get random odd integer > 0 */
2036 check_ext ("pow (-0, y) == -0 for y an odd integer > 0",
2037 FUNC(pow) (minus_zero, x), minus_zero, x);
2038 #endif
2040 x = ((rand () % 1000000) + 1) * 2.0; /* Get random even integer > 1 */
2041 check_ext ("pow (+0, y) == +0 for y > 0 and not an odd integer",
2042 FUNC(pow) (0.0, x), 0.0, x);
2044 x = ((rand () % 1000000) + 1) * 2.0; /* Get random even integer > 1 */
2045 check_ext ("pow (-0, y) == +0 for y > 0 and not an odd integer",
2046 FUNC(pow) (minus_zero, x), 0.0, x);
2050 static void
2051 fdim_test (void)
2053 check ("fdim (+0, +0) = +0", FUNC(fdim) (0, 0), 0);
2054 check ("fdim (9, 0) = 9", FUNC(fdim) (9, 0), 9);
2055 check ("fdim (0, 9) = 0", FUNC(fdim) (0, 9), 0);
2056 check ("fdim (-9, 0) = 9", FUNC(fdim) (-9, 0), 0);
2057 check ("fdim (0, -9) = 9", FUNC(fdim) (0, -9), 9);
2059 check_isinfp ("fdim (+inf, 9) = +inf", FUNC(fdim) (plus_infty, 9));
2060 check_isinfp ("fdim (+inf, -9) = +inf", FUNC(fdim) (plus_infty, -9));
2061 check ("fdim (-inf, 9) = 0", FUNC(fdim) (minus_infty, 9), 0);
2062 check ("fdim (-inf, -9) = 0", FUNC(fdim) (minus_infty, -9), 0);
2063 check_isinfp ("fdim (+9, -inf) = +inf", FUNC(fdim) (9, minus_infty));
2064 check_isinfp ("fdim (-9, -inf) = +inf", FUNC(fdim) (-9, minus_infty));
2065 check ("fdim (9, inf) = 0", FUNC(fdim) (9, plus_infty), 0);
2066 check ("fdim (-9, inf) = 0", FUNC(fdim) (-9, plus_infty), 0);
2068 check_isnan ("fdim (0, NaN) = NaN", FUNC(fdim) (0, nan_value));
2069 check_isnan ("fdim (9, NaN) = NaN", FUNC(fdim) (9, nan_value));
2070 check_isnan ("fdim (-9, NaN) = NaN", FUNC(fdim) (-9, nan_value));
2071 check_isnan ("fdim (NaN, 9) = NaN", FUNC(fdim) (nan_value, 9));
2072 check_isnan ("fdim (NaN, -9) = NaN", FUNC(fdim) (nan_value, -9));
2073 check_isnan ("fdim (+inf, NaN) = NaN", FUNC(fdim) (plus_infty, nan_value));
2074 check_isnan ("fdim (-inf, NaN) = NaN", FUNC(fdim) (minus_infty, nan_value));
2075 check_isnan ("fdim (NaN, +inf) = NaN", FUNC(fdim) (nan_value, plus_infty));
2076 check_isnan ("fdim (NaN, -inf) = NaN", FUNC(fdim) (nan_value, minus_infty));
2077 check_isnan ("fdim (NaN, NaN) = NaN", FUNC(fdim) (nan_value, nan_value));
2081 static void
2082 fmin_test (void)
2084 check ("fmin (+0, +0) = +0", FUNC(fmin) (0, 0), 0);
2085 check ("fmin (9, 0) = 0", FUNC(fmin) (9, 0), 0);
2086 check ("fmin (0, 9) = 0", FUNC(fmin) (0, 9), 0);
2087 check ("fmin (-9, 0) = -9", FUNC(fmin) (-9, 0), -9);
2088 check ("fmin (0, -9) = -9", FUNC(fmin) (0, -9), -9);
2090 check ("fmin (+inf, 9) = 9", FUNC(fmin) (plus_infty, 9), 9);
2091 check ("fmin (9, +inf) = 9", FUNC(fmin) (9, plus_infty), 9);
2092 check ("fmin (+inf, -9) = -9", FUNC(fmin) (plus_infty, -9), -9);
2093 check ("fmin (-9, +inf) = -9", FUNC(fmin) (-9, plus_infty), -9);
2094 check_isinfn ("fmin (-inf, 9) = -inf", FUNC(fmin) (minus_infty, 9));
2095 check_isinfn ("fmin (-inf, -9) = -inf", FUNC(fmin) (minus_infty, -9));
2096 check_isinfn ("fmin (+9, -inf) = -inf", FUNC(fmin) (9, minus_infty));
2097 check_isinfn ("fmin (-9, -inf) = -inf", FUNC(fmin) (-9, minus_infty));
2099 check ("fmin (0, NaN) = 0", FUNC(fmin) (0, nan_value), 0);
2100 check ("fmin (9, NaN) = 9", FUNC(fmin) (9, nan_value), 9);
2101 check ("fmin (-9, NaN) = 9", FUNC(fmin) (-9, nan_value), -9);
2102 check ("fmin (NaN, 0) = 0", FUNC(fmin) (nan_value, 0), 0);
2103 check ("fmin (NaN, 9) = NaN", FUNC(fmin) (nan_value, 9), 9);
2104 check ("fmin (NaN, -9) = NaN", FUNC(fmin) (nan_value, -9), -9);
2105 check_isinfp ("fmin (+inf, NaN) = +inf", FUNC(fmin) (plus_infty, nan_value));
2106 check_isinfn ("fmin (-inf, NaN) = -inf", FUNC(fmin) (minus_infty, nan_value));
2107 check_isinfp ("fmin (NaN, +inf) = +inf", FUNC(fmin) (nan_value, plus_infty));
2108 check_isinfn ("fmin (NaN, -inf) = -inf", FUNC(fmin) (nan_value, minus_infty));
2109 check_isnan ("fmin (NaN, NaN) = NaN", FUNC(fmin) (nan_value, nan_value));
2113 static void
2114 fmax_test (void)
2116 check ("fmax (+0, +0) = +0", FUNC(fmax) (0, 0), 0);
2117 check ("fmax (9, 0) = 9", FUNC(fmax) (9, 0), 9);
2118 check ("fmax (0, 9) = 9", FUNC(fmax) (0, 9), 9);
2119 check ("fmax (-9, 0) = 0", FUNC(fmax) (-9, 0), 0);
2120 check ("fmax (0, -9) = 0", FUNC(fmax) (0, -9), 0);
2122 check_isinfp ("fmax (+inf, 9) = +inf", FUNC(fmax) (plus_infty, 9));
2123 check_isinfp ("fmax (9, +inf) = +inf", FUNC(fmax) (0, plus_infty));
2124 check_isinfp ("fmax (-9, +inf) = +inf", FUNC(fmax) (-9, plus_infty));
2125 check_isinfp ("fmax (+inf, -9) = +inf", FUNC(fmax) (plus_infty, -9));
2126 check ("fmax (-inf, 9) = 9", FUNC(fmax) (minus_infty, 9), 9);
2127 check ("fmax (-inf, -9) = -9", FUNC(fmax) (minus_infty, -9), -9);
2128 check ("fmax (+9, -inf) = 9", FUNC(fmax) (9, minus_infty), 9);
2129 check ("fmax (-9, -inf) = -9", FUNC(fmax) (-9, minus_infty), -9);
2131 check ("fmax (0, NaN) = 0", FUNC(fmax) (0, nan_value), 0);
2132 check ("fmax (9, NaN) = 9", FUNC(fmax) (9, nan_value), 9);
2133 check ("fmax (-9, NaN) = 9", FUNC(fmax) (-9, nan_value), -9);
2134 check ("fmax (NaN, 0) = 0", FUNC(fmax) (nan_value, 0), 0);
2135 check ("fmax (NaN, 9) = NaN", FUNC(fmax) (nan_value, 9), 9);
2136 check ("fmax (NaN, -9) = NaN", FUNC(fmax) (nan_value, -9), -9);
2137 check_isinfp ("fmax (+inf, NaN) = +inf", FUNC(fmax) (plus_infty, nan_value));
2138 check_isinfn ("fmax (-inf, NaN) = -inf", FUNC(fmax) (minus_infty, nan_value));
2139 check_isinfp ("fmax (NaN, +inf) = +inf", FUNC(fmax) (nan_value, plus_infty));
2140 check_isinfn ("fmax (NaN, -inf) = -inf", FUNC(fmax) (nan_value, minus_infty));
2141 check_isnan ("fmax (NaN, NaN) = NaN", FUNC(fmax) (nan_value, nan_value));
2145 static void
2146 fmod_test (void)
2148 MATHTYPE x;
2150 x = random_greater (0);
2151 check_ext ("fmod (+0, y) == +0 for y != 0", FUNC(fmod) (0, x), 0, x);
2153 x = random_greater (0);
2154 check_ext ("fmod (-0, y) == -0 for y != 0", FUNC(fmod) (minus_zero, x),
2155 minus_zero, x);
2157 check_isnan_exc_ext ("fmod (+inf, y) == NaN plus invalid exception",
2158 FUNC(fmod) (plus_infty, x), INVALID_EXCEPTION, x);
2159 check_isnan_exc_ext ("fmod (-inf, y) == NaN plus invalid exception",
2160 FUNC(fmod) (minus_infty, x), INVALID_EXCEPTION, x);
2161 check_isnan_exc_ext ("fmod (x, +0) == NaN plus invalid exception",
2162 FUNC(fmod) (x, 0), INVALID_EXCEPTION, x);
2163 check_isnan_exc_ext ("fmod (x, -0) == NaN plus invalid exception",
2164 FUNC(fmod) (x, minus_zero), INVALID_EXCEPTION, x);
2166 x = random_greater (0);
2167 check_ext ("fmod (x, +inf) == x for x not infinite",
2168 FUNC(fmod) (x, plus_infty), x, x);
2169 x = random_greater (0);
2170 check_ext ("fmod (x, -inf) == x for x not infinite",
2171 FUNC(fmod) (x, minus_infty), x, x);
2173 check_eps ("fmod (6.5, 2.3) == 1.9", FUNC(fmod) (6.5, 2.3), 1.9,
2174 CHOOSE(5e-16, 1e-15, 2e-7));
2175 check_eps ("fmod (-6.5, 2.3) == -1.9", FUNC(fmod) (-6.5, 2.3), -1.9,
2176 CHOOSE(5e-16, 1e-15, 2e-7));
2177 check_eps ("fmod (6.5, -2.3) == 1.9", FUNC(fmod) (6.5, -2.3), 1.9,
2178 CHOOSE(5e-16, 1e-15, 2e-7));
2179 check_eps ("fmod (-6.5, -2.3) == -1.9", FUNC(fmod) (-6.5, -2.3), -1.9,
2180 CHOOSE(5e-16, 1e-15, 2e-7));
2186 static void
2187 nextafter_test (void)
2189 MATHTYPE x;
2191 check ("nextafter (+0, +0) = +0", FUNC(nextafter) (0, 0), 0);
2192 check ("nextafter (-0, +0) = +0", FUNC(nextafter) (minus_zero, 0), 0);
2193 check ("nextafter (+0, -0) = -0", FUNC(nextafter) (0, minus_zero),
2194 minus_zero);
2195 check ("nextafter (-0, -0) = -0", FUNC(nextafter) (minus_zero, minus_zero),
2196 minus_zero);
2198 check ("nextafter (9, 9) = 9", FUNC(nextafter) (9, 9), 9);
2199 check ("nextafter (-9, -9) = -9", FUNC(nextafter) (-9, -9), -9);
2200 check_isinfp ("nextafter (+inf, +inf) = +inf",
2201 FUNC(nextafter) (plus_infty, plus_infty));
2202 check_isinfn ("nextafter (-inf, -inf) = -inf",
2203 FUNC(nextafter) (minus_infty, minus_infty));
2205 x = rand () * 1.1;
2206 check_isnan ("nextafter (NaN, x) = NaN", FUNC(nextafter) (nan_value, x));
2207 check_isnan ("nextafter (x, NaN) = NaN", FUNC(nextafter) (x, nan_value));
2208 check_isnan ("nextafter (NaN, NaN) = NaN", FUNC(nextafter) (nan_value,
2209 nan_value));
2211 /* XXX We need the hexadecimal FP number representation here for further
2212 tests. */
2216 static void
2217 copysign_test (void)
2219 check ("copysign (0, 4) = 0", FUNC(copysign) (0, 4), 0);
2220 check ("copysign (0, -4) = -0", FUNC(copysign) (0, -4), minus_zero);
2221 check ("copysign (-0, 4) = 0", FUNC(copysign) (minus_zero, 4), 0);
2222 check ("copysign (-0, -4) = -0", FUNC(copysign) (minus_zero, -4),
2223 minus_zero);
2225 check_isinfp ("copysign (+inf, 0) = +inf", FUNC(copysign) (plus_infty, 0));
2226 check_isinfn ("copysign (+inf, -0) = -inf", FUNC(copysign) (plus_infty,
2227 minus_zero));
2228 check_isinfp ("copysign (-inf, 0) = +inf", FUNC(copysign) (minus_infty, 0));
2229 check_isinfn ("copysign (-inf, -0) = -inf", FUNC(copysign) (minus_infty,
2230 minus_zero));
2232 check ("copysign (0, +inf) = 0", FUNC(copysign) (0, plus_infty), 0);
2233 check ("copysign (0, -inf) = -0", FUNC(copysign) (0, minus_zero),
2234 minus_zero);
2235 check ("copysign (-0, +inf) = 0", FUNC(copysign) (minus_zero, plus_infty),
2237 check ("copysign (-0, -inf) = -0", FUNC(copysign) (minus_zero, minus_zero),
2238 minus_zero);
2240 /* XXX More correctly we would have to check the sign of the NaN. */
2241 check_isnan ("copysign (+NaN, 0) = +NaN", FUNC(copysign) (nan_value, 0));
2242 check_isnan ("copysign (+NaN, -0) = -NaN", FUNC(copysign) (nan_value,
2243 minus_zero));
2244 check_isnan ("copysign (-NaN, 0) = +NaN", FUNC(copysign) (-nan_value, 0));
2245 check_isnan ("copysign (-NaN, -0) = -NaN", FUNC(copysign) (-nan_value,
2246 minus_zero));
2250 static void
2251 trunc_test (void)
2253 check ("trunc(0) = 0", FUNC(trunc) (0), 0);
2254 check ("trunc(-0) = -0", FUNC(trunc) (minus_zero), minus_zero);
2255 check ("trunc(0.625) = 0", FUNC(trunc) (0.625), 0);
2256 check ("trunc(-0.625) = -0", FUNC(trunc) (-0.625), minus_zero);
2257 check ("trunc(1) = 1", FUNC(trunc) (1), 1);
2258 check ("trunc(-1) = -1", FUNC(trunc) (-1), -1);
2259 check ("trunc(1.625) = 1", FUNC(trunc) (1.625), 1);
2260 check ("trunc(-1.625) = -1", FUNC(trunc) (-1.625), -1);
2262 check ("trunc(1048580.625) = 1048580", FUNC(trunc) (1048580.625L),
2263 1048580L);
2264 check ("trunc(-1048580.625) = -1048580", FUNC(trunc) (-1048580.625L),
2265 -1048580L);
2267 check ("trunc(8388610.125) = 8388610", FUNC(trunc) (8388610.125L),
2268 8388610.0L);
2269 check ("trunc(-8388610.125) = -8388610", FUNC(trunc) (-8388610.125L),
2270 -8388610.0L);
2272 check ("trunc(4294967296.625) = 4294967296", FUNC(trunc) (4294967296.625L),
2273 4294967296.0L);
2274 check ("trunc(-4294967296.625) = -4294967296",
2275 FUNC(trunc) (-4294967296.625L), -4294967296.0L);
2277 check_isinfp ("trunc(+inf) = +inf", FUNC(trunc) (plus_infty));
2278 check_isinfn ("trunc(-inf) = -inf", FUNC(trunc) (minus_infty));
2279 check_isnan ("trunc(NaN) = NaN", FUNC(trunc) (nan_value));
2283 static void
2284 sqrt_test (void)
2286 MATHTYPE x;
2289 /* XXX Tests fuer negative x are missing */
2290 check ("sqrt (0) == 0", FUNC(sqrt) (0), 0);
2291 check_isnan ("sqrt (NaN) == NaN", FUNC(sqrt) (nan_value));
2292 check_isinfp ("sqrt (+inf) == +inf", FUNC(sqrt) (plus_infty));
2294 check ("sqrt (-0) == -0", FUNC(sqrt) (0), 0);
2296 x = random_less (0.0);
2297 check_isnan_exc_ext ("sqrt (x) == NaN plus invalid exception for x < 0",
2298 FUNC(sqrt) (x), INVALID_EXCEPTION, x);
2300 x = random_value (0, 10000);
2301 check_ext ("sqrt (x*x) == x", FUNC(sqrt) (x*x), x, x);
2302 check ("sqrt (4) == 2", FUNC(sqrt) (4), 2);
2303 check ("sqrt (0.25) == 0.5", FUNC(sqrt) (0.25), 0.5);
2307 static void
2308 remainder_test (void)
2310 MATHTYPE result;
2312 result = FUNC(remainder) (1, 0);
2313 check_isnan_exc ("remainder(1, +0) == NaN plus invalid exception",
2314 result, INVALID_EXCEPTION);
2316 result = FUNC(remainder) (1, minus_zero);
2317 check_isnan_exc ("remainder(1, -0) == NaN plus invalid exception",
2318 result, INVALID_EXCEPTION);
2320 result = FUNC(remainder) (plus_infty, 1);
2321 check_isnan_exc ("remainder(+inf, 1) == NaN plus invalid exception",
2322 result, INVALID_EXCEPTION);
2324 result = FUNC(remainder) (minus_infty, 1);
2325 check_isnan_exc ("remainder(-inf, 1) == NaN plus invalid exception",
2326 result, INVALID_EXCEPTION);
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) (1.625, -1.0);
2335 check ("remainder(1.625, -1.0) == -0.375", result, -0.375);
2337 result = FUNC(remainder) (-1.625, -1.0);
2338 check ("remainder(-1.625, -1.0) == 0.375", result, 0.375);
2340 result = FUNC(remainder) (5.0, 2.0);
2341 check ("remainder(5.0, 2.0) == 1.0", result, 1.0);
2343 result = FUNC(remainder) (3.0, 2.0);
2344 check ("remainder(3.0, 2.0) == -1.0", result, -1.0);
2348 static void
2349 remquo_test (void)
2351 int quo;
2352 MATHTYPE result;
2354 result = FUNC(remquo) (1, 0, &quo);
2355 check_isnan_exc ("remquo(1, +0, &x) == NaN plus invalid exception",
2356 result, INVALID_EXCEPTION);
2358 result = FUNC(remquo) (1, minus_zero, &quo);
2359 check_isnan_exc ("remquo(1, -0, &x) == NaN plus invalid exception",
2360 result, INVALID_EXCEPTION);
2362 result = FUNC(remquo) (plus_infty, 1, &quo);
2363 check_isnan_exc ("remquo(+inf, 1, &x) == NaN plus invalid exception",
2364 result, INVALID_EXCEPTION);
2366 result = FUNC(remquo) (minus_infty, 1, &quo);
2367 check_isnan_exc ("remquo(-inf, 1, &x) == NaN plus invalid exception",
2368 result, INVALID_EXCEPTION);
2370 result = FUNC(remquo) (1.625, 1.0, &quo);
2371 check ("remquo(1.625, 1.0, &x) == -0.375", result, -0.375);
2372 check_long ("remquo(1.625, 1.0, &x) puts 2 in x", quo, 2);
2374 result = FUNC(remquo) (-1.625, 1.0, &quo);
2375 check ("remquo(-1.625, 1.0, &x) == 0.375", result, 0.375);
2376 check_long ("remquo(-1.625, 1.0, &x) puts -2 in x", quo, -2);
2378 result = FUNC(remquo) (1.625, -1.0, &quo);
2379 check ("remquo(1.625, -1.0, &x) == -0.375", result, -0.375);
2380 check_long ("remquo(1.625, -1.0, &x) puts -2 in x", quo, -2);
2382 result = FUNC(remquo) (-1.625, -1.0, &quo);
2383 check ("remquo(-1.625, -1.0, &x) == 0.375", result, 0.375);
2384 check_long ("remquo(-1.625, -1.0, &x) puts 2 in x", quo, 2);
2386 result = FUNC(remquo) (5.0, 2.0, &quo);
2387 check ("remquo(5.0, 2.0, &x) == 1.0", result, 1.0);
2388 check_long ("remquo (5.0, 2.0, &x) puts 2 in x", quo, 2);
2390 result = FUNC(remquo) (3.0, 2.0, &quo);
2391 check ("remquo(3.0, 2.0, &x) == -1.0", result, -1.0);
2392 check_long ("remquo (3.0, 2.0, &x) puts 2 in x", quo, 2);
2396 static void
2397 cexp_test (void)
2399 __complex__ MATHTYPE result;
2401 result = FUNC(cexp) (BUILD_COMPLEX (plus_zero, plus_zero));
2402 check ("real(cexp(0 + 0i)) = 1", __real__ result, 1);
2403 check ("imag(cexp(0 + 0i)) = 0", __imag__ result, 0);
2404 result = FUNC(cexp) (BUILD_COMPLEX (minus_zero, plus_zero));
2405 check ("real(cexp(-0 + 0i)) = 1", __real__ result, 1);
2406 check ("imag(cexp(-0 + 0i)) = 0", __imag__ result, 0);
2407 result = FUNC(cexp) (BUILD_COMPLEX (plus_zero, minus_zero));
2408 check ("real(cexp(0 - 0i)) = 1", __real__ result, 1);
2409 check ("imag(cexp(0 - 0i)) = -0", __imag__ result, minus_zero);
2410 result = FUNC(cexp) (BUILD_COMPLEX (minus_zero, minus_zero));
2411 check ("real(cexp(-0 - 0i)) = 1", __real__ result, 1);
2412 check ("imag(cexp(-0 - 0i)) = -0", __imag__ result, minus_zero);
2414 result = FUNC(cexp) (BUILD_COMPLEX (plus_infty, plus_zero));
2415 check_isinfp ("real(cexp(+inf + 0i)) = +inf", __real__ result);
2416 check ("imag(cexp(+inf + 0i)) = 0", __imag__ result, 0);
2417 result = FUNC(cexp) (BUILD_COMPLEX (plus_infty, minus_zero));
2418 check_isinfp ("real(cexp(+inf - 0i)) = +inf", __real__ result);
2419 check ("imag(cexp(+inf - 0i)) = -0", __imag__ result, minus_zero);
2421 result = FUNC(cexp) (BUILD_COMPLEX (minus_infty, plus_zero));
2422 check ("real(cexp(-inf + 0i)) = 0", __real__ result, 0);
2423 check ("imag(cexp(-inf + 0i)) = 0", __imag__ result, 0);
2424 result = FUNC(cexp) (BUILD_COMPLEX (minus_infty, minus_zero));
2425 check ("real(cexp(-inf - 0i)) = 0", __real__ result, 0);
2426 check ("imag(cexp(-inf - 0i)) = -0", __imag__ result, minus_zero);
2429 result = FUNC(cexp) (BUILD_COMPLEX (0.0, plus_infty));
2430 check_isnan_exc ("real(cexp(0 + i inf)) = NaN plus invalid exception",
2431 __real__ result, INVALID_EXCEPTION);
2432 check_isnan ("imag(cexp(0 + i inf)) = NaN plus invalid exception",
2433 __imag__ result);
2435 #if defined __GNUC__ && __GNUC__ <= 2 && __GNUC_MINOR <= 7
2436 if (verbose)
2437 printf ("The following test for cexp might fail due to a gcc compiler error!\n");
2438 #endif
2440 result = FUNC(cexp) (BUILD_COMPLEX (minus_zero, plus_infty));
2441 check_isnan_exc ("real(cexp(-0 + i inf)) = NaN plus invalid exception",
2442 __real__ result, INVALID_EXCEPTION);
2443 check_isnan ("imag(cexp(-0 + i inf)) = NaN plus invalid exception",
2444 __imag__ result);
2445 result = FUNC(cexp) (BUILD_COMPLEX (0.0, minus_infty));
2446 check_isnan_exc ("real(cexp(0 - i inf)) = NaN plus invalid exception",
2447 __real__ result, INVALID_EXCEPTION);
2448 check_isnan ("imag(cexp(0 - i inf)) = NaN plus invalid exception",
2449 __imag__ result);
2450 result = FUNC(cexp) (BUILD_COMPLEX (minus_zero, minus_infty));
2451 check_isnan_exc ("real(cexp(-0 - i inf)) = NaN plus invalid exception",
2452 __real__ result, INVALID_EXCEPTION);
2453 check_isnan ("imag(cexp(-0 - i inf)) = NaN plus invalid exception",
2454 __imag__ result);
2456 result = FUNC(cexp) (BUILD_COMPLEX (100.0, plus_infty));
2457 check_isnan_exc ("real(cexp(100.0 + i inf)) = NaN plus invalid exception",
2458 __real__ result, INVALID_EXCEPTION);
2459 check_isnan ("imag(cexp(100.0 + i inf)) = NaN plus invalid exception",
2460 __imag__ result);
2461 result = FUNC(cexp) (BUILD_COMPLEX (-100.0, plus_infty));
2462 check_isnan_exc ("real(cexp(-100.0 + i inf)) = NaN plus invalid exception",
2463 __real__ result, INVALID_EXCEPTION);
2464 check_isnan ("imag(cexp(-100.0 + i inf)) = NaN plus invalid exception",
2465 __imag__ result);
2466 result = FUNC(cexp) (BUILD_COMPLEX (100.0, minus_infty));
2467 check_isnan_exc ("real(cexp(100.0 - i inf)) = NaN plus invalid exception",
2468 __real__ result, INVALID_EXCEPTION);
2469 check_isnan ("imag(cexp(100.0 - i inf)) = NaN plus invalid exception",
2470 __imag__ result);
2471 result = FUNC(cexp) (BUILD_COMPLEX (-100.0, minus_infty));
2472 check_isnan_exc ("real(cexp(-100.0 - i inf)) = NaN plus invalid exception",
2473 __real__ result, INVALID_EXCEPTION);
2474 check_isnan ("imag(cexp(-100.0 - i inf)) = NaN", __imag__ result);
2476 result = FUNC(cexp) (BUILD_COMPLEX (minus_infty, 2.0));
2477 check ("real(cexp(-inf + 2.0i)) = -0", __real__ result, minus_zero);
2478 check ("imag(cexp(-inf + 2.0i)) = 0", __imag__ result, 0);
2479 result = FUNC(cexp) (BUILD_COMPLEX (minus_infty, 4.0));
2480 check ("real(cexp(-inf + 4.0i)) = -0", __real__ result, minus_zero);
2481 check ("imag(cexp(-inf + 4.0i)) = -0", __imag__ result, minus_zero);
2483 result = FUNC(cexp) (BUILD_COMPLEX (plus_infty, 2.0));
2484 check_isinfn ("real(cexp(+inf + 2.0i)) = -inf", __real__ result);
2485 check_isinfp ("imag(cexp(+inf + 2.0i)) = +inf", __imag__ result);
2486 result = FUNC(cexp) (BUILD_COMPLEX (plus_infty, 4.0));
2487 check_isinfn ("real(cexp(+inf + 4.0i)) = -inf", __real__ result);
2488 check_isinfn ("imag(cexp(+inf + 4.0i)) = -inf", __imag__ result);
2490 result = FUNC(cexp) (BUILD_COMPLEX (plus_infty, plus_infty));
2491 check_isinfp_exc ("real(cexp(+inf + i inf)) = +inf plus invalid exception",
2492 __real__ result, INVALID_EXCEPTION);
2493 check_isnan ("imag(cexp(+inf + i inf)) = NaN plus invalid exception",
2494 __imag__ result);
2495 result = FUNC(cexp) (BUILD_COMPLEX (plus_infty, minus_infty));
2496 check_isinfp_exc ("real(cexp(+inf - i inf)) = +inf plus invalid exception",
2497 __real__ result, INVALID_EXCEPTION);
2498 check_isnan ("imag(cexp(+inf - i inf)) = NaN plus invalid exception",
2499 __imag__ result);
2501 result = FUNC(cexp) (BUILD_COMPLEX (minus_infty, plus_infty));
2502 check ("real(cexp(-inf + i inf)) = 0", __real__ result, 0);
2503 check ("imag(cexp(-inf + i inf)) = 0", __imag__ result, 0);
2504 result = FUNC(cexp) (BUILD_COMPLEX (minus_infty, minus_infty));
2505 check ("real(cexp(-inf - i inf)) = 0", __real__ result, 0);
2506 check ("imag(cexp(-inf - i inf)) = -0", __imag__ result, minus_zero);
2508 result = FUNC(cexp) (BUILD_COMPLEX (minus_infty, nan_value));
2509 check ("real(cexp(-inf + i NaN)) = 0", __real__ result, 0);
2510 check ("imag(cexp(-inf + i NaN)) = 0", fabs (__imag__ result), 0);
2512 result = FUNC(cexp) (BUILD_COMPLEX (plus_infty, nan_value));
2513 check_isinfp ("real(cexp(+inf + i NaN)) = +inf", __real__ result);
2514 check_isnan ("imag(cexp(+inf + i NaN)) = NaN", __imag__ result);
2516 result = FUNC(cexp) (BUILD_COMPLEX (nan_value, 0.0));
2517 check_isnan_maybe_exc ("real(cexp(NaN + i0)) = NaN plus maybe invalid exception",
2518 __real__ result, INVALID_EXCEPTION);
2519 check_isnan ("imag(cexp(NaN + i0)) = NaN plus maybe invalid exception",
2520 __imag__ result);
2521 result = FUNC(cexp) (BUILD_COMPLEX (nan_value, 1.0));
2522 check_isnan_maybe_exc ("real(cexp(NaN + 1i)) = NaN plus maybe invalid exception",
2523 __real__ result, INVALID_EXCEPTION);
2524 check_isnan ("imag(cexp(NaN + 1i)) = NaN plus maybe invalid exception",
2525 __imag__ result);
2526 result = FUNC(cexp) (BUILD_COMPLEX (nan_value, plus_infty));
2527 check_isnan_maybe_exc ("real(cexp(NaN + i inf)) = NaN plus maybe invalid exception",
2528 __real__ result, INVALID_EXCEPTION);
2529 check_isnan ("imag(cexp(NaN + i inf)) = NaN plus maybe invalid exception",
2530 __imag__ result);
2532 result = FUNC(cexp) (BUILD_COMPLEX (0, nan_value));
2533 check_isnan_maybe_exc ("real(cexp(0 + i NaN)) = NaN plus maybe invalid exception",
2534 __real__ result, INVALID_EXCEPTION);
2535 check_isnan ("imag(cexp(0 + i NaN)) = NaN plus maybe invalid exception",
2536 __imag__ result);
2537 result = FUNC(cexp) (BUILD_COMPLEX (1, nan_value));
2538 check_isnan_maybe_exc ("real(cexp(1 + i NaN)) = NaN plus maybe invalid exception",
2539 __real__ result, INVALID_EXCEPTION);
2540 check_isnan ("imag(cexp(1 + i NaN)) = NaN plus maybe invalid exception",
2541 __imag__ result);
2543 result = FUNC(cexp) (BUILD_COMPLEX (nan_value, nan_value));
2544 check_isnan ("real(cexp(NaN + i NaN)) = NaN", __real__ result);
2545 check_isnan ("imag(cexp(NaN + i NaN)) = NaN", __imag__ result);
2549 static void
2550 csin_test (void)
2552 __complex__ MATHTYPE result;
2554 result = FUNC(csin) (BUILD_COMPLEX (0.0, 0.0));
2555 check ("real(csin(0 + 0i)) = 0", __real__ result, 0);
2556 check ("imag(csin(0 + 0i)) = 0", __imag__ result, 0);
2557 result = FUNC(csin) (BUILD_COMPLEX (minus_zero, 0.0));
2558 check ("real(csin(-0 + 0i)) = -0", __real__ result, minus_zero);
2559 check ("imag(csin(-0 + 0i)) = 0", __imag__ result, 0);
2560 result = FUNC(csin) (BUILD_COMPLEX (0.0, minus_zero));
2561 check ("real(csin(0 - 0i)) = 0", __real__ result, 0);
2562 check ("imag(csin(0 - 0i)) = -0", __imag__ result, minus_zero);
2563 result = FUNC(csin) (BUILD_COMPLEX (minus_zero, minus_zero));
2564 check ("real(csin(-0 - 0i)) = -0", __real__ result, minus_zero);
2565 check ("imag(csin(-0 - 0i)) = -0", __imag__ result, minus_zero);
2567 result = FUNC(csin) (BUILD_COMPLEX (0.0, plus_infty));
2568 check ("real(csin(0 + i Inf)) = 0", __real__ result, 0);
2569 check_isinfp ("imag(csin(0 + i Inf)) = +Inf", __imag__ result);
2570 result = FUNC(csin) (BUILD_COMPLEX (minus_zero, plus_infty));
2571 check ("real(csin(-0 + i Inf)) = -0", __real__ result, minus_zero);
2572 check_isinfp ("imag(csin(-0 + i Inf)) = +Inf", __imag__ result);
2573 result = FUNC(csin) (BUILD_COMPLEX (0.0, minus_infty));
2574 check ("real(csin(0 - i Inf)) = 0", __real__ result, 0);
2575 check_isinfn ("imag(csin(0 - i Inf)) = -Inf", __imag__ result);
2576 result = FUNC(csin) (BUILD_COMPLEX (minus_zero, minus_infty));
2577 check ("real(csin(-0 - i Inf)) = -0", __real__ result, minus_zero);
2578 check_isinfn("imag(csin(-0 - i Inf)) = -Inf", __imag__ result);
2580 result = FUNC(csin) (BUILD_COMPLEX (plus_infty, 0.0));
2581 check_isnan_exc ("real(csin(+Inf + 0i)) = NaN plus invalid exception",
2582 __real__ result, INVALID_EXCEPTION);
2583 check ("imag(csin(+Inf + 0i)) = +-0 plus invalid exception",
2584 FUNC(fabs) (__imag__ result), 0);
2585 result = FUNC(csin) (BUILD_COMPLEX (minus_infty, 0.0));
2586 check_isnan_exc ("real(csin(-Inf + 0i)) = NaN plus invalid exception",
2587 __real__ result, INVALID_EXCEPTION);
2588 check ("imag(csin(-Inf + 0i)) = +-0 plus invalid exception",
2589 FUNC(fabs) (__imag__ result), 0);
2590 result = FUNC(csin) (BUILD_COMPLEX (plus_infty, minus_zero));
2591 check_isnan_exc ("real(csin(+Inf - 0i)) = NaN plus invalid exception",
2592 __real__ result, INVALID_EXCEPTION);
2593 check ("imag(csin(+Inf - 0i)) = +-0 plus invalid exception",
2594 FUNC(fabs) (__imag__ result), 0.0);
2595 result = FUNC(csin) (BUILD_COMPLEX (minus_infty, minus_zero));
2596 check_isnan_exc ("real(csin(-Inf - 0i)) = NaN plus invalid exception",
2597 __real__ result, INVALID_EXCEPTION);
2598 check ("imag(csin(-Inf - 0i)) = +-0 plus invalid exception",
2599 FUNC(fabs) (__imag__ result), 0.0);
2601 result = FUNC(csin) (BUILD_COMPLEX (plus_infty, plus_infty));
2602 check_isnan_exc ("real(csin(+Inf + i Inf)) = NaN plus invalid exception",
2603 __real__ result, INVALID_EXCEPTION);
2604 check_isinfp ("imag(csin(+Inf + i Inf)) = +-Inf plus invalid exception",
2605 FUNC(fabs) (__imag__ result));
2606 result = FUNC(csin) (BUILD_COMPLEX (minus_infty, plus_infty));
2607 check_isnan_exc ("real(csin(-Inf + i Inf)) = NaN plus invalid exception",
2608 __real__ result, INVALID_EXCEPTION);
2609 check_isinfp ("imag(csin(-Inf + i Inf)) = +-Inf plus invalid exception",
2610 FUNC(fabs) (__imag__ result));
2611 result = FUNC(csin) (BUILD_COMPLEX (plus_infty, minus_infty));
2612 check_isnan_exc ("real(csin(Inf - i Inf)) = NaN plus invalid exception",
2613 __real__ result, INVALID_EXCEPTION);
2614 check_isinfp ("imag(csin(Inf - i Inf)) = +-Inf plus invalid exception",
2615 FUNC(fabs) (__imag__ result));
2616 result = FUNC(csin) (BUILD_COMPLEX (minus_infty, minus_infty));
2617 check_isnan_exc ("real(csin(-Inf - i Inf)) = NaN plus invalid exception",
2618 __real__ result, INVALID_EXCEPTION);
2619 check_isinfp ("imag(csin(-Inf - i Inf)) = +-Inf plus invalid exception",
2620 FUNC(fabs) (__imag__ result));
2622 result = FUNC(csin) (BUILD_COMPLEX (plus_infty, 6.75));
2623 check_isnan_exc ("real(csin(+Inf + i 6.75)) = NaN plus invalid exception",
2624 __real__ result, INVALID_EXCEPTION);
2625 check_isnan ("imag(csin(+Inf + i6.75)) = NaN plus invalid exception",
2626 __imag__ result);
2627 result = FUNC(csin) (BUILD_COMPLEX (plus_infty, -6.75));
2628 check_isnan_exc ("real(csin(+Inf - i 6.75)) = NaN plus invalid exception",
2629 __real__ result, INVALID_EXCEPTION);
2630 check_isnan ("imag(csin(+Inf - i6.75)) = NaN plus invalid exception",
2631 __imag__ result);
2632 result = FUNC(csin) (BUILD_COMPLEX (minus_infty, 6.75));
2633 check_isnan_exc ("real(csin(-Inf + i6.75)) = NaN plus invalid exception",
2634 __real__ result, INVALID_EXCEPTION);
2635 check_isnan ("imag(csin(-Inf + i6.75)) = NaN plus invalid exception",
2636 __imag__ result);
2637 result = FUNC(csin) (BUILD_COMPLEX (minus_infty, -6.75));
2638 check_isnan_exc ("real(csin(-Inf - i6.75)) = NaN plus invalid exception",
2639 __real__ result, INVALID_EXCEPTION);
2640 check_isnan ("imag(csin(-Inf - i6.75)) = NaN plus invalid exception",
2641 __imag__ result);
2643 result = FUNC(csin) (BUILD_COMPLEX (4.625, plus_infty));
2644 check_isinfn ("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_isinfn ("real(csin(4.625 - i Inf)) = -Inf", __real__ result);
2648 check_isinfp ("imag(csin(4.625 - i Inf)) = +Inf", __imag__ result);
2649 result = FUNC(csin) (BUILD_COMPLEX (-4.625, plus_infty));
2650 check_isinfp ("real(csin(-4.625 + i Inf)) = +Inf", __real__ result);
2651 check_isinfn ("imag(csin(-4.625 + i Inf)) = -Inf", __imag__ result);
2652 result = FUNC(csin) (BUILD_COMPLEX (-4.625, minus_infty));
2653 check_isinfp ("real(csin(-4.625 - i Inf)) = +Inf", __real__ result);
2654 check_isinfp ("imag(csin(-4.625 - i Inf)) = +Inf", __imag__ result);
2656 result = FUNC(csin) (BUILD_COMPLEX (nan_value, 0.0));
2657 check_isnan ("real(csin(NaN + i0)) = NaN", __real__ result);
2658 check ("imag(csin(NaN + i0)) = +-0", FUNC(fabs) (__imag__ result), 0);
2659 result = FUNC(csin) (BUILD_COMPLEX (nan_value, minus_zero));
2660 check_isnan ("real(csin(NaN - i0)) = NaN", __real__ result);
2661 check ("imag(csin(NaN - i0)) = +-0", FUNC(fabs) (__imag__ result), 0);
2663 result = FUNC(csin) (BUILD_COMPLEX (nan_value, plus_infty));
2664 check_isnan ("real(csin(NaN + i Inf)) = NaN", __real__ result);
2665 check_isinfp ("imag(csin(NaN + i Inf)) = +-Inf",
2666 FUNC(fabs) (__imag__ result));
2667 result = FUNC(csin) (BUILD_COMPLEX (nan_value, minus_infty));
2668 check_isnan ("real(csin(NaN - i Inf)) = NaN", __real__ result);
2669 check_isinfp ("real(csin(NaN - i Inf)) = +-Inf",
2670 FUNC(fabs) (__imag__ result));
2672 result = FUNC(csin) (BUILD_COMPLEX (nan_value, 9.0));
2673 check_isnan_maybe_exc ("real(csin(NaN + i9.0)) = NaN plus maybe invalid exception",
2674 __real__ result, INVALID_EXCEPTION);
2675 check_isnan ("imag(csin(NaN + i9.0)) = NaN plus maybe invalid exception",
2676 __imag__ result);
2677 result = FUNC(csin) (BUILD_COMPLEX (nan_value, -9.0));
2678 check_isnan_maybe_exc ("real(csin(NaN - i9.0)) = NaN plus maybe invalid exception",
2679 __real__ result, INVALID_EXCEPTION);
2680 check_isnan ("imag(csin(NaN - i9.0)) = NaN plus maybe invalid exception",
2681 __imag__ result);
2683 result = FUNC(csin) (BUILD_COMPLEX (0.0, nan_value));
2684 check ("real(csin(0 + i NaN))", __real__ result, 0.0);
2685 check_isnan ("imag(csin(0 + i NaN)) = NaN", __imag__ result);
2686 result = FUNC(csin) (BUILD_COMPLEX (minus_zero, nan_value));
2687 check ("real(csin(-0 + i NaN)) = -0", __real__ result, minus_zero);
2688 check_isnan ("imag(csin(-0 + NaN)) = NaN", __imag__ result);
2690 result = FUNC(csin) (BUILD_COMPLEX (10.0, nan_value));
2691 check_isnan_maybe_exc ("real(csin(10 + i NaN)) = NaN plus maybe invalid exception",
2692 __real__ result, INVALID_EXCEPTION);
2693 check_isnan ("imag(csin(10 + i NaN)) = NaN plus maybe invalid exception",
2694 __imag__ result);
2695 result = FUNC(csin) (BUILD_COMPLEX (nan_value, -10.0));
2696 check_isnan_maybe_exc ("real(csin(-10 + i NaN)) = NaN plus maybe invalid exception",
2697 __real__ result, INVALID_EXCEPTION);
2698 check_isnan ("imag(csin(-10 + i NaN)) = NaN plus maybe invalid exception",
2699 __imag__ result);
2701 result = FUNC(csin) (BUILD_COMPLEX (plus_infty, nan_value));
2702 check_isnan_maybe_exc ("real(csin(+Inf + i NaN)) = NaN plus maybe invalid exception",
2703 __real__ result, INVALID_EXCEPTION);
2704 check_isnan ("imag(csin(+Inf + i NaN)) = NaN plus maybe invalid exception",
2705 __imag__ result);
2706 result = FUNC(csin) (BUILD_COMPLEX (minus_infty, nan_value));
2707 check_isnan_maybe_exc ("real(csin(-Inf + i NaN)) = NaN plus maybe invalid exception",
2708 __real__ result, INVALID_EXCEPTION);
2709 check_isnan ("imag(csin(-Inf + i NaN)) = NaN plus maybe invalid exception",
2710 __imag__ result);
2712 result = FUNC(csin) (BUILD_COMPLEX (nan_value, nan_value));
2713 check_isnan ("real(csin(NaN + i NaN)) = NaN", __real__ result);
2714 check_isnan ("imag(csin(NaN + i NaN)) = NaN", __imag__ result);
2718 static void
2719 csinh_test (void)
2721 __complex__ MATHTYPE result;
2723 result = FUNC(csinh) (BUILD_COMPLEX (0.0, 0.0));
2724 check ("real(csinh(0 + 0i)) = 0", __real__ result, 0);
2725 check ("imag(csinh(0 + 0i)) = 0", __imag__ result, 0);
2726 result = FUNC(csinh) (BUILD_COMPLEX (minus_zero, 0.0));
2727 check ("real(csinh(-0 + 0i)) = -0", __real__ result, minus_zero);
2728 check ("imag(csinh(-0 + 0i)) = 0", __imag__ result, 0);
2729 result = FUNC(csinh) (BUILD_COMPLEX (0.0, minus_zero));
2730 check ("real(csinh(0 - 0i)) = 0", __real__ result, 0);
2731 check ("imag(csinh(0 - 0i)) = -0", __imag__ result, minus_zero);
2732 result = FUNC(csinh) (BUILD_COMPLEX (minus_zero, minus_zero));
2733 check ("real(csinh(-0 - 0i)) = -0", __real__ result, minus_zero);
2734 check ("imag(csinh(-0 - 0i)) = -0", __imag__ result, minus_zero);
2736 result = FUNC(csinh) (BUILD_COMPLEX (0.0, plus_infty));
2737 check_exc ("real(csinh(0 + i Inf)) = +-0 plus invalid exception",
2738 FUNC(fabs) (__real__ result), 0, INVALID_EXCEPTION);
2739 check_isnan ("imag(csinh(0 + i Inf)) = NaN plus invalid exception",
2740 __imag__ result);
2741 result = FUNC(csinh) (BUILD_COMPLEX (minus_zero, plus_infty));
2742 check_exc ("real(csinh(-0 + i Inf)) = +-0 plus invalid exception",
2743 FUNC(fabs) (__real__ result), 0, INVALID_EXCEPTION);
2744 check_isnan ("imag(csinh(-0 + i Inf)) = NaN plus invalid exception",
2745 __imag__ result);
2746 result = FUNC(csinh) (BUILD_COMPLEX (0.0, minus_infty));
2747 check_exc ("real(csinh(0 - i Inf)) = +-0 plus invalid exception",
2748 FUNC(fabs) (__real__ result), 0, INVALID_EXCEPTION);
2749 check_isnan ("imag(csinh(0 - i Inf)) = NaN plus invalid exception",
2750 __imag__ result);
2751 result = FUNC(csinh) (BUILD_COMPLEX (minus_zero, minus_infty));
2752 check_exc ("real(csinh(-0 - i Inf)) = +-0 plus invalid exception",
2753 FUNC(fabs) (__real__ result), 0, INVALID_EXCEPTION);
2754 check_isnan ("imag(csinh(-0 - i Inf)) = NaN plus invalid exception",
2755 __imag__ result);
2757 result = FUNC(csinh) (BUILD_COMPLEX (plus_infty, 0.0));
2758 check_isinfp ("real(csinh(+Inf + 0i)) = +Inf", __real__ result);
2759 check ("imag(csinh(+Inf + 0i)) = 0", __imag__ result, 0);
2760 result = FUNC(csinh) (BUILD_COMPLEX (minus_infty, 0.0));
2761 check_isinfn ("real(csinh(-Inf + 0i)) = -Inf", __real__ result);
2762 check ("imag(csinh(-Inf + 0i)) = 0", __imag__ result, 0);
2763 result = FUNC(csinh) (BUILD_COMPLEX (plus_infty, minus_zero));
2764 check_isinfp ("real(csinh(+Inf - 0i)) = +Inf", __real__ result);
2765 check ("imag(csinh(+Inf - 0i)) = -0", __imag__ result, minus_zero);
2766 result = FUNC(csinh) (BUILD_COMPLEX (minus_infty, minus_zero));
2767 check_isinfn ("real(csinh(-Inf - 0i)) = -Inf", __real__ result);
2768 check ("imag(csinh(-Inf - 0i)) = -0", __imag__ result, minus_zero);
2770 result = FUNC(csinh) (BUILD_COMPLEX (plus_infty, plus_infty));
2771 check_isinfp_exc ("real(csinh(+Inf + i Inf)) = +-Inf plus invalid exception",
2772 FUNC(fabs) (__real__ result), INVALID_EXCEPTION);
2773 check_isnan ("imag(csinh(+Inf + i Inf)) = NaN plus invalid exception",
2774 __imag__ result);
2775 result = FUNC(csinh) (BUILD_COMPLEX (minus_infty, plus_infty));
2776 check_isinfp_exc ("real(csinh(-Inf + i Inf)) = +-Inf plus invalid exception",
2777 FUNC(fabs) (__real__ result), INVALID_EXCEPTION);
2778 check_isnan ("imag(csinh(-Inf + i Inf)) = NaN plus invalid exception",
2779 __imag__ result);
2780 result = FUNC(csinh) (BUILD_COMPLEX (plus_infty, minus_infty));
2781 check_isinfp_exc ("real(csinh(Inf - i Inf)) = +-Inf plus invalid exception",
2782 FUNC(fabs) (__real__ result), INVALID_EXCEPTION);
2783 check_isnan ("imag(csinh(Inf - i Inf)) = NaN plus invalid exception",
2784 __imag__ result);
2785 result = FUNC(csinh) (BUILD_COMPLEX (minus_infty, minus_infty));
2786 check_isinfp_exc ("real(csinh(-Inf - i Inf)) = +-Inf plus invalid exception",
2787 FUNC(fabs) (__real__ result), INVALID_EXCEPTION);
2788 check_isnan ("imag(csinh(-Inf - i Inf)) = NaN plus invalid exception",
2789 __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_isinfn ("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_isinfn ("imag(csinh(-Inf + i4.625)) = -Inf", __imag__ result);
2797 result = FUNC(csinh) (BUILD_COMPLEX (plus_infty, -4.625));
2798 check_isinfn ("real(csinh(+Inf - i4.625)) = -Inf", __real__ result);
2799 check_isinfp ("imag(csinh(+Inf - i4.625)) = +Inf", __imag__ result);
2800 result = FUNC(csinh) (BUILD_COMPLEX (minus_infty, -4.625));
2801 check_isinfp ("real(csinh(-Inf - i4.625)) = +Inf", __real__ result);
2802 check_isinfp ("imag(csinh(-Inf - i4.625)) = +Inf", __imag__ result);
2804 result = FUNC(csinh) (BUILD_COMPLEX (6.75, plus_infty));
2805 check_isnan_exc ("real(csinh(6.75 + i Inf)) = NaN plus invalid exception",
2806 __real__ result, INVALID_EXCEPTION);
2807 check_isnan ("imag(csinh(6.75 + i Inf)) = NaN plus invalid exception",
2808 __imag__ result);
2809 result = FUNC(csinh) (BUILD_COMPLEX (-6.75, plus_infty));
2810 check_isnan_exc ("real(csinh(-6.75 + i Inf)) = NaN plus invalid exception",
2811 __real__ result, INVALID_EXCEPTION);
2812 check_isnan ("imag(csinh(-6.75 + i Inf)) = NaN plus invalid exception",
2813 __imag__ result);
2814 result = FUNC(csinh) (BUILD_COMPLEX (6.75, minus_infty));
2815 check_isnan_exc ("real(csinh(6.75 - i Inf)) = NaN plus invalid exception",
2816 __real__ result, INVALID_EXCEPTION);
2817 check_isnan ("imag(csinh(6.75 - i Inf)) = NaN plus invalid exception",
2818 __imag__ result);
2819 result = FUNC(csinh) (BUILD_COMPLEX (-6.75, minus_infty));
2820 check_isnan_exc ("real(csinh(-6.75 - i Inf)) = NaN plus invalid exception",
2821 __real__ result, INVALID_EXCEPTION);
2822 check_isnan ("imag(csinh(-6.75 - i Inf)) = NaN plus invalid exception",
2823 __imag__ result);
2825 result = FUNC(csinh) (BUILD_COMPLEX (0.0, nan_value));
2826 check ("real(csinh(0 + i NaN)) = +-0", FUNC(fabs) (__real__ result), 0);
2827 check_isnan ("imag(csinh(0 + i NaN)) = NaN", __imag__ result);
2828 result = FUNC(csinh) (BUILD_COMPLEX (minus_zero, nan_value));
2829 check ("real(csinh(-0 + i NaN)) = +-0", FUNC(fabs) (__real__ result), 0);
2830 check_isnan ("imag(csinh(-0 + i NaN)) = NaN", __imag__ result);
2832 result = FUNC(csinh) (BUILD_COMPLEX (plus_infty, nan_value));
2833 check_isinfp ("real(csinh(+Inf + i NaN)) = +-Inf",
2834 FUNC(fabs) (__real__ result));
2835 check_isnan ("imag(csinh(+Inf + i NaN)) = NaN", __imag__ result);
2836 result = FUNC(csinh) (BUILD_COMPLEX (minus_infty, nan_value));
2837 check_isinfp ("real(csinh(-Inf + i NaN)) = +-Inf",
2838 FUNC(fabs) (__real__ result));
2839 check_isnan ("imag(csinh(-Inf + i NaN)) = NaN", __imag__ result);
2841 result = FUNC(csinh) (BUILD_COMPLEX (9.0, nan_value));
2842 check_isnan_maybe_exc ("real(csinh(9.0 + i NaN)) = NaN plus maybe invalid exception",
2843 __real__ result, INVALID_EXCEPTION);
2844 check_isnan ("imag(csinh(9.0 + i NaN)) = NaN plus maybe invalid exception",
2845 __imag__ result);
2846 result = FUNC(csinh) (BUILD_COMPLEX (-9.0, nan_value));
2847 check_isnan_maybe_exc ("real(csinh(-9.0 + i NaN)) = NaN plus maybe invalid exception",
2848 __real__ result, INVALID_EXCEPTION);
2849 check_isnan ("imag(csinh(-9.0 + i NaN)) = NaN plus maybe invalid exception",
2850 __imag__ result);
2852 result = FUNC(csinh) (BUILD_COMPLEX (nan_value, 0.0));
2853 check_isnan ("real(csinh(NaN + i0)) = NaN", __real__ result);
2854 check ("imag(csinh(NaN + i0)) = 0", __imag__ result, 0.0);
2855 result = FUNC(csinh) (BUILD_COMPLEX (nan_value, minus_zero));
2856 check_isnan ("real(csinh(NaN - i0)) = NaN", __real__ result);
2857 check ("imag(csinh(NaN - i0)) = -0", __imag__ result, minus_zero);
2859 result = FUNC(csinh) (BUILD_COMPLEX (nan_value, 10.0));
2860 check_isnan_maybe_exc ("real(csinh(NaN + i10)) = NaN plus maybe invalid exception",
2861 __real__ result, INVALID_EXCEPTION);
2862 check_isnan ("imag(csinh(NaN + i10)) = NaN plus maybe invalid exception",
2863 __imag__ result);
2864 result = FUNC(csinh) (BUILD_COMPLEX (nan_value, -10.0));
2865 check_isnan_maybe_exc ("real(csinh(NaN - i10)) = NaN plus maybe invalid exception",
2866 __real__ result, INVALID_EXCEPTION);
2867 check_isnan ("imag(csinh(NaN - i10)) = NaN plus maybe invalid exception",
2868 __imag__ result);
2870 result = FUNC(csinh) (BUILD_COMPLEX (nan_value, plus_infty));
2871 check_isnan_maybe_exc ("real(csinh(NaN + i Inf)) = NaN plus maybe invalid exception",
2872 __real__ result, INVALID_EXCEPTION);
2873 check_isnan ("imag(csinh(NaN + i Inf)) = NaN plus maybe invalid exception",
2874 __imag__ result);
2875 result = FUNC(csinh) (BUILD_COMPLEX (nan_value, minus_infty));
2876 check_isnan_maybe_exc ("real(csinh(NaN - i Inf)) = NaN plus maybe invalid exception",
2877 __real__ result, INVALID_EXCEPTION);
2878 check_isnan ("imag(csinh(NaN - i Inf)) = NaN plus maybe invalid exception",
2879 __imag__ result);
2881 result = FUNC(csinh) (BUILD_COMPLEX (nan_value, nan_value));
2882 check_isnan ("real(csinh(NaN + i NaN)) = NaN", __real__ result);
2883 check_isnan ("imag(csinh(NaN + i NaN)) = NaN", __imag__ result);
2887 static void
2888 ccos_test (void)
2890 __complex__ MATHTYPE result;
2892 result = FUNC(ccos) (BUILD_COMPLEX (0.0, 0.0));
2893 check ("real(ccos(0 + 0i)) = 1.0", __real__ result, 1.0);
2894 check ("imag(ccos(0 + 0i)) = -0", __imag__ result, minus_zero);
2895 result = FUNC(ccos) (BUILD_COMPLEX (minus_zero, 0.0));
2896 check ("real(ccos(-0 + 0i)) = 1.0", __real__ result, 1.0);
2897 check ("imag(ccos(-0 + 0i)) = 0", __imag__ result, 0.0);
2898 result = FUNC(ccos) (BUILD_COMPLEX (0.0, minus_zero));
2899 check ("real(ccos(0 - 0i)) = 1.0", __real__ result, 1.0);
2900 check ("imag(ccos(0 - 0i)) = 0", __imag__ result, 0.0);
2901 result = FUNC(ccos) (BUILD_COMPLEX (minus_zero, minus_zero));
2902 check ("real(ccos(-0 - 0i)) = 1.0", __real__ result, 1.0);
2903 check ("imag(ccos(-0 - 0i)) = -0", __imag__ result, minus_zero);
2905 result = FUNC(ccos) (BUILD_COMPLEX (plus_infty, 0.0));
2906 check_isnan_exc ("real(ccos(+Inf + i0)) = NaN plus invalid exception",
2907 __real__ result, INVALID_EXCEPTION);
2908 check ("imag(ccos(Inf + i0)) = +-0 plus invalid exception",
2909 FUNC(fabs) (__imag__ result), 0);
2910 result = FUNC(ccos) (BUILD_COMPLEX (plus_infty, minus_zero));
2911 check_isnan_exc ("real(ccos(Inf - i0)) = NaN plus invalid exception",
2912 __real__ result, INVALID_EXCEPTION);
2913 check ("imag(ccos(Inf - i0)) = +-0 plus invalid exception",
2914 FUNC(fabs) (__imag__ result), 0);
2915 result = FUNC(ccos) (BUILD_COMPLEX (minus_infty, 0.0));
2916 check_isnan_exc ("real(ccos(-Inf + i0)) = NaN plus invalid exception",
2917 __real__ result, INVALID_EXCEPTION);
2918 check ("imag(ccos(-Inf + i0)) = +-0 plus invalid exception",
2919 FUNC(fabs) (__imag__ result), 0);
2920 result = FUNC(ccos) (BUILD_COMPLEX (minus_infty, minus_zero));
2921 check_isnan_exc ("real(ccos(-Inf - i0)) = NaN plus invalid exception",
2922 __real__ result, INVALID_EXCEPTION);
2923 check ("imag(ccos(-Inf - i0)) = +-0 plus invalid exception",
2924 FUNC(fabs) (__imag__ result), 0);
2926 result = FUNC(ccos) (BUILD_COMPLEX (0.0, plus_infty));
2927 check_isinfp ("real(ccos(0 + i Inf)) = +Inf", __real__ result);
2928 check ("imag(ccos(0 + i Inf)) = -0", __imag__ result, minus_zero);
2929 result = FUNC(ccos) (BUILD_COMPLEX (0.0, minus_infty));
2930 check_isinfp ("real(ccos(0 - i Inf)) = +Inf", __real__ result);
2931 check ("imag(ccos(0 - i Inf)) = 0", __imag__ result, 0);
2932 result = FUNC(ccos) (BUILD_COMPLEX (minus_zero, plus_infty));
2933 check_isinfp ("real(ccos(-0 + i Inf)) = +Inf", __real__ result);
2934 check ("imag(ccos(-0 + i Inf)) = 0", __imag__ result, 0.0);
2935 result = FUNC(ccos) (BUILD_COMPLEX (minus_zero, minus_infty));
2936 check_isinfp ("real(ccos(-0 - i Inf)) = +Inf", __real__ result);
2937 check ("imag(ccos(-0 - i Inf)) = -0", __imag__ result, minus_zero);
2939 result = FUNC(ccos) (BUILD_COMPLEX (plus_infty, plus_infty));
2940 check_isinfp_exc ("real(ccos(+Inf + i Inf)) = +Inf plus invalid exception",
2941 __real__ result, INVALID_EXCEPTION);
2942 check_isnan ("imag(ccos(+Inf + i Inf)) = NaN plus invalid exception",
2943 __imag__ result);
2944 result = FUNC(ccos) (BUILD_COMPLEX (minus_infty, plus_infty));
2945 check_isinfp_exc ("real(ccos(-Inf + i Inf)) = +Inf plus invalid exception",
2946 __real__ result, INVALID_EXCEPTION);
2947 check_isnan ("imag(ccos(-Inf + i Inf)) = NaN plus invalid exception",
2948 __imag__ result);
2949 result = FUNC(ccos) (BUILD_COMPLEX (plus_infty, minus_infty));
2950 check_isinfp_exc ("real(ccos(Inf - i Inf)) = +Inf plus invalid exception",
2951 __real__ result, INVALID_EXCEPTION);
2952 check_isnan ("imag(ccos(Inf - i Inf)) = NaN plus invalid exception",
2953 __imag__ result);
2954 result = FUNC(ccos) (BUILD_COMPLEX (minus_infty, minus_infty));
2955 check_isinfp_exc ("real(ccos(-Inf - i Inf)) = +Inf plus invalid exception",
2956 __real__ result, INVALID_EXCEPTION);
2957 check_isnan ("imag(ccos(-Inf - i Inf)) = NaN plus invalid exception",
2958 __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_isinfp ("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_isinfn ("imag(ccos(4.625 - i Inf)) = -Inf", __imag__ result);
2966 result = FUNC(ccos) (BUILD_COMPLEX (-4.625, plus_infty));
2967 check_isinfn ("real(ccos(-4.625 + i Inf)) = -Inf", __real__ result);
2968 check_isinfn ("imag(ccos(-4.625 + i Inf)) = -Inf", __imag__ result);
2969 result = FUNC(ccos) (BUILD_COMPLEX (-4.625, minus_infty));
2970 check_isinfn ("real(ccos(-4.625 - i Inf)) = -Inf", __real__ result);
2971 check_isinfp ("imag(ccos(-4.625 - i Inf)) = +Inf", __imag__ result);
2973 result = FUNC(ccos) (BUILD_COMPLEX (plus_infty, 6.75));
2974 check_isnan_exc ("real(ccos(+Inf + i6.75)) = NaN plus invalid exception",
2975 __real__ result, INVALID_EXCEPTION);
2976 check_isnan ("imag(ccos(+Inf + i6.75)) = NaN plus invalid exception",
2977 __imag__ result);
2978 result = FUNC(ccos) (BUILD_COMPLEX (plus_infty, -6.75));
2979 check_isnan_exc ("real(ccos(+Inf - i6.75)) = NaN plus invalid exception",
2980 __real__ result, INVALID_EXCEPTION);
2981 check_isnan ("imag(ccos(+Inf - i6.75)) = NaN plus invalid exception",
2982 __imag__ result);
2983 result = FUNC(ccos) (BUILD_COMPLEX (minus_infty, 6.75));
2984 check_isnan_exc ("real(ccos(-Inf + i6.75)) = NaN plus invalid exception",
2985 __real__ result, INVALID_EXCEPTION);
2986 check_isnan ("imag(ccos(-Inf + i6.75)) = NaN plus invalid exception",
2987 __imag__ result);
2988 result = FUNC(ccos) (BUILD_COMPLEX (minus_infty, -6.75));
2989 check_isnan_exc ("real(ccos(-Inf - i6.75)) = NaN plus invalid exception",
2990 __real__ result, INVALID_EXCEPTION);
2991 check_isnan ("imag(ccos(-Inf - i6.75)) = NaN plus invalid exception",
2992 __imag__ result);
2994 result = FUNC(ccos) (BUILD_COMPLEX (nan_value, 0.0));
2995 check_isnan ("real(ccos(NaN + i0)) = NaN", __real__ result);
2996 check ("imag(ccos(NaN + i0)) = +-0", FUNC(fabs) (__imag__ result), 0);
2997 result = FUNC(ccos) (BUILD_COMPLEX (nan_value, minus_zero));
2998 check_isnan ("real(ccos(NaN - i0)) = NaN", __real__ result);
2999 check ("imag(ccos(NaN - i0)) = +-0", FUNC(fabs) (__imag__ result), 0);
3001 result = FUNC(ccos) (BUILD_COMPLEX (nan_value, plus_infty));
3002 check_isinfp ("real(ccos(NaN + i Inf)) = +Inf", __real__ result);
3003 check_isnan ("imag(ccos(NaN + i Inf)) = NaN", __imag__ result);
3004 result = FUNC(ccos) (BUILD_COMPLEX (nan_value, minus_infty));
3005 check_isinfp ("real(ccos(NaN - i Inf)) = +Inf", __real__ result);
3006 check_isnan ("imag(ccos(NaN - i Inf)) = NaN", __imag__ result);
3008 result = FUNC(ccos) (BUILD_COMPLEX (nan_value, 9.0));
3009 check_isnan_maybe_exc ("real(ccos(NaN + i9.0)) = NaN plus maybe invalid exception",
3010 __real__ result, INVALID_EXCEPTION);
3011 check_isnan ("imag(ccos(NaN + i9.0)) = NaN plus maybe invalid exception",
3012 __imag__ result);
3013 result = FUNC(ccos) (BUILD_COMPLEX (nan_value, -9.0));
3014 check_isnan_maybe_exc ("real(ccos(NaN - i9.0)) = NaN plus maybe invalid exception",
3015 __real__ result, INVALID_EXCEPTION);
3016 check_isnan ("imag(ccos(NaN - i9.0)) = NaN plus maybe invalid exception",
3017 __imag__ result);
3019 result = FUNC(ccos) (BUILD_COMPLEX (0.0, nan_value));
3020 check_isnan ("real(ccos(0 + i NaN)) = NaN", __real__ result);
3021 check ("imag(ccos(0 + i NaN)) = +-0", FUNC(fabs) (__imag__ result), 0.0);
3022 result = FUNC(ccos) (BUILD_COMPLEX (minus_zero, nan_value));
3023 check_isnan ("real(ccos(-0 + i NaN)) = NaN", __real__ result);
3024 check ("imag(ccos(-0 + i NaN)) = +-0", FUNC(fabs) (__imag__ result), 0.0);
3026 result = FUNC(ccos) (BUILD_COMPLEX (10.0, nan_value));
3027 check_isnan_maybe_exc ("real(ccos(10 + i NaN)) = NaN plus maybe invalid exception",
3028 __real__ result, INVALID_EXCEPTION);
3029 check_isnan ("imag(ccos(10 + i NaN)) = NaN plus maybe invalid exception",
3030 __imag__ result);
3031 result = FUNC(ccos) (BUILD_COMPLEX (-10.0, nan_value));
3032 check_isnan_maybe_exc ("real(ccos(-10 + i NaN)) = NaN plus maybe invalid exception",
3033 __real__ result, INVALID_EXCEPTION);
3034 check_isnan ("imag(ccos(-10 + i NaN)) = NaN plus maybe invalid exception",
3035 __imag__ result);
3037 result = FUNC(ccos) (BUILD_COMPLEX (plus_infty, nan_value));
3038 check_isnan_maybe_exc ("real(ccos(+Inf + i NaN)) = NaN plus maybe invalid exception",
3039 __real__ result, INVALID_EXCEPTION);
3040 check_isnan ("imag(ccos(+Inf + i NaN)) = NaN plus maybe invalid exception",
3041 __imag__ result);
3042 result = FUNC(ccos) (BUILD_COMPLEX (minus_infty, nan_value));
3043 check_isnan_maybe_exc ("real(ccos(-Inf + i NaN)) = NaN plus maybe invalid exception",
3044 __real__ result, INVALID_EXCEPTION);
3045 check_isnan ("imag(ccos(-Inf + i NaN)) = NaN plus maybe invalid exception",
3046 __imag__ result);
3048 result = FUNC(ccos) (BUILD_COMPLEX (nan_value, nan_value));
3049 check_isnan ("real(ccos(NaN + i NaN)) = NaN", __real__ result);
3050 check_isnan ("imag(ccos(NaN + i NaN)) = NaN", __imag__ result);
3054 static void
3055 ccosh_test (void)
3057 __complex__ MATHTYPE result;
3059 result = FUNC(ccosh) (BUILD_COMPLEX (0.0, 0.0));
3060 check ("real(ccosh(0 + 0i)) = 1.0", __real__ result, 1.0);
3061 check ("imag(ccosh(0 + 0i)) = 0", __imag__ result, 0);
3062 result = FUNC(ccosh) (BUILD_COMPLEX (minus_zero, 0.0));
3063 check ("real(ccosh(-0 + 0i)) = 1.0", __real__ result, 1.0);
3064 check ("imag(ccosh(-0 + 0i)) = -0", __imag__ result, minus_zero);
3065 result = FUNC(ccosh) (BUILD_COMPLEX (0.0, minus_zero));
3066 check ("real(ccosh(0 - 0i)) = 1.0", __real__ result, 1.0);
3067 check ("imag(ccosh(0 - 0i)) = -0", __imag__ result, minus_zero);
3068 result = FUNC(ccosh) (BUILD_COMPLEX (minus_zero, minus_zero));
3069 check ("real(ccosh(-0 - 0i)) = 1.0", __real__ result, 1.0);
3070 check ("imag(ccosh(-0 - 0i)) = 0", __imag__ result, 0.0);
3072 result = FUNC(ccosh) (BUILD_COMPLEX (0.0, plus_infty));
3073 check_isnan_exc ("real(ccosh(0 + i Inf)) = NaN plus invalid exception",
3074 __real__ result, INVALID_EXCEPTION);
3075 check ("imag(ccosh(0 + i Inf)) = +-0 plus invalid exception",
3076 FUNC(fabs) (__imag__ result), 0);
3077 result = FUNC(ccosh) (BUILD_COMPLEX (minus_zero, plus_infty));
3078 check_isnan_exc ("real(ccosh(-0 + i Inf)) = NaN plus invalid exception",
3079 __real__ result, INVALID_EXCEPTION);
3080 check ("imag(ccosh(-0 + i Inf)) = +-0 plus invalid exception",
3081 FUNC(fabs) (__imag__ result), 0);
3082 result = FUNC(ccosh) (BUILD_COMPLEX (0.0, minus_infty));
3083 check_isnan_exc ("real(ccosh(0 - i Inf)) = NaN plus invalid exception",
3084 __real__ result, INVALID_EXCEPTION);
3085 check ("imag(ccosh(0 - i Inf)) = +-0 plus invalid exception",
3086 FUNC(fabs) (__imag__ result), 0);
3087 result = FUNC(ccosh) (BUILD_COMPLEX (minus_zero, minus_infty));
3088 check_isnan_exc ("real(ccosh(-0 - i Inf)) = NaN plus invalid exception",
3089 __real__ result, INVALID_EXCEPTION);
3090 check ("imag(ccosh(-0 - i Inf)) = +-0 plus invalid exception",
3091 FUNC(fabs) (__imag__ result), 0);
3093 result = FUNC(ccosh) (BUILD_COMPLEX (plus_infty, 0.0));
3094 check_isinfp ("real(ccosh(+Inf + 0i)) = +Inf", __real__ result);
3095 check ("imag(ccosh(+Inf + 0i)) = 0", __imag__ result, 0);
3096 result = FUNC(ccosh) (BUILD_COMPLEX (minus_infty, 0.0));
3097 check_isinfp ("real(ccosh(-Inf + 0i)) = +Inf", __real__ result);
3098 check ("imag(ccosh(-Inf + 0i)) = -0", __imag__ result, minus_zero);
3099 result = FUNC(ccosh) (BUILD_COMPLEX (plus_infty, minus_zero));
3100 check_isinfp ("real(ccosh(+Inf - 0i)) = +Inf", __real__ result);
3101 check ("imag(ccosh(+Inf - 0i)) = -0", __imag__ result, minus_zero);
3102 result = FUNC(ccosh) (BUILD_COMPLEX (minus_infty, minus_zero));
3103 check_isinfp ("real(ccosh(-Inf - 0i)) = +Inf", __real__ result);
3104 check ("imag(ccosh(-Inf - 0i)) = 0", __imag__ result, 0.0);
3106 result = FUNC(ccosh) (BUILD_COMPLEX (plus_infty, plus_infty));
3107 check_isinfp_exc ("real(ccosh(+Inf + i Inf)) = +Inf plus invalid exception",
3108 __real__ result, INVALID_EXCEPTION);
3109 check_isnan ("imag(ccosh(+Inf + i Inf)) = NaN plus invalid exception",
3110 __imag__ result);
3111 result = FUNC(ccosh) (BUILD_COMPLEX (minus_infty, plus_infty));
3112 check_isinfp_exc ("real(ccosh(-Inf + i Inf)) = +Inf plus invalid exception",
3113 __real__ result, INVALID_EXCEPTION);
3114 check_isnan ("imag(ccosh(-Inf + i Inf)) = NaN plus invalid exception",
3115 __imag__ result);
3116 result = FUNC(ccosh) (BUILD_COMPLEX (plus_infty, minus_infty));
3117 check_isinfp_exc ("real(ccosh(Inf - i Inf)) = +Inf plus invalid exception",
3118 __real__ result, INVALID_EXCEPTION);
3119 check_isnan ("imag(ccosh(Inf - i Inf)) = NaN plus invalid exception",
3120 __imag__ result);
3121 result = FUNC(ccosh) (BUILD_COMPLEX (minus_infty, minus_infty));
3122 check_isinfp_exc ("real(ccosh(-Inf - i Inf)) = +Inf plus invalid exception",
3123 __real__ result, INVALID_EXCEPTION);
3124 check_isnan ("imag(ccosh(-Inf - i Inf)) = NaN plus invalid exception",
3125 __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_isinfn ("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_isinfp ("imag(ccosh(-Inf + i4.625)) = Inf", __imag__ result);
3133 result = FUNC(ccosh) (BUILD_COMPLEX (plus_infty, -4.625));
3134 check_isinfn ("real(ccosh(+Inf - i4.625)) = -Inf", __real__ result);
3135 check_isinfp ("imag(ccosh(+Inf - i4.625)) = +Inf", __imag__ result);
3136 result = FUNC(ccosh) (BUILD_COMPLEX (minus_infty, -4.625));
3137 check_isinfn ("real(ccosh(-Inf - i4.625)) = -Inf", __real__ result);
3138 check_isinfn ("imag(ccosh(-Inf - i4.625)) = -Inf", __imag__ result);
3140 result = FUNC(ccosh) (BUILD_COMPLEX (6.75, plus_infty));
3141 check_isnan_exc ("real(ccosh(6.75 + i Inf)) = NaN plus invalid exception",
3142 __real__ result, INVALID_EXCEPTION);
3143 check_isnan ("imag(ccosh(6.75 + i Inf)) = NaN plus invalid exception",
3144 __imag__ result);
3145 result = FUNC(ccosh) (BUILD_COMPLEX (-6.75, plus_infty));
3146 check_isnan_exc ("real(ccosh(-6.75 + i Inf)) = NaN plus invalid exception",
3147 __real__ result, INVALID_EXCEPTION);
3148 check_isnan ("imag(ccosh(-6.75 + i Inf)) = NaN plus invalid exception",
3149 __imag__ result);
3150 result = FUNC(ccosh) (BUILD_COMPLEX (6.75, minus_infty));
3151 check_isnan_exc ("real(ccosh(6.75 - i Inf)) = NaN plus invalid exception",
3152 __real__ result, INVALID_EXCEPTION);
3153 check_isnan ("imag(ccosh(6.75 - i Inf)) = NaN plus invalid exception",
3154 __imag__ result);
3155 result = FUNC(ccosh) (BUILD_COMPLEX (-6.75, minus_infty));
3156 check_isnan_exc ("real(ccosh(-6.75 - i Inf)) = NaN plus invalid exception",
3157 __real__ result, INVALID_EXCEPTION);
3158 check_isnan ("imag(ccosh(-6.75 - i Inf)) = NaN plus invalid exception",
3159 __imag__ result);
3161 result = FUNC(ccosh) (BUILD_COMPLEX (0.0, nan_value));
3162 check_isnan ("real(ccosh(0 + i NaN)) = NaN", __real__ result);
3163 check ("imag(ccosh(0 + i NaN)) = +-0", FUNC(fabs) (__imag__ result), 0);
3164 result = FUNC(ccosh) (BUILD_COMPLEX (minus_zero, nan_value));
3165 check_isnan ("real(ccosh(-0 + i NaN)) = NaN", __real__ result);
3166 check ("imag(ccosh(-0 + i NaN)) = +-0", FUNC(fabs) (__imag__ result), 0);
3168 result = FUNC(ccosh) (BUILD_COMPLEX (plus_infty, nan_value));
3169 check_isinfp ("real(ccosh(+Inf + i NaN)) = +Inf", __real__ result);
3170 check_isnan ("imag(ccosh(+Inf + i NaN)) = NaN", __imag__ result);
3171 result = FUNC(ccosh) (BUILD_COMPLEX (minus_infty, nan_value));
3172 check_isinfp ("real(ccosh(-Inf + i NaN)) = +Inf", __real__ result);
3173 check_isnan ("imag(ccosh(-Inf + i NaN)) = NaN", __imag__ result);
3175 result = FUNC(ccosh) (BUILD_COMPLEX (9.0, nan_value));
3176 check_isnan_maybe_exc ("real(ccosh(9.0 + i NaN)) = NaN plus maybe invalid exception",
3177 __real__ result, INVALID_EXCEPTION);
3178 check_isnan ("imag(ccosh(9.0 + i NaN)) = NaN plus maybe invalid exception",
3179 __imag__ result);
3180 result = FUNC(ccosh) (BUILD_COMPLEX (-9.0, nan_value));
3181 check_isnan_maybe_exc ("real(ccosh(-9.0 + i NaN)) = NaN plus maybe invalid exception",
3182 __real__ result, INVALID_EXCEPTION);
3183 check_isnan ("imag(ccosh(-9.0 + i NaN)) = NaN plus maybe invalid exception",
3184 __imag__ result);
3186 result = FUNC(ccosh) (BUILD_COMPLEX (nan_value, 0.0));
3187 check_isnan ("real(ccosh(NaN + i0)) = NaN", __real__ result);
3188 check ("imag(ccosh(NaN + i0)) = +-0", FUNC(fabs) (__imag__ result), 0.0);
3189 result = FUNC(ccosh) (BUILD_COMPLEX (nan_value, minus_zero));
3190 check_isnan ("real(ccosh(NaN - i0)) = NaN", __real__ result);
3191 check ("imag(ccosh(NaN - i0)) = +-0", FUNC(fabs) (__imag__ result), 0.0);
3193 result = FUNC(ccosh) (BUILD_COMPLEX (nan_value, 10.0));
3194 check_isnan_maybe_exc ("real(ccosh(NaN + i10)) = NaN plus maybe invalid exception",
3195 __real__ result, INVALID_EXCEPTION);
3196 check_isnan ("imag(ccosh(NaN + i10)) = NaN plus maybe invalid exception",
3197 __imag__ result);
3198 result = FUNC(ccosh) (BUILD_COMPLEX (nan_value, -10.0));
3199 check_isnan_maybe_exc ("real(ccosh(NaN - i10)) = NaN plus maybe invalid exception",
3200 __real__ result, INVALID_EXCEPTION);
3201 check_isnan ("imag(ccosh(NaN - i10)) = NaN plus maybe invalid exception",
3202 __imag__ result);
3204 result = FUNC(ccosh) (BUILD_COMPLEX (nan_value, plus_infty));
3205 check_isnan_maybe_exc ("real(ccosh(NaN + i Inf)) = NaN plus maybe invalid exception",
3206 __real__ result, INVALID_EXCEPTION);
3207 check_isnan ("imag(ccosh(NaN + i Inf)) = NaN plus maybe invalid exception",
3208 __imag__ result);
3209 result = FUNC(ccosh) (BUILD_COMPLEX (nan_value, minus_infty));
3210 check_isnan_maybe_exc ("real(ccosh(NaN - i Inf)) = NaN plus maybe invalid exception",
3211 __real__ result, INVALID_EXCEPTION);
3212 check_isnan ("imag(ccosh(NaN - i Inf)) = NaN plus maybe invalid exception",
3213 __imag__ result);
3215 result = FUNC(ccosh) (BUILD_COMPLEX (nan_value, nan_value));
3216 check_isnan ("real(ccosh(NaN + i NaN)) = NaN", __real__ result);
3217 check_isnan ("imag(ccosh(NaN + i NaN)) = NaN", __imag__ result);
3221 static void
3222 cacos_test (void)
3224 __complex__ MATHTYPE result;
3226 result = FUNC(cacos) (BUILD_COMPLEX (0, 0));
3227 check ("real(cacos(0 + i0)) = pi/2", __real__ result, M_PI_2);
3228 check ("imag(cacos(0 + i0)) = -0", __imag__ result, minus_zero);
3229 result = FUNC(cacos) (BUILD_COMPLEX (minus_zero, 0));
3230 check ("real(cacos(-0 + i0)) = pi/2", __real__ result, M_PI_2);
3231 check ("imag(cacos(-0 + i0)) = -0", __imag__ result, minus_zero);
3232 result = FUNC(cacos) (BUILD_COMPLEX (0, minus_zero));
3233 check ("real(cacos(0 - i0)) = pi/2", __real__ result, M_PI_2);
3234 check ("imag(cacos(0 - i0)) = 0", __imag__ result, 0);
3235 result = FUNC(cacos) (BUILD_COMPLEX (minus_zero, minus_zero));
3236 check ("real(cacos(-0 - i0)) = pi/2", __real__ result, M_PI_2);
3237 check ("imag(cacos(-0 - i0)) = 0", __imag__ result, 0);
3239 result = FUNC(cacos) (BUILD_COMPLEX (minus_infty, plus_infty));
3240 check ("real(cacos(-Inf + i Inf)) = 3*pi/4", __real__ result, M_PI - M_PI_4);
3241 check_isinfn ("imag(cacos(-Inf + i Inf)) = -Inf", __imag__ result);
3242 result = FUNC(cacos) (BUILD_COMPLEX (minus_infty, minus_infty));
3243 check ("real(cacos(-Inf - i Inf)) = 3*pi/4", __real__ result, M_PI - M_PI_4);
3244 check_isinfp ("imag(cacos(-Inf - i Inf)) = +Inf", __imag__ result);
3246 result = FUNC(cacos) (BUILD_COMPLEX (plus_infty, plus_infty));
3247 check ("real(cacos(+Inf + i Inf)) = pi/4", __real__ result, M_PI_4);
3248 check_isinfn ("imag(cacos(+Inf + i Inf)) = -Inf", __imag__ result);
3249 result = FUNC(cacos) (BUILD_COMPLEX (plus_infty, minus_infty));
3250 check ("real(cacos(+Inf - i Inf)) = pi/4", __real__ result, M_PI_4);
3251 check_isinfp ("imag(cacos(+Inf - i Inf)) = +Inf", __imag__ result);
3253 result = FUNC(cacos) (BUILD_COMPLEX (-10.0, plus_infty));
3254 check ("real(cacos(-10.0 + i Inf)) = pi/2", __real__ result, M_PI_2);
3255 check_isinfn ("imag(cacos(-10.0 + i Inf)) = -Inf", __imag__ result);
3256 result = FUNC(cacos) (BUILD_COMPLEX (-10.0, minus_infty));
3257 check ("real(cacos(-10.0 - i Inf)) = pi/2", __real__ result, M_PI_2);
3258 check_isinfp ("imag(cacos(-10.0 - i Inf)) = +Inf", __imag__ result);
3259 result = FUNC(cacos) (BUILD_COMPLEX (0, plus_infty));
3260 check ("real(cacos(0 + i Inf)) = pi/2", __real__ result, M_PI_2);
3261 check_isinfn ("imag(cacos(0 + i Inf)) = -Inf", __imag__ result);
3262 result = FUNC(cacos) (BUILD_COMPLEX (0, minus_infty));
3263 check ("real(cacos(0 - i Inf)) = pi/2", __real__ result, M_PI_2);
3264 check_isinfp ("imag(cacos(0 - i Inf)) = +Inf", __imag__ result);
3265 result = FUNC(cacos) (BUILD_COMPLEX (0.1, plus_infty));
3266 check ("real(cacos(0.1 + i Inf)) = pi/2", __real__ result, M_PI_2);
3267 check_isinfn ("imag(cacos(0.1 + i Inf)) = -Inf", __imag__ result);
3268 result = FUNC(cacos) (BUILD_COMPLEX (0.1, minus_infty));
3269 check ("real(cacos(0.1 - i Inf)) = pi/2", __real__ result, M_PI_2);
3270 check_isinfp ("imag(cacos(0.1 - i Inf)) = +Inf", __imag__ result);
3272 result = FUNC(cacos) (BUILD_COMPLEX (minus_infty, 0));
3273 check ("real(cacos(-Inf + i0)) = pi", __real__ result, M_PI);
3274 check_isinfn ("imag(cacos(-Inf + i0)) = -Inf", __imag__ result);
3275 result = FUNC(cacos) (BUILD_COMPLEX (minus_infty, minus_zero));
3276 check ("real(cacos(-Inf - i0)) = pi", __real__ result, M_PI);
3277 check_isinfp ("imag(cacos(-Inf - i0)) = +Inf", __imag__ result);
3278 result = FUNC(cacos) (BUILD_COMPLEX (minus_infty, 100));
3279 check ("real(cacos(-Inf + i100)) = pi", __real__ result, M_PI);
3280 check_isinfn ("imag(cacos(-Inf + i100)) = -Inf", __imag__ result);
3281 result = FUNC(cacos) (BUILD_COMPLEX (minus_infty, -100));
3282 check ("real(cacos(-Inf - i100)) = pi", __real__ result, M_PI);
3283 check_isinfp ("imag(cacos(-Inf - i100)) = +Inf", __imag__ result);
3285 result = FUNC(cacos) (BUILD_COMPLEX (plus_infty, 0));
3286 check ("real(cacos(+Inf + i0)) = 0", __real__ result, 0);
3287 check_isinfn ("imag(cacos(+Inf + i0)) = -Inf", __imag__ result);
3288 result = FUNC(cacos) (BUILD_COMPLEX (plus_infty, minus_zero));
3289 check ("real(cacos(+Inf - i0)) = 0", __real__ result, 0);
3290 check_isinfp ("imag(cacos(+Inf - i0)) = +Inf", __imag__ result);
3291 result = FUNC(cacos) (BUILD_COMPLEX (plus_infty, 0.5));
3292 check ("real(cacos(+Inf + i0.5)) = 0", __real__ result, 0);
3293 check_isinfn ("imag(cacos(+Inf + i0.5)) = -Inf", __imag__ result);
3294 result = FUNC(cacos) (BUILD_COMPLEX (plus_infty, -0.5));
3295 check ("real(cacos(+Inf - i0.5)) = 0", __real__ result, 0);
3296 check_isinfp ("imag(cacos(+Inf - i0.5)) = +Inf", __imag__ result);
3298 result = FUNC(cacos) (BUILD_COMPLEX (plus_infty, nan_value));
3299 check_isnan ("real(cacos(+Inf + i NaN)) = NaN", __real__ result);
3300 check_isinfp ("imag(cacos(+Inf + i NaN)) = +-Inf",
3301 FUNC(fabs) (__imag__ result));
3302 result = FUNC(cacos) (BUILD_COMPLEX (minus_infty, nan_value));
3303 check_isnan ("real(cacos(-Inf + i NaN)) = NaN", __real__ result);
3304 check_isinfp ("imag(cacos(-Inf + i NaN)) = +-Inf",
3305 FUNC(fabs) (__imag__ result));
3307 result = FUNC(cacos) (BUILD_COMPLEX (0, nan_value));
3308 check ("real(cacos(0 + i NaN)) = pi/2", __real__ result, M_PI_2);
3309 check_isnan ("imag(cacos(0 + i NaN)) = NaN", __imag__ result);
3310 result = FUNC(cacos) (BUILD_COMPLEX (minus_zero, nan_value));
3311 check ("real(cacos(-0 + i NaN)) = pi/2", __real__ result, M_PI_2);
3312 check_isnan ("imag(cacos(-0 + i NaN)) = NaN", __imag__ result);
3314 result = FUNC(cacos) (BUILD_COMPLEX (nan_value, plus_infty));
3315 check_isnan ("real(cacos(NaN + i Inf)) = NaN", __real__ result);
3316 check_isinfn ("imag(cacos(NaN + i Inf)) = -Inf", __imag__ result);
3317 result = FUNC(cacos) (BUILD_COMPLEX (nan_value, minus_infty));
3318 check_isnan ("real(cacos(NaN - i Inf)) = NaN", __real__ result);
3319 check_isinfp ("imag(cacos(NaN - i Inf)) = +Inf", __imag__ result);
3321 result = FUNC(cacos) (BUILD_COMPLEX (10.5, nan_value));
3322 check_isnan_maybe_exc ("real(cacos(10.5 + i NaN)) = NaN plus maybe invalid exception",
3323 __real__ result, INVALID_EXCEPTION);
3324 check_isnan ("imag(cacos(10.5 + i NaN)) = NaN plus maybe invalid exception",
3325 __imag__ result);
3326 result = FUNC(cacos) (BUILD_COMPLEX (-10.5, nan_value));
3327 check_isnan_maybe_exc ("real(cacos(-10.5 + i NaN)) = NaN plus maybe invalid exception",
3328 __real__ result, INVALID_EXCEPTION);
3329 check_isnan ("imag(cacos(-10.5 + i NaN)) = NaN plus maybe invalid exception",
3330 __imag__ result);
3332 result = FUNC(cacos) (BUILD_COMPLEX (nan_value, 0.75));
3333 check_isnan_maybe_exc ("real(cacos(NaN + i0.75)) = NaN plus maybe invalid exception",
3334 __real__ result, INVALID_EXCEPTION);
3335 check_isnan ("imag(cacos(NaN + i0.75)) = NaN plus maybe invalid exception",
3336 __imag__ result);
3337 result = FUNC(cacos) (BUILD_COMPLEX (-10.5, nan_value));
3338 check_isnan_maybe_exc ("real(cacos(NaN - i0.75)) = NaN plus maybe invalid exception",
3339 __real__ result, INVALID_EXCEPTION);
3340 check_isnan ("imag(cacos(NaN - i0.75)) = NaN plus maybe invalid exception",
3341 __imag__ result);
3343 result = FUNC(cacos) (BUILD_COMPLEX (nan_value, nan_value));
3344 check_isnan ("real(cacos(NaN + i NaN)) = NaN", __real__ result);
3345 check_isnan ("imag(cacos(NaN + i NaN)) = NaN", __imag__ result);
3349 static void
3350 cacosh_test (void)
3352 __complex__ MATHTYPE result;
3354 result = FUNC(cacosh) (BUILD_COMPLEX (0, 0));
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, 0));
3358 check ("real(cacosh(-0 + i0)) = 0", __real__ result, 0);
3359 check ("imag(cacosh(-0 + i0)) = pi/2", __imag__ result, M_PI_2);
3360 result = FUNC(cacosh) (BUILD_COMPLEX (0, minus_zero));
3361 check ("real(cacosh(0 - i0)) = 0", __real__ result, 0);
3362 check ("imag(cacosh(0 - i0)) = -pi/2", __imag__ result, -M_PI_2);
3363 result = FUNC(cacosh) (BUILD_COMPLEX (minus_zero, minus_zero));
3364 check ("real(cacosh(-0 - i0)) = 0", __real__ result, 0);
3365 check ("imag(cacosh(-0 - i0)) = -pi/2", __imag__ result, -M_PI_2);
3367 result = FUNC(cacosh) (BUILD_COMPLEX (minus_infty, plus_infty));
3368 check_isinfp ("real(cacosh(-Inf + i Inf)) = +Inf", __real__ result);
3369 check ("imag(cacosh(-Inf + i Inf)) = 3*pi/4", __imag__ result,
3370 M_PI - M_PI_4);
3371 result = FUNC(cacosh) (BUILD_COMPLEX (minus_infty, minus_infty));
3372 check_isinfp ("real(cacosh(-Inf - i Inf)) = +Inf", __real__ result);
3373 check ("imag(cacosh(-Inf - i Inf)) = -3*pi/4", __imag__ result,
3374 M_PI_4 - M_PI);
3376 result = FUNC(cacosh) (BUILD_COMPLEX (plus_infty, plus_infty));
3377 check_isinfp ("real(cacosh(+Inf + i Inf)) = +Inf", __real__ result);
3378 check ("imag(cacosh(+Inf + i Inf)) = pi/4", __imag__ result, M_PI_4);
3379 result = FUNC(cacosh) (BUILD_COMPLEX (plus_infty, minus_infty));
3380 check_isinfp ("real(cacosh(+Inf - i Inf)) = +Inf", __real__ result);
3381 check ("imag(cacosh(+Inf - i Inf)) = -pi/4", __imag__ result, -M_PI_4);
3383 result = FUNC(cacosh) (BUILD_COMPLEX (-10.0, plus_infty));
3384 check_isinfp ("real(cacosh(-10.0 + i Inf)) = +Inf", __real__ result);
3385 check ("imag(cacosh(-10.0 + i Inf)) = pi/2", __imag__ result, M_PI_2);
3386 result = FUNC(cacosh) (BUILD_COMPLEX (-10.0, minus_infty));
3387 check_isinfp ("real(cacosh(-10.0 - i Inf)) = +Inf", __real__ result);
3388 check ("imag(cacosh(-10.0 - i Inf)) = -pi/2", __imag__ result, -M_PI_2);
3389 result = FUNC(cacosh) (BUILD_COMPLEX (0, plus_infty));
3390 check_isinfp ("real(cacosh(0 + i Inf)) = +Inf", __real__ result);
3391 check ("imag(cacosh(0 + i Inf)) = pi/2", __imag__ result, M_PI_2);
3392 result = FUNC(cacosh) (BUILD_COMPLEX (0, minus_infty));
3393 check_isinfp ("real(cacosh(0 - i Inf)) = +Inf", __real__ result);
3394 check ("imag(cacosh(0 - i Inf)) = -pi/2", __imag__ result, -M_PI_2);
3395 result = FUNC(cacosh) (BUILD_COMPLEX (0.1, plus_infty));
3396 check_isinfp ("real(cacosh(0.1 + i Inf)) = +Inf", __real__ result);
3397 check ("imag(cacosh(0.1 + i Inf)) = pi/2", __imag__ result, M_PI_2);
3398 result = FUNC(cacosh) (BUILD_COMPLEX (0.1, minus_infty));
3399 check_isinfp ("real(cacosh(0.1 - i Inf)) = +Inf", __real__ result);
3400 check ("imag(cacosh(0.1 - i Inf)) = -pi/2", __imag__ result, -M_PI_2);
3402 result = FUNC(cacosh) (BUILD_COMPLEX (minus_infty, 0));
3403 check_isinfp ("real(cacosh(-Inf + i0)) = +Inf", __real__ result);
3404 check ("imag(cacosh(-Inf + i0)) = pi", __imag__ result, M_PI);
3405 result = FUNC(cacosh) (BUILD_COMPLEX (minus_infty, minus_zero));
3406 check_isinfp ("real(cacosh(-Inf - i0)) = +Inf", __real__ result);
3407 check ("imag(cacosh(-Inf - i0)) = -pi", __imag__ result, -M_PI);
3408 result = FUNC(cacosh) (BUILD_COMPLEX (minus_infty, 100));
3409 check_isinfp ("real(cacosh(-Inf + i100)) = +Inf", __real__ result);
3410 check ("imag(cacosh(-Inf + i100)) = pi", __imag__ result, M_PI);
3411 result = FUNC(cacosh) (BUILD_COMPLEX (minus_infty, -100));
3412 check_isinfp ("real(cacosh(-Inf - i100)) = +Inf", __real__ result);
3413 check ("imag(cacosh(-Inf - i100)) = -pi", __imag__ result, -M_PI);
3415 result = FUNC(cacosh) (BUILD_COMPLEX (plus_infty, 0));
3416 check_isinfp ("real(cacosh(+Inf + i0)) = +Inf", __real__ result);
3417 check ("imag(cacosh(+Inf + i0)) = 0", __imag__ result, 0);
3418 result = FUNC(cacosh) (BUILD_COMPLEX (plus_infty, minus_zero));
3419 check_isinfp ("real(cacosh(+Inf - i0)) = +Inf", __real__ result);
3420 check ("imag(cacosh(+Inf - i0)) = -0", __imag__ result, minus_zero);
3421 result = FUNC(cacosh) (BUILD_COMPLEX (plus_infty, 0.5));
3422 check_isinfp ("real(cacosh(+Inf + i0.5)) = +Inf", __real__ result);
3423 check ("imag(cacosh(+Inf + i0.5)) = 0", __imag__ result, 0);
3424 result = FUNC(cacosh) (BUILD_COMPLEX (plus_infty, -0.5));
3425 check_isinfp ("real(cacosh(+Inf - i0.5)) = +Inf", __real__ result);
3426 check ("imag(cacosh(+Inf - i0.5)) = -0", __imag__ result, minus_zero);
3428 result = FUNC(cacosh) (BUILD_COMPLEX (plus_infty, nan_value));
3429 check_isinfp ("real(cacosh(+Inf + i NaN)) = +Inf", __real__ result);
3430 check_isnan ("imag(cacosh(+Inf + i NaN)) = NaN", __imag__ result);
3431 result = FUNC(cacosh) (BUILD_COMPLEX (minus_infty, nan_value));
3432 check_isinfp ("real(cacosh(-Inf + i NaN)) = +Inf", __real__ result);
3433 check_isnan ("imag(cacosh(-Inf + i NaN)) = NaN", __imag__ result);
3435 result = FUNC(cacosh) (BUILD_COMPLEX (0, nan_value));
3436 check_isnan ("real(cacosh(0 + i NaN)) = NaN", __real__ result);
3437 check_isnan ("imag(cacosh(0 + i NaN)) = NaN", __imag__ result);
3438 result = FUNC(cacosh) (BUILD_COMPLEX (minus_zero, nan_value));
3439 check_isnan ("real(cacosh(-0 + i NaN)) = NaN", __real__ result);
3440 check_isnan ("imag(cacosh(-0 + i NaN)) = NaN", __imag__ result);
3442 result = FUNC(cacosh) (BUILD_COMPLEX (nan_value, plus_infty));
3443 check_isinfp ("real(cacosh(NaN + i Inf)) = +Inf", __real__ result);
3444 check_isnan ("imag(cacosh(NaN + i Inf)) = NaN", __imag__ result);
3445 result = FUNC(cacosh) (BUILD_COMPLEX (nan_value, minus_infty));
3446 check_isinfp ("real(cacosh(NaN - i Inf)) = +Inf", __real__ result);
3447 check_isnan ("imag(cacosh(NaN - i Inf)) = NaN", __imag__ result);
3449 result = FUNC(cacosh) (BUILD_COMPLEX (10.5, nan_value));
3450 check_isnan_maybe_exc ("real(cacosh(10.5 + i NaN)) = NaN plus maybe invalid exception",
3451 __real__ result, INVALID_EXCEPTION);
3452 check_isnan ("imag(cacosh(10.5 + i NaN)) = NaN plus maybe invalid exception",
3453 __imag__ result);
3454 result = FUNC(cacosh) (BUILD_COMPLEX (-10.5, nan_value));
3455 check_isnan_maybe_exc ("real(cacosh(-10.5 + i NaN)) = NaN plus maybe invalid exception",
3456 __real__ result, INVALID_EXCEPTION);
3457 check_isnan ("imag(cacosh(-10.5 + i NaN)) = NaN plus maybe invalid exception",
3458 __imag__ result);
3460 result = FUNC(cacosh) (BUILD_COMPLEX (nan_value, 0.75));
3461 check_isnan_maybe_exc ("real(cacosh(NaN + i0.75)) = NaN plus maybe invalid exception",
3462 __real__ result, INVALID_EXCEPTION);
3463 check_isnan ("imag(cacosh(NaN + i0.75)) = NaN plus maybe invalid exception",
3464 __imag__ result);
3465 result = FUNC(cacosh) (BUILD_COMPLEX (-10.5, nan_value));
3466 check_isnan_maybe_exc ("real(cacosh(NaN - i0.75)) = NaN plus maybe invalid exception",
3467 __real__ result, INVALID_EXCEPTION);
3468 check_isnan ("imag(cacosh(NaN - i0.75)) = NaN plus maybe invalid exception",
3469 __imag__ result);
3471 result = FUNC(cacosh) (BUILD_COMPLEX (nan_value, nan_value));
3472 check_isnan ("real(cacosh(NaN + i NaN)) = NaN", __real__ result);
3473 check_isnan ("imag(cacosh(NaN + i NaN)) = NaN", __imag__ result);
3477 static void
3478 casin_test (void)
3480 __complex__ MATHTYPE result;
3482 result = FUNC(casin) (BUILD_COMPLEX (0, 0));
3483 check ("real(casin(0 + i0)) = 0", __real__ result, 0);
3484 check ("imag(casin(0 + i0)) = 0", __imag__ result, 0);
3485 result = FUNC(casin) (BUILD_COMPLEX (minus_zero, 0));
3486 check ("real(casin(-0 + i0)) = -0", __real__ result, minus_zero);
3487 check ("imag(casin(-0 + i0)) = 0", __imag__ result, 0);
3488 result = FUNC(casin) (BUILD_COMPLEX (0, minus_zero));
3489 check ("real(casin(0 - i0)) = 0", __real__ result, 0);
3490 check ("imag(casin(0 - i0)) = -0", __imag__ result, minus_zero);
3491 result = FUNC(casin) (BUILD_COMPLEX (minus_zero, minus_zero));
3492 check ("real(casin(-0 - i0)) = -0", __real__ result, minus_zero);
3493 check ("imag(casin(-0 - i0)) = -0", __imag__ result, minus_zero);
3495 result = FUNC(casin) (BUILD_COMPLEX (plus_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 (plus_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);
3501 result = FUNC(casin) (BUILD_COMPLEX (minus_infty, plus_infty));
3502 check ("real(casin(-Inf + i Inf)) = -pi/4", __real__ result, -M_PI_4);
3503 check_isinfp ("imag(casin(-Inf + i Inf)) = +Inf", __imag__ result);
3504 result = FUNC(casin) (BUILD_COMPLEX (minus_infty, minus_infty));
3505 check ("real(casin(-Inf - i Inf)) = -pi/4", __real__ result, -M_PI_4);
3506 check_isinfn ("imag(casin(-Inf - i Inf)) = -Inf", __imag__ result);
3508 result = FUNC(casin) (BUILD_COMPLEX (-10.0, plus_infty));
3509 check ("real(casin(-10.0 + i Inf)) = -0", __real__ result, minus_zero);
3510 check_isinfp ("imag(casin(-10.0 + i Inf)) = +Inf", __imag__ result);
3511 result = FUNC(casin) (BUILD_COMPLEX (-10.0, minus_infty));
3512 check ("real(casin(-10.0 - i Inf)) = -0", __real__ result, minus_zero);
3513 check_isinfn ("imag(casin(-10.0 - i Inf)) = -Inf", __imag__ result);
3514 result = FUNC(casin) (BUILD_COMPLEX (0, plus_infty));
3515 check ("real(casin(0 + i Inf)) = 0", __real__ result, 0.0);
3516 check_isinfp ("imag(casin(0 + i Inf)) = +Inf", __imag__ result);
3517 result = FUNC(casin) (BUILD_COMPLEX (0, minus_infty));
3518 check ("real(casin(0 - i Inf)) = 0", __real__ result, 0.0);
3519 check_isinfn ("imag(casin(0 - i Inf)) = -Inf", __imag__ result);
3520 result = FUNC(casin) (BUILD_COMPLEX (minus_zero, plus_infty));
3521 check ("real(casin(-0 + i Inf)) = -0", __real__ result, minus_zero);
3522 check_isinfp ("imag(casin(-0 + i Inf)) = +Inf", __imag__ result);
3523 result = FUNC(casin) (BUILD_COMPLEX (minus_zero, minus_infty));
3524 check ("real(casin(-0 - i Inf)) = -0", __real__ result, minus_zero);
3525 check_isinfn ("imag(casin(-0 - i Inf)) = -Inf", __imag__ result);
3526 result = FUNC(casin) (BUILD_COMPLEX (0.1, plus_infty));
3527 check ("real(casin(0.1 + i Inf)) = 0", __real__ result, 0);
3528 check_isinfp ("imag(casin(0.1 + i Inf)) = +Inf", __imag__ result);
3529 result = FUNC(casin) (BUILD_COMPLEX (0.1, minus_infty));
3530 check ("real(casin(0.1 - i Inf)) = 0", __real__ result, 0);
3531 check_isinfn ("imag(casin(0.1 - i Inf)) = -Inf", __imag__ result);
3533 result = FUNC(casin) (BUILD_COMPLEX (minus_infty, 0));
3534 check ("real(casin(-Inf + i0)) = -pi/2", __real__ result, -M_PI_2);
3535 check_isinfp ("imag(casin(-Inf + i0)) = +Inf", __imag__ result);
3536 result = FUNC(casin) (BUILD_COMPLEX (minus_infty, minus_zero));
3537 check ("real(casin(-Inf - i0)) = -pi/2", __real__ result, -M_PI_2);
3538 check_isinfn ("imag(casin(-Inf - i0)) = -Inf", __imag__ result);
3539 result = FUNC(casin) (BUILD_COMPLEX (minus_infty, 100));
3540 check ("real(casin(-Inf + i100)) = -pi/2", __real__ result, -M_PI_2);
3541 check_isinfp ("imag(casin(-Inf + i100)) = +Inf", __imag__ result);
3542 result = FUNC(casin) (BUILD_COMPLEX (minus_infty, -100));
3543 check ("real(casin(-Inf - i100)) = -pi/2", __real__ result, -M_PI_2);
3544 check_isinfn ("imag(casin(-Inf - i100)) = -Inf", __imag__ result);
3546 result = FUNC(casin) (BUILD_COMPLEX (plus_infty, 0));
3547 check ("real(casin(+Inf + i0)) = pi/2", __real__ result, M_PI_2);
3548 check_isinfp ("imag(casin(+Inf + i0)) = +Inf", __imag__ result);
3549 result = FUNC(casin) (BUILD_COMPLEX (plus_infty, minus_zero));
3550 check ("real(casin(+Inf - i0)) = pi/2", __real__ result, M_PI_2);
3551 check_isinfn ("imag(casin(+Inf - i0)) = -Inf", __imag__ result);
3552 result = FUNC(casin) (BUILD_COMPLEX (plus_infty, 0.5));
3553 check ("real(casin(+Inf + i0.5)) = pi/2", __real__ result, M_PI_2);
3554 check_isinfp ("imag(casin(+Inf + i0.5)) = +Inf", __imag__ result);
3555 result = FUNC(casin) (BUILD_COMPLEX (plus_infty, -0.5));
3556 check ("real(casin(+Inf - i0.5)) = pi/2", __real__ result, M_PI_2);
3557 check_isinfn ("imag(casin(+Inf - i0.5)) = -Inf", __imag__ result);
3559 result = FUNC(casin) (BUILD_COMPLEX (nan_value, plus_infty));
3560 check_isnan ("real(casin(NaN + i Inf)) = NaN", __real__ result);
3561 check_isinfp ("imag(casin(NaN + i Inf)) = +Inf", __imag__ result);
3562 result = FUNC(casin) (BUILD_COMPLEX (nan_value, minus_infty));
3563 check_isnan ("real(casin(NaN - i Inf)) = NaN", __real__ result);
3564 check_isinfn ("imag(casin(NaN - i Inf)) = -Inf", __imag__ result);
3566 result = FUNC(casin) (BUILD_COMPLEX (0.0, nan_value));
3567 check ("real(casin(0 + i NaN)) = 0", __real__ result, 0.0);
3568 check_isnan ("imag(casin(0 + i NaN)) = NaN", __imag__ result);
3569 result = FUNC(casin) (BUILD_COMPLEX (minus_zero, nan_value));
3570 check ("real(casin(-0 + i NaN)) = -0", __real__ result, minus_zero);
3571 check_isnan ("imag(casin(-0 + i NaN)) = NaN", __imag__ result);
3573 result = FUNC(casin) (BUILD_COMPLEX (plus_infty, nan_value));
3574 check_isnan ("real(casin(+Inf + i NaN)) = NaN", __real__ result);
3575 check_isinfp ("imag(casin(+Inf + i NaN)) = +-Inf",
3576 FUNC(fabs) (__imag__ result));
3577 result = FUNC(casin) (BUILD_COMPLEX (minus_infty, nan_value));
3578 check_isnan ("real(casin(-Inf + i NaN)) = NaN", __real__ result);
3579 check_isinfp ("imag(casin(-Inf + NaN)) = +-Inf",
3580 FUNC(fabs) (__imag__ result));
3582 result = FUNC(casin) (BUILD_COMPLEX (nan_value, 10.5));
3583 check_isnan_maybe_exc ("real(casin(NaN + i10.5)) = NaN plus maybe invalid exception",
3584 __real__ result, INVALID_EXCEPTION);
3585 check_isnan ("imag(casin(NaN + i10.5)) = NaN plus maybe invalid exception",
3586 __imag__ result);
3587 result = FUNC(casin) (BUILD_COMPLEX (nan_value, -10.5));
3588 check_isnan_maybe_exc ("real(casin(NaN - i10.5)) = NaN plus maybe invalid exception",
3589 __real__ result, INVALID_EXCEPTION);
3590 check_isnan ("imag(casin(NaN - i10.5)) = NaN plus maybe invalid exception",
3591 __imag__ result);
3593 result = FUNC(casin) (BUILD_COMPLEX (0.75, nan_value));
3594 check_isnan_maybe_exc ("real(casin(0.75 + i NaN)) = NaN plus maybe invalid exception",
3595 __real__ result, INVALID_EXCEPTION);
3596 check_isnan ("imag(casin(0.75 + i NaN)) = NaN plus maybe invalid exception",
3597 __imag__ result);
3598 result = FUNC(casin) (BUILD_COMPLEX (-0.75, nan_value));
3599 check_isnan_maybe_exc ("real(casin(-0.75 + i NaN)) = NaN plus maybe invalid exception",
3600 __real__ result, INVALID_EXCEPTION);
3601 check_isnan ("imag(casin(-0.75 + i NaN)) = NaN plus maybe invalid exception",
3602 __imag__ result);
3604 result = FUNC(casin) (BUILD_COMPLEX (nan_value, nan_value));
3605 check_isnan ("real(casin(NaN + i NaN)) = NaN", __real__ result);
3606 check_isnan ("imag(casin(NaN + i NaN)) = NaN", __imag__ result);
3610 static void
3611 casinh_test (void)
3613 __complex__ MATHTYPE result;
3615 result = FUNC(casinh) (BUILD_COMPLEX (0, 0));
3616 check ("real(casinh(0 + i0)) = 0", __real__ result, 0);
3617 check ("imag(casinh(0 + i0)) = 0", __imag__ result, 0);
3618 result = FUNC(casinh) (BUILD_COMPLEX (minus_zero, 0));
3619 check ("real(casinh(-0 + i0)) = -0", __real__ result, minus_zero);
3620 check ("imag(casinh(-0 + i0)) = 0", __imag__ result, 0);
3621 result = FUNC(casinh) (BUILD_COMPLEX (0, minus_zero));
3622 check ("real(casinh(0 - i0)) = 0", __real__ result, 0);
3623 check ("imag(casinh(0 - i0)) = -0", __imag__ result, minus_zero);
3624 result = FUNC(casinh) (BUILD_COMPLEX (minus_zero, minus_zero));
3625 check ("real(casinh(-0 - i0)) = -0", __real__ result, minus_zero);
3626 check ("imag(casinh(-0 - i0)) = -0", __imag__ result, minus_zero);
3628 result = FUNC(casinh) (BUILD_COMPLEX (plus_infty, plus_infty));
3629 check_isinfp ("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 (plus_infty, minus_infty));
3632 check_isinfp ("real(casinh(+Inf - i Inf)) = +Inf", __real__ result);
3633 check ("imag(casinh(+Inf - i Inf)) = -pi/4", __imag__ result, -M_PI_4);
3634 result = FUNC(casinh) (BUILD_COMPLEX (minus_infty, plus_infty));
3635 check_isinfn ("real(casinh(-Inf + i Inf)) = -Inf", __real__ result);
3636 check ("imag(casinh(-Inf + i Inf)) = pi/4", __imag__ result, M_PI_4);
3637 result = FUNC(casinh) (BUILD_COMPLEX (minus_infty, minus_infty));
3638 check_isinfn ("real(casinh(-Inf - i Inf)) = -Inf", __real__ result);
3639 check ("imag(casinh(-Inf - i Inf)) = -pi/4", __imag__ result, -M_PI_4);
3641 result = FUNC(casinh) (BUILD_COMPLEX (-10.0, plus_infty));
3642 check_isinfn ("real(casinh(-10.0 + i Inf)) = -Inf", __real__ result);
3643 check ("imag(casinh(-10.0 + i Inf)) = pi/2", __imag__ result, M_PI_2);
3644 result = FUNC(casinh) (BUILD_COMPLEX (-10.0, minus_infty));
3645 check_isinfn ("real(casinh(-10.0 - i Inf)) = -Inf", __real__ result);
3646 check ("imag(casinh(-10.0 - i Inf)) = -pi/2", __imag__ result, -M_PI_2);
3647 result = FUNC(casinh) (BUILD_COMPLEX (0, plus_infty));
3648 check_isinfp ("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 (0, minus_infty));
3651 check_isinfp ("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 (minus_zero, plus_infty));
3654 check_isinfn ("real(casinh(-0 + i Inf)) = -Inf", __real__ result);
3655 check ("imag(casinh(-0 + i Inf)) = pi/2", __imag__ result, M_PI_2);
3656 result = FUNC(casinh) (BUILD_COMPLEX (minus_zero, minus_infty));
3657 check_isinfn ("real(casinh(-0 - i Inf)) = -Inf", __real__ result);
3658 check ("imag(casinh(-0 - i Inf)) = -pi/2", __imag__ result, -M_PI_2);
3659 result = FUNC(casinh) (BUILD_COMPLEX (0.1, plus_infty));
3660 check_isinfp ("real(casinh(0.1 + i Inf)) = +Inf", __real__ result);
3661 check ("imag(casinh(0.1 + i Inf)) = pi/2", __imag__ result, M_PI_2);
3662 result = FUNC(casinh) (BUILD_COMPLEX (0.1, minus_infty));
3663 check_isinfp ("real(casinh(0.1 - i Inf)) = +Inf", __real__ result);
3664 check ("imag(casinh(0.1 - i Inf)) = -pi/2", __imag__ result, -M_PI_2);
3666 result = FUNC(casinh) (BUILD_COMPLEX (minus_infty, 0));
3667 check_isinfn ("real(casinh(-Inf + i0)) = -Inf", __real__ result);
3668 check ("imag(casinh(-Inf + i0)) = 0", __imag__ result, 0);
3669 result = FUNC(casinh) (BUILD_COMPLEX (minus_infty, minus_zero));
3670 check_isinfn ("real(casinh(-Inf - i0)) = -Inf", __real__ result);
3671 check ("imag(casinh(-Inf - i0)) = -0", __imag__ result, minus_zero);
3672 result = FUNC(casinh) (BUILD_COMPLEX (minus_infty, 100));
3673 check_isinfn ("real(casinh(-Inf + i100)) = -Inf", __real__ result);
3674 check ("imag(casinh(-Inf + i100)) = 0", __imag__ result, 0);
3675 result = FUNC(casinh) (BUILD_COMPLEX (minus_infty, -100));
3676 check_isinfn ("real(casinh(-Inf - i100)) = -Inf", __real__ result);
3677 check ("imag(casinh(-Inf - i100)) = -0", __imag__ result, minus_zero);
3679 result = FUNC(casinh) (BUILD_COMPLEX (plus_infty, 0));
3680 check_isinfp ("real(casinh(+Inf + i0)) = +Inf", __real__ result);
3681 check ("imag(casinh(+Inf + i0)) = 0", __imag__ result, 0);
3682 result = FUNC(casinh) (BUILD_COMPLEX (plus_infty, minus_zero));
3683 check_isinfp ("real(casinh(+Inf - i0)) = +Inf", __real__ result);
3684 check ("imag(casinh(+Inf - i0)) = -0", __imag__ result, minus_zero);
3685 result = FUNC(casinh) (BUILD_COMPLEX (plus_infty, 0.5));
3686 check_isinfp ("real(casinh(+Inf + i0.5)) = +Inf", __real__ result);
3687 check ("imag(casinh(+Inf + i0.5)) = 0", __imag__ result, 0);
3688 result = FUNC(casinh) (BUILD_COMPLEX (plus_infty, -0.5));
3689 check_isinfp ("real(casinh(+Inf - i0.5)) = +Inf", __real__ result);
3690 check ("imag(casinh(+Inf - i0.5)) = -0", __imag__ result, minus_zero);
3692 result = FUNC(casinh) (BUILD_COMPLEX (plus_infty, nan_value));
3693 check_isinfp ("real(casinh(+Inf + i NaN)) = +Inf", __real__ result);
3694 check_isnan ("imag(casinh(+Inf + i NaN)) = NaN", __imag__ result);
3695 result = FUNC(casinh) (BUILD_COMPLEX (minus_infty, nan_value));
3696 check_isinfn ("real(casinh(-Inf + i NaN)) = -Inf", __real__ result);
3697 check_isnan ("imag(casinh(-Inf + i NaN)) = NaN", __imag__ result);
3699 result = FUNC(casinh) (BUILD_COMPLEX (nan_value, 0));
3700 check_isnan ("real(casinh(NaN + i0)) = NaN", __real__ result);
3701 check ("imag(casinh(NaN + i0)) = 0", __imag__ result, 0);
3702 result = FUNC(casinh) (BUILD_COMPLEX (nan_value, minus_zero));
3703 check_isnan ("real(casinh(NaN - i0)) = NaN", __real__ result);
3704 check ("imag(casinh(NaN - i0)) = -0", __imag__ result, minus_zero);
3706 result = FUNC(casinh) (BUILD_COMPLEX (nan_value, plus_infty));
3707 check_isinfp ("real(casinh(NaN + i Inf)) = +-Inf",
3708 FUNC(fabs) (__real__ result));
3709 check_isnan ("imag(casinh(NaN + i Inf)) = NaN", __imag__ result);
3710 result = FUNC(casinh) (BUILD_COMPLEX (nan_value, minus_infty));
3711 check_isinfp ("real(casinh(NaN - i Inf)) = +-Inf",
3712 FUNC(fabs) (__real__ result));
3713 check_isnan ("imag(casinh(NaN - i Inf)) = NaN", __imag__ result);
3715 result = FUNC(casinh) (BUILD_COMPLEX (10.5, nan_value));
3716 check_isnan_maybe_exc ("real(casinh(10.5 + i NaN)) = NaN plus maybe invalid exception",
3717 __real__ result, INVALID_EXCEPTION);
3718 check_isnan ("imag(casinh(10.5 + i NaN)) = NaN plus maybe invalid exception",
3719 __imag__ result);
3720 result = FUNC(casinh) (BUILD_COMPLEX (-10.5, nan_value));
3721 check_isnan_maybe_exc ("real(casinh(-10.5 + i NaN)) = NaN plus maybe invalid exception",
3722 __real__ result, INVALID_EXCEPTION);
3723 check_isnan ("imag(casinh(-10.5 + i NaN)) = NaN plus maybe invalid exception",
3724 __imag__ result);
3726 result = FUNC(casinh) (BUILD_COMPLEX (nan_value, 0.75));
3727 check_isnan_maybe_exc ("real(casinh(NaN + i0.75)) = NaN plus maybe invalid exception",
3728 __real__ result, INVALID_EXCEPTION);
3729 check_isnan ("imag(casinh(NaN + i0.75)) = NaN plus maybe invalid exception",
3730 __imag__ result);
3731 result = FUNC(casinh) (BUILD_COMPLEX (-0.75, nan_value));
3732 check_isnan_maybe_exc ("real(casinh(NaN - i0.75)) = NaN plus maybe invalid exception",
3733 __real__ result, INVALID_EXCEPTION);
3734 check_isnan ("imag(casinh(NaN - i0.75)) = NaN plus maybe invalid exception",
3735 __imag__ result);
3737 result = FUNC(casinh) (BUILD_COMPLEX (nan_value, nan_value));
3738 check_isnan ("real(casinh(NaN + i NaN)) = NaN", __real__ result);
3739 check_isnan ("imag(casinh(NaN + i NaN)) = NaN", __imag__ result);
3743 static void
3744 catan_test (void)
3746 __complex__ MATHTYPE result;
3748 result = FUNC(catan) (BUILD_COMPLEX (0, 0));
3749 check ("real(catan(0 + i0)) = 0", __real__ result, 0);
3750 check ("imag(catan(0 + i0)) = 0", __imag__ result, 0);
3751 result = FUNC(catan) (BUILD_COMPLEX (minus_zero, 0));
3752 check ("real(catan(-0 + i0)) = -0", __real__ result, minus_zero);
3753 check ("imag(catan(-0 + i0)) = 0", __imag__ result, 0);
3754 result = FUNC(catan) (BUILD_COMPLEX (0, minus_zero));
3755 check ("real(catan(0 - i0)) = 0", __real__ result, 0);
3756 check ("imag(catan(0 - i0)) = -0", __imag__ result, minus_zero);
3757 result = FUNC(catan) (BUILD_COMPLEX (minus_zero, minus_zero));
3758 check ("real(catan(-0 - i0)) = -0", __real__ result, minus_zero);
3759 check ("imag(catan(-0 - i0)) = -0", __imag__ result, minus_zero);
3761 result = FUNC(catan) (BUILD_COMPLEX (plus_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);
3764 result = FUNC(catan) (BUILD_COMPLEX (plus_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);
3767 result = FUNC(catan) (BUILD_COMPLEX (minus_infty, plus_infty));
3768 check ("real(catan(-Inf + i Inf)) = -pi/2", __real__ result, -M_PI_2);
3769 check ("imag(catan(-Inf + i Inf)) = 0", __imag__ result, 0.0);
3770 result = FUNC(catan) (BUILD_COMPLEX (minus_infty, minus_infty));
3771 check ("real(catan(-Inf - i Inf)) = -pi/2", __real__ result, -M_PI_2);
3772 check ("imag(catan(-Inf - i Inf)) = -0", __imag__ result, minus_zero);
3774 result = FUNC(catan) (BUILD_COMPLEX (plus_infty, -10.0));
3775 check ("real(catan(+Inf - i10.0)) = pi/2", __real__ result, M_PI_2);
3776 check ("imag(catan(+Inf - i10.0)) = -0", __imag__ result, minus_zero);
3777 result = FUNC(catan) (BUILD_COMPLEX (minus_infty, -10.0));
3778 check ("real(catan(-Inf - i10.0)) = -pi/2", __real__ result, -M_PI_2);
3779 check ("imag(catan(-Inf - i10.0)) = -0", __imag__ result, minus_zero);
3780 result = FUNC(catan) (BUILD_COMPLEX (plus_infty, minus_zero));
3781 check ("real(catan(Inf - i0)) = pi/2", __real__ result, M_PI_2);
3782 check ("imag(catan(Inf - i0)) = -0", __imag__ result, minus_zero);
3783 result = FUNC(catan) (BUILD_COMPLEX (minus_infty, minus_zero));
3784 check ("real(catan(-Inf - i0)) = -pi/2", __real__ result, -M_PI_2);
3785 check ("imag(catan(-Inf - i0)) = -0", __imag__ result, minus_zero);
3786 result = FUNC(catan) (BUILD_COMPLEX (plus_infty, 0.0));
3787 check ("real(catan(Inf + i0)) = pi/2", __real__ result, M_PI_2);
3788 check ("imag(catan(Inf + i0)) = 0", __imag__ result, 0.0);
3789 result = FUNC(catan) (BUILD_COMPLEX (minus_infty, 0.0));
3790 check ("real(catan(-Inf + i0)) = -pi/2", __real__ result, -M_PI_2);
3791 check ("imag(catan(-Inf + i0)) = 0", __imag__ result, 0.0);
3792 result = FUNC(catan) (BUILD_COMPLEX (plus_infty, 0.1));
3793 check ("real(catan(+Inf + i0.1)) = pi/2", __real__ result, M_PI_2);
3794 check ("imag(catan(+Inf + i0.1)) = 0", __imag__ result, 0);
3795 result = FUNC(catan) (BUILD_COMPLEX (minus_infty, 0.1));
3796 check ("real(catan(-Inf + i0.1)) = -pi/2", __real__ result, -M_PI_2);
3797 check ("imag(catan(-Inf + i0.1)) = 0", __imag__ result, 0);
3799 result = FUNC(catan) (BUILD_COMPLEX (0.0, minus_infty));
3800 check ("real(catan(0 - i Inf)) = pi/2", __real__ result, M_PI_2);
3801 check ("imag(catan(0 - i Inf)) = -0", __imag__ result, minus_zero);
3802 result = FUNC(catan) (BUILD_COMPLEX (minus_zero, minus_infty));
3803 check ("real(catan(-0 - i Inf)) = -pi/2", __real__ result, -M_PI_2);
3804 check ("imag(catan(-0 - i Inf)) = -0", __imag__ result, minus_zero);
3805 result = FUNC(catan) (BUILD_COMPLEX (100.0, minus_infty));
3806 check ("real(catan(100 - i Inf)) = pi/2", __real__ result, M_PI_2);
3807 check ("imag(catan(100 - i Inf)) = -0", __imag__ result, minus_zero);
3808 result = FUNC(catan) (BUILD_COMPLEX (-100.0, minus_infty));
3809 check ("real(catan(-100 - i Inf)) = -pi/2", __real__ result, -M_PI_2);
3810 check ("imag(catan(-100 - i Inf)) = -0", __imag__ result, minus_zero);
3812 result = FUNC(catan) (BUILD_COMPLEX (0.0, plus_infty));
3813 check ("real(catan(0 + i Inf)) = pi/2", __real__ result, M_PI_2);
3814 check ("imag(catan(0 + i Inf)) = 0", __imag__ result, 0);
3815 result = FUNC(catan) (BUILD_COMPLEX (minus_zero, plus_infty));
3816 check ("real(catan(-0 + i Inf)) = -pi/2", __real__ result, -M_PI_2);
3817 check ("imag(catan(-0 + i Inf)) = 0", __imag__ result, 0);
3818 result = FUNC(catan) (BUILD_COMPLEX (0.5, plus_infty));
3819 check ("real(catan(0.5 + i Inf)) = pi/2", __real__ result, M_PI_2);
3820 check ("imag(catan(0.5 + i Inf)) = 0", __imag__ result, 0);
3821 result = FUNC(catan) (BUILD_COMPLEX (-0.5, plus_infty));
3822 check ("real(catan(-0.5 + i Inf)) = -pi/2", __real__ result, -M_PI_2);
3823 check ("imag(catan(-0.5 + i Inf)) = 0", __imag__ result, 0);
3825 result = FUNC(catan) (BUILD_COMPLEX (nan_value, 0.0));
3826 check_isnan ("real(catan(NaN + i0)) = NaN", __real__ result);
3827 check ("imag(catan(NaN + i0)) = 0", __imag__ result, 0.0);
3828 result = FUNC(catan) (BUILD_COMPLEX (nan_value, minus_zero));
3829 check_isnan ("real(catan(NaN - i0)) = NaN", __real__ result);
3830 check ("imag(catan(NaN - i0)) = -0", __imag__ result, minus_zero);
3832 result = FUNC(catan) (BUILD_COMPLEX (nan_value, plus_infty));
3833 check_isnan ("real(catan(NaN + i Inf)) = NaN", __real__ result);
3834 check ("imag(catan(NaN + i Inf)) = 0", __imag__ result, 0);
3835 result = FUNC(catan) (BUILD_COMPLEX (nan_value, minus_infty));
3836 check_isnan ("real(catan(NaN - i Inf)) = NaN", __real__ result);
3837 check ("imag(catan(NaN - i Inf)) = -0", __imag__ result, minus_zero);
3839 result = FUNC(catan) (BUILD_COMPLEX (0.0, nan_value));
3840 check_isnan ("real(catan(0 + i NaN)) = NaN", __real__ result);
3841 check_isnan ("imag(catan(0 + i NaN)) = NaN", __imag__ result);
3842 result = FUNC(catan) (BUILD_COMPLEX (minus_zero, nan_value));
3843 check_isnan ("real(catan(-0 + i NaN)) = NaN", __real__ result);
3844 check_isnan ("imag(catan(-0 + i NaN)) = NaN", __imag__ result);
3846 result = FUNC(catan) (BUILD_COMPLEX (plus_infty, nan_value));
3847 check ("real(catan(+Inf + i NaN)) = pi/2", __real__ result, M_PI_2);
3848 check ("imag(catan(+Inf + i NaN)) = +-0", FUNC(fabs) (__imag__ result), 0);
3849 result = FUNC(catan) (BUILD_COMPLEX (minus_infty, nan_value));
3850 check ("real(catan(-Inf + i NaN)) = -pi/2", __real__ result, -M_PI_2);
3851 check ("imag(catan(-Inf + i NaN)) = +-0", FUNC(fabs) (__imag__ result), 0);
3853 result = FUNC(catan) (BUILD_COMPLEX (nan_value, 10.5));
3854 check_isnan_maybe_exc ("real(catan(NaN + i10.5)) = NaN plus maybe invalid exception",
3855 __real__ result, INVALID_EXCEPTION);
3856 check_isnan ("imag(catan(NaN + i10.5)) = NaN plus maybe invalid exception",
3857 __imag__ result);
3858 result = FUNC(catan) (BUILD_COMPLEX (nan_value, -10.5));
3859 check_isnan_maybe_exc ("real(catan(NaN - i10.5)) = NaN plus maybe invalid exception",
3860 __real__ result, INVALID_EXCEPTION);
3861 check_isnan ("imag(catan(NaN - i10.5)) = NaN plus maybe invalid exception",
3862 __imag__ result);
3864 result = FUNC(catan) (BUILD_COMPLEX (0.75, nan_value));
3865 check_isnan_maybe_exc ("real(catan(0.75 + i NaN)) = NaN plus maybe invalid exception",
3866 __real__ result, INVALID_EXCEPTION);
3867 check_isnan ("imag(catan(0.75 + i NaN)) = NaN plus maybe invalid exception",
3868 __imag__ result);
3869 result = FUNC(catan) (BUILD_COMPLEX (-0.75, nan_value));
3870 check_isnan_maybe_exc ("real(catan(-0.75 + i NaN)) = NaN plus maybe invalid exception",
3871 __real__ result, INVALID_EXCEPTION);
3872 check_isnan ("imag(catan(-0.75 + i NaN)) = NaN plus maybe invalid exception",
3873 __imag__ result);
3875 result = FUNC(catan) (BUILD_COMPLEX (nan_value, nan_value));
3876 check_isnan ("real(catan(NaN + i NaN)) = NaN", __real__ result);
3877 check_isnan ("imag(catan(NaN + i NaN)) = NaN", __imag__ result);
3881 static void
3882 catanh_test (void)
3884 __complex__ MATHTYPE result;
3886 result = FUNC(catanh) (BUILD_COMPLEX (0, 0));
3887 check ("real(catanh(0 + i0)) = 0", __real__ result, 0);
3888 check ("imag(catanh(0 + i0)) = 0", __imag__ result, 0);
3889 result = FUNC(catanh) (BUILD_COMPLEX (minus_zero, 0));
3890 check ("real(catanh(-0 + i0)) = -0", __real__ result, minus_zero);
3891 check ("imag(catanh(-0 + i0)) = 0", __imag__ result, 0);
3892 result = FUNC(catanh) (BUILD_COMPLEX (0, minus_zero));
3893 check ("real(catanh(0 - i0)) = 0", __real__ result, 0);
3894 check ("imag(catanh(0 - i0)) = -0", __imag__ result, minus_zero);
3895 result = FUNC(catanh) (BUILD_COMPLEX (minus_zero, minus_zero));
3896 check ("real(catanh(-0 - i0)) = -0", __real__ result, minus_zero);
3897 check ("imag(catanh(-0 - i0)) = -0", __imag__ result, minus_zero);
3899 result = FUNC(catanh) (BUILD_COMPLEX (plus_infty, plus_infty));
3900 check ("real(catanh(+Inf + i Inf)) = 0", __real__ result, 0);
3901 check ("imag(catanh(+Inf + i Inf)) = pi/2", __imag__ result, M_PI_2);
3902 result = FUNC(catanh) (BUILD_COMPLEX (plus_infty, minus_infty));
3903 check ("real(catanh(+Inf - i Inf)) = 0", __real__ result, 0);
3904 check ("imag(catanh(+Inf - i Inf)) = -pi/2", __imag__ result, -M_PI_2);
3905 result = FUNC(catanh) (BUILD_COMPLEX (minus_infty, plus_infty));
3906 check ("real(catanh(-Inf + i Inf)) = -0", __real__ result, minus_zero);
3907 check ("imag(catanh(-Inf + i Inf)) = pi/2", __imag__ result, M_PI_2);
3908 result = FUNC(catanh) (BUILD_COMPLEX (minus_infty, minus_infty));
3909 check ("real(catanh(-Inf - i Inf)) = -0", __real__ result, minus_zero);
3910 check ("imag(catanh(-Inf - i Inf)) = -pi/2", __imag__ result, -M_PI_2);
3912 result = FUNC(catanh) (BUILD_COMPLEX (-10.0, plus_infty));
3913 check ("real(catanh(-10.0 + i Inf)) = -0", __real__ result, minus_zero);
3914 check ("imag(catanh(-10.0 + i Inf)) = pi/2", __imag__ result, M_PI_2);
3915 result = FUNC(catanh) (BUILD_COMPLEX (-10.0, minus_infty));
3916 check ("real(catanh(-10.0 - i Inf)) = -0", __real__ result, minus_zero);
3917 check ("imag(catanh(-10.0 - i Inf)) = -pi/2", __imag__ result, -M_PI_2);
3918 result = FUNC(catanh) (BUILD_COMPLEX (minus_zero, plus_infty));
3919 check ("real(catanh(-0 + i Inf)) = -0", __real__ result, minus_zero);
3920 check ("imag(catanh(-0 + i Inf)) = pi/2", __imag__ result, M_PI_2);
3921 result = FUNC(catanh) (BUILD_COMPLEX (minus_zero, minus_infty));
3922 check ("real(catanh(-0 - i Inf)) = -0", __real__ result, minus_zero);
3923 check ("imag(catanh(-0 - i Inf)) = -pi/2", __imag__ result, -M_PI_2);
3924 result = FUNC(catanh) (BUILD_COMPLEX (0, plus_infty));
3925 check ("real(catanh(0 + i Inf)) = 0", __real__ result, 0);
3926 check ("imag(catanh(0 + i Inf)) = pi/2", __imag__ result, M_PI_2);
3927 result = FUNC(catanh) (BUILD_COMPLEX (0, minus_infty));
3928 check ("real(catanh(0 - i Inf)) = 0", __real__ result, 0);
3929 check ("imag(catanh(0 - i Inf)) = -pi/2", __imag__ result, -M_PI_2);
3930 result = FUNC(catanh) (BUILD_COMPLEX (0.1, plus_infty));
3931 check ("real(catanh(0.1 + i Inf)) = 0", __real__ result, 0);
3932 check ("imag(catanh(0.1 + i Inf)) = pi/2", __imag__ result, M_PI_2);
3933 result = FUNC(catanh) (BUILD_COMPLEX (0.1, minus_infty));
3934 check ("real(catanh(0.1 - i Inf)) = 0", __real__ result, 0);
3935 check ("imag(catanh(0.1 - i Inf)) = -pi/2", __imag__ result, -M_PI_2);
3937 result = FUNC(catanh) (BUILD_COMPLEX (minus_infty, 0));
3938 check ("real(catanh(-Inf + i0)) = -0", __real__ result, minus_zero);
3939 check ("imag(catanh(-Inf + i0)) = pi/2", __imag__ result, M_PI_2);
3940 result = FUNC(catanh) (BUILD_COMPLEX (minus_infty, minus_zero));
3941 check ("real(catanh(-Inf - i0)) = -0", __real__ result, minus_zero);
3942 check ("imag(catanh(-Inf - i0)) = -pi/2", __imag__ result, -M_PI_2);
3943 result = FUNC(catanh) (BUILD_COMPLEX (minus_infty, 100));
3944 check ("real(catanh(-Inf + i100)) = -0", __real__ result, minus_zero);
3945 check ("imag(catanh(-Inf + i100)) = pi/2", __imag__ result, M_PI_2);
3946 result = FUNC(catanh) (BUILD_COMPLEX (minus_infty, -100));
3947 check ("real(catanh(-Inf - i100)) = -0", __real__ result, minus_zero);
3948 check ("imag(catanh(-Inf - i100)) = -pi/2", __imag__ result, -M_PI_2);
3950 result = FUNC(catanh) (BUILD_COMPLEX (plus_infty, 0));
3951 check ("real(catanh(+Inf + i0)) = 0", __real__ result, 0);
3952 check ("imag(catanh(+Inf + i0)) = pi/2", __imag__ result, M_PI_2);
3953 result = FUNC(catanh) (BUILD_COMPLEX (plus_infty, minus_zero));
3954 check ("real(catanh(+Inf - i0)) = 0", __real__ result, 0);
3955 check ("imag(catanh(+Inf - i0)) = -pi/2", __imag__ result, -M_PI_2);
3956 result = FUNC(catanh) (BUILD_COMPLEX (plus_infty, 0.5));
3957 check ("real(catanh(+Inf + i0.5)) = 0", __real__ result, 0);
3958 check ("imag(catanh(+Inf + i0.5)) = pi/2", __imag__ result, M_PI_2);
3959 result = FUNC(catanh) (BUILD_COMPLEX (plus_infty, -0.5));
3960 check ("real(catanh(+Inf - i0.5)) = 0", __real__ result, 0);
3961 check ("imag(catanh(+Inf - i0.5)) = -pi/2", __imag__ result, -M_PI_2);
3963 result = FUNC(catanh) (BUILD_COMPLEX (0, nan_value));
3964 check ("real(catanh(0 + i NaN)) = 0", __real__ result, 0);
3965 check_isnan ("imag(catanh(0 + i NaN)) = NaN", __imag__ result);
3966 result = FUNC(catanh) (BUILD_COMPLEX (minus_zero, nan_value));
3967 check ("real(catanh(-0 + i NaN)) = -0", __real__ result, minus_zero);
3968 check_isnan ("imag(catanh(-0 + i NaN)) = NaN", __imag__ result);
3970 result = FUNC(catanh) (BUILD_COMPLEX (plus_infty, nan_value));
3971 check ("real(catanh(+Inf + i NaN)) = 0", __real__ result, 0);
3972 check_isnan ("imag(catanh(+Inf + i NaN)) = NaN", __imag__ result);
3973 result = FUNC(catanh) (BUILD_COMPLEX (minus_infty, nan_value));
3974 check ("real(catanh(-Inf + i NaN)) = -0", __real__ result, minus_zero);
3975 check_isnan ("imag(catanh(-Inf + i NaN)) = NaN", __imag__ result);
3977 result = FUNC(catanh) (BUILD_COMPLEX (nan_value, 0));
3978 check_isnan ("real(catanh(NaN + i0)) = NaN", __real__ result);
3979 check_isnan ("imag(catanh(NaN + i0)) = NaN", __imag__ result);
3980 result = FUNC(catanh) (BUILD_COMPLEX (nan_value, minus_zero));
3981 check_isnan ("real(catanh(NaN - i0)) = NaN", __real__ result);
3982 check_isnan ("imag(catanh(NaN - i0)) = NaN", __imag__ result);
3984 result = FUNC(catanh) (BUILD_COMPLEX (nan_value, plus_infty));
3985 check ("real(catanh(NaN + i Inf)) = +-0", FUNC(fabs) (__real__ result), 0);
3986 check ("imag(catanh(NaN + i Inf)) = pi/2", __imag__ result, M_PI_2);
3987 result = FUNC(catanh) (BUILD_COMPLEX (nan_value, minus_infty));
3988 check ("real(catanh(NaN - i Inf)) = +-0", FUNC(fabs) (__real__ result), 0);
3989 check ("imag(catanh(NaN - i Inf)) = -pi/2", __imag__ result, -M_PI_2);
3991 result = FUNC(catanh) (BUILD_COMPLEX (10.5, nan_value));
3992 check_isnan_maybe_exc ("real(catanh(10.5 + i NaN)) = NaN plus maybe invalid exception",
3993 __real__ result, INVALID_EXCEPTION);
3994 check_isnan ("imag(catanh(10.5 + i NaN)) = NaN plus maybe invalid exception",
3995 __imag__ result);
3996 result = FUNC(catanh) (BUILD_COMPLEX (-10.5, nan_value));
3997 check_isnan_maybe_exc ("real(catanh(-10.5 + i NaN)) = NaN plus maybe invalid exception",
3998 __real__ result, INVALID_EXCEPTION);
3999 check_isnan ("imag(catanh(-10.5 + i NaN)) = NaN plus maybe invalid exception",
4000 __imag__ result);
4002 result = FUNC(catanh) (BUILD_COMPLEX (nan_value, 0.75));
4003 check_isnan_maybe_exc ("real(catanh(NaN + i0.75)) = NaN plus maybe invalid exception",
4004 __real__ result, INVALID_EXCEPTION);
4005 check_isnan ("imag(catanh(NaN + i0.75)) = NaN plus maybe invalid exception",
4006 __imag__ result);
4007 result = FUNC(catanh) (BUILD_COMPLEX (nan_value, -0.75));
4008 check_isnan_maybe_exc ("real(catanh(NaN - i0.75)) = NaN plus maybe invalid exception",
4009 __real__ result, INVALID_EXCEPTION);
4010 check_isnan ("imag(catanh(NaN - i0.75)) = NaN plus maybe invalid exception",
4011 __imag__ result);
4013 result = FUNC(catanh) (BUILD_COMPLEX (nan_value, nan_value));
4014 check_isnan ("real(catanh(NaN + i NaN)) = NaN", __real__ result);
4015 check_isnan ("imag(catanh(NaN + i NaN)) = NaN", __imag__ result);
4019 static void
4020 ctanh_test (void)
4022 __complex__ MATHTYPE result;
4024 result = FUNC(ctanh) (BUILD_COMPLEX (0, 0));
4025 check ("real(ctanh(0 + i0)) = 0", __real__ result, 0);
4026 check ("imag(ctanh(0 + i0)) = 0", __imag__ result, 0);
4027 result = FUNC(ctanh) (BUILD_COMPLEX (0, minus_zero));
4028 check ("real(ctanh(0 - i0)) = 0", __real__ result, 0);
4029 check ("imag(ctanh(0 - i0)) = -0", __imag__ result, minus_zero);
4030 result = FUNC(ctanh) (BUILD_COMPLEX (minus_zero, 0));
4031 check ("real(ctanh(-0 + i0)) = -0", __real__ result, minus_zero);
4032 check ("imag(ctanh(-0 + i0)) = 0", __imag__ result, 0);
4033 result = FUNC(ctanh) (BUILD_COMPLEX (minus_zero, minus_zero));
4034 check ("real(ctanh(-0 - i0)) = -0", __real__ result, minus_zero);
4035 check ("imag(ctanh(-0 - i0)) = -0", __imag__ result, minus_zero);
4037 result = FUNC(ctanh) (BUILD_COMPLEX (plus_infty, 0));
4038 check ("real(ctanh(+Inf + i0)) = 1", __real__ result, 1);
4039 check ("imag(ctanh(+Inf + i0)) = 0", __imag__ result, 0);
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, 0);
4043 result = FUNC(ctanh) (BUILD_COMPLEX (plus_infty, minus_zero));
4044 check ("real(ctanh(+Inf - i0)) = 1", __real__ result, 1);
4045 check ("imag(ctanh(+Inf - i0)) = -0", __imag__ result, minus_zero);
4046 result = FUNC(ctanh) (BUILD_COMPLEX (plus_infty, -1));
4047 check ("real(ctanh(+Inf - i1)) = 1", __real__ result, 1);
4048 check ("imag(ctanh(+Inf - i1)) = -0", __imag__ result, minus_zero);
4049 result = FUNC(ctanh) (BUILD_COMPLEX (minus_infty, 0));
4050 check ("real(ctanh(-Inf + i0)) = -1", __real__ result, -1);
4051 check ("imag(ctanh(-Inf + i0)) = 0", __imag__ result, 0);
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, 0);
4055 result = FUNC(ctanh) (BUILD_COMPLEX (minus_infty, minus_zero));
4056 check ("real(ctanh(-Inf - i0)) = -1", __real__ result, -1);
4057 check ("imag(ctanh(-Inf - i0)) = -0", __imag__ result, minus_zero);
4058 result = FUNC(ctanh) (BUILD_COMPLEX (minus_infty, -1));
4059 check ("real(ctanh(-Inf - i1)) = -1", __real__ result, -1);
4060 check ("imag(ctanh(-Inf - i1)) = -0", __imag__ result, minus_zero);
4062 result = FUNC(ctanh) (BUILD_COMPLEX (0, plus_infty));
4063 check_isnan_exc ("real(ctanh(0 + i Inf)) = NaN plus invalid exception",
4064 __real__ result, INVALID_EXCEPTION);
4065 check_isnan ("imag(ctanh(0 + i Inf)) = NaN plus invalid exception",
4066 __imag__ result);
4067 result = FUNC(ctanh) (BUILD_COMPLEX (2, plus_infty));
4068 check_isnan_exc ("real(ctanh(2 + i Inf)) = NaN plus invalid exception",
4069 __real__ result, INVALID_EXCEPTION);
4070 check_isnan ("imag(ctanh(2 + i Inf)) = NaN plus invalid exception",
4071 __imag__ result);
4072 result = FUNC(ctanh) (BUILD_COMPLEX (0, minus_infty));
4073 check_isnan_exc ("real(ctanh(0 - i Inf)) = NaN plus invalid exception",
4074 __real__ result, INVALID_EXCEPTION);
4075 check_isnan ("imag(ctanh(0 - i Inf)) = NaN plus invalid exception",
4076 __imag__ result);
4077 result = FUNC(ctanh) (BUILD_COMPLEX (2, minus_infty));
4078 check_isnan_exc ("real(ctanh(2 - i Inf)) = NaN plus invalid exception",
4079 __real__ result, INVALID_EXCEPTION);
4080 check_isnan ("imag(ctanh(2 - i Inf)) = NaN plus invalid exception",
4081 __imag__ result);
4082 result = FUNC(ctanh) (BUILD_COMPLEX (minus_zero, plus_infty));
4083 check_isnan_exc ("real(ctanh(-0 + i Inf)) = NaN plus invalid exception",
4084 __real__ result, INVALID_EXCEPTION);
4085 check_isnan ("imag(ctanh(-0 + i Inf)) = NaN plus invalid exception",
4086 __imag__ result);
4087 result = FUNC(ctanh) (BUILD_COMPLEX (-2, plus_infty));
4088 check_isnan_exc ("real(ctanh(-2 + i Inf)) = NaN plus invalid exception",
4089 __real__ result, INVALID_EXCEPTION);
4090 check_isnan ("imag(ctanh(-2 + i Inf)) = NaN plus invalid exception",
4091 __imag__ result);
4092 result = FUNC(ctanh) (BUILD_COMPLEX (minus_zero, minus_infty));
4093 check_isnan_exc ("real(ctanh(-0 - i Inf)) = NaN plus invalid exception",
4094 __real__ result, INVALID_EXCEPTION);
4095 check_isnan ("imag(ctanh(-0 - i Inf)) = NaN plus invalid exception",
4096 __imag__ result);
4097 result = FUNC(ctanh) (BUILD_COMPLEX (-2, minus_infty));
4098 check_isnan_exc ("real(ctanh(-2 - i Inf)) = NaN plus invalid exception",
4099 __real__ result, INVALID_EXCEPTION);
4100 check_isnan ("imag(ctanh(-2 - i Inf)) = NaN plus invalid exception",
4101 __imag__ result);
4103 result = FUNC(ctanh) (BUILD_COMPLEX (plus_infty, nan_value));
4104 check ("real(ctanh(+Inf + i NaN)) = 1", __real__ result, 1);
4105 check ("imag(ctanh(+Inf + i NaN)) = +-0", FUNC(fabs) (__imag__ result), 0);
4106 result = FUNC(ctanh) (BUILD_COMPLEX (minus_infty, nan_value));
4107 check ("real(ctanh(-Inf + i NaN)) = -1", __real__ result, -1);
4108 check ("imag(ctanh(-Inf + i NaN)) = +-0", FUNC(fabs) (__imag__ result), 0);
4110 result = FUNC(ctanh) (BUILD_COMPLEX (nan_value, 0));
4111 check_isnan ("real(ctanh(NaN + i0)) = NaN", __real__ result);
4112 check ("imag(ctanh(NaN + i0)) = 0", __imag__ result, 0);
4113 result = FUNC(ctanh) (BUILD_COMPLEX (nan_value, minus_zero));
4114 check_isnan ("real(ctanh(NaN - i0)) = NaN", __real__ result);
4115 check ("imag(ctanh(NaN - i0)) = -0", __imag__ result, minus_zero);
4117 result = FUNC(ctanh) (BUILD_COMPLEX (nan_value, 0.5));
4118 check_isnan_maybe_exc ("real(ctanh(NaN + i0.5)) = NaN plus maybe invalid exception",
4119 __real__ result, INVALID_EXCEPTION);
4120 check_isnan ("imag(ctanh(NaN + i0.5)) = NaN plus maybe invalid exception",
4121 __imag__ result);
4122 result = FUNC(ctanh) (BUILD_COMPLEX (nan_value, -4.5));
4123 check_isnan_maybe_exc ("real(ctanh(NaN - i4.5)) = NaN plus maybe invalid exception",
4124 __real__ result, INVALID_EXCEPTION);
4125 check_isnan ("imag(ctanh(NaN - i4.5)) = NaN plus maybe invalid exception",
4126 __imag__ result);
4128 result = FUNC(ctanh) (BUILD_COMPLEX (0, nan_value));
4129 check_isnan_maybe_exc ("real(ctanh(0 + i NaN)) = NaN plus maybe invalid exception",
4130 __real__ result, INVALID_EXCEPTION);
4131 check_isnan ("imag(ctanh(0 + i NaN)) = NaN plus maybe invalid exception",
4132 __imag__ result);
4133 result = FUNC(ctanh) (BUILD_COMPLEX (5, nan_value));
4134 check_isnan_maybe_exc ("real(ctanh(5 + i NaN)) = NaN plus maybe invalid exception",
4135 __real__ result, INVALID_EXCEPTION);
4136 check_isnan ("imag(ctanh(5 + i NaN)) = NaN plus maybe invalid exception",
4137 __imag__ result);
4138 result = FUNC(ctanh) (BUILD_COMPLEX (minus_zero, nan_value));
4139 check_isnan_maybe_exc ("real(ctanh(-0 + i NaN)) = NaN plus maybe invalid exception",
4140 __real__ result, INVALID_EXCEPTION);
4141 check_isnan ("imag(ctanh(-0 + i NaN)) = NaN plus maybe invalid exception",
4142 __imag__ result);
4143 result = FUNC(ctanh) (BUILD_COMPLEX (-0.25, nan_value));
4144 check_isnan_maybe_exc ("real(ctanh(-0.25 + i NaN)) = NaN plus maybe invalid exception",
4145 __real__ result, INVALID_EXCEPTION);
4146 check_isnan ("imag(ctanh(-0.25 + i NaN)) = NaN plus maybe invalid exception",
4147 __imag__ result);
4149 result = FUNC(ctanh) (BUILD_COMPLEX (nan_value, nan_value));
4150 check_isnan ("real(ctanh(NaN + i NaN)) = NaN", __real__ result);
4151 check_isnan ("imag(ctanh(NaN + i NaN)) = NaN", __imag__ result);
4155 static void
4156 clog_test (void)
4158 __complex__ MATHTYPE result;
4160 result = FUNC(clog) (BUILD_COMPLEX (minus_zero, 0));
4161 check_isinfn_exc ("real(clog(-0 + i0)) = -Inf plus divide-by-zero exception",
4162 __real__ result, DIVIDE_BY_ZERO_EXCEPTION);
4163 check ("imag(clog(-0 + i0)) = pi plus divide-by-zero exception",
4164 __imag__ result, M_PI);
4165 result = FUNC(clog) (BUILD_COMPLEX (minus_zero, minus_zero));
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)) = -pi plus divide-by-zero exception",
4169 __imag__ result, -M_PI);
4171 result = FUNC(clog) (BUILD_COMPLEX (0, 0));
4172 check_isinfn_exc ("real(clog(0 + i0)) = -Inf plus divide-by-zero exception",
4173 __real__ result, DIVIDE_BY_ZERO_EXCEPTION);
4174 check ("imag(clog(0 + i0)) = 0 plus divide-by-zero exception",
4175 __imag__ result, 0);
4176 result = FUNC(clog) (BUILD_COMPLEX (0, minus_zero));
4177 check_isinfn_exc ("real(clog(0 - i0)) = -Inf plus divide-by-zero exception",
4178 __real__ result, DIVIDE_BY_ZERO_EXCEPTION);
4179 check ("imag(clog(0 - i0)) = -0 plus divide-by-zero exception",
4180 __imag__ result, minus_zero);
4182 result = FUNC(clog) (BUILD_COMPLEX (minus_infty, plus_infty));
4183 check_isinfp ("real(clog(-Inf + i Inf)) = +Inf", __real__ result);
4184 check ("imag(clog(-Inf + i Inf)) = 3*pi/4", __imag__ result, M_PI - M_PI_4);
4185 result = FUNC(clog) (BUILD_COMPLEX (minus_infty, minus_infty));
4186 check_isinfp ("real(clog(-Inf - i Inf)) = +Inf", __real__ result);
4187 check ("imag(clog(-Inf - i Inf)) = -3*pi/4", __imag__ result, M_PI_4 - M_PI);
4189 result = FUNC(clog) (BUILD_COMPLEX (plus_infty, plus_infty));
4190 check_isinfp ("real(clog(+Inf + i Inf)) = +Inf", __real__ result);
4191 check ("imag(clog(+Inf + i Inf)) = pi/4", __imag__ result, M_PI_4);
4192 result = FUNC(clog) (BUILD_COMPLEX (plus_infty, minus_infty));
4193 check_isinfp ("real(clog(+Inf - i Inf)) = +Inf", __real__ result);
4194 check ("imag(clog(+Inf - i Inf)) = -pi/4", __imag__ result, -M_PI_4);
4196 result = FUNC(clog) (BUILD_COMPLEX (0, 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 (minus_zero, plus_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, plus_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 (0, 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);
4214 result = FUNC(clog) (BUILD_COMPLEX (minus_zero, minus_infty));
4215 check_isinfp ("real(clog(-0 - i Inf)) = +Inf", __real__ result);
4216 check ("imag(clog(-0 - i Inf)) = -pi/2", __imag__ result, -M_PI_2);
4217 result = FUNC(clog) (BUILD_COMPLEX (-3, minus_infty));
4218 check_isinfp ("real(clog(-3 - i Inf)) = +Inf", __real__ result);
4219 check ("imag(clog(-3 - i Inf)) = -pi/2", __imag__ result, -M_PI_2);
4221 result = FUNC(clog) (BUILD_COMPLEX (minus_infty, 0));
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);
4227 result = FUNC(clog) (BUILD_COMPLEX (minus_infty, minus_zero));
4228 check_isinfp ("real(clog(-Inf - i0)) = +Inf", __real__ result);
4229 check ("imag(clog(-Inf - i0)) = -pi", __imag__ result, -M_PI);
4230 result = FUNC(clog) (BUILD_COMPLEX (minus_infty, -1));
4231 check_isinfp ("real(clog(-Inf - i1)) = +Inf", __real__ result);
4232 check ("imag(clog(-Inf - i1)) = -pi", __imag__ result, -M_PI);
4234 result = FUNC(clog) (BUILD_COMPLEX (plus_infty, 0));
4235 check_isinfp ("real(clog(+Inf + i0)) = +Inf", __real__ result);
4236 check ("imag(clog(+Inf + i0)) = 0", __imag__ result, 0);
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, 0);
4240 result = FUNC(clog) (BUILD_COMPLEX (plus_infty, minus_zero));
4241 check_isinfp ("real(clog(+Inf - i0)) = +Inf", __real__ result);
4242 check ("imag(clog(+Inf - i0)) = -0", __imag__ result, minus_zero);
4243 result = FUNC(clog) (BUILD_COMPLEX (plus_infty, -1));
4244 check_isinfp ("real(clog(+Inf - i1)) = +Inf", __real__ result);
4245 check ("imag(clog(+Inf - i1)) = -0", __imag__ result, minus_zero);
4247 result = FUNC(clog) (BUILD_COMPLEX (plus_infty, nan_value));
4248 check_isinfp ("real(clog(+Inf + i NaN)) = +Inf", __real__ result);
4249 check_isnan ("imag(clog(+Inf + i NaN)) = NaN", __imag__ result);
4250 result = FUNC(clog) (BUILD_COMPLEX (minus_infty, nan_value));
4251 check_isinfp ("real(clog(-Inf + i NaN)) = +Inf", __real__ result);
4252 check_isnan ("imag(clog(-Inf + i NaN)) = NaN", __imag__ result);
4254 result = FUNC(clog) (BUILD_COMPLEX (nan_value, plus_infty));
4255 check_isinfp ("real(clog(NaN + i Inf)) = +Inf", __real__ result);
4256 check_isnan ("imag(clog(NaN + i Inf)) = NaN", __imag__ result);
4257 result = FUNC(clog) (BUILD_COMPLEX (nan_value, minus_infty));
4258 check_isinfp ("real(clog(NaN - i Inf)) = +Inf", __real__ result);
4259 check_isnan ("imag(clog(NaN - i Inf)) = NaN", __imag__ result);
4261 result = FUNC(clog) (BUILD_COMPLEX (0, nan_value));
4262 check_isnan_maybe_exc ("real(clog(0 + i NaN)) = NaN plus maybe invalid exception",
4263 __real__ result, INVALID_EXCEPTION);
4264 check_isnan ("imag(clog(0 + i NaN)) = NaN plus maybe invalid exception",
4265 __imag__ result);
4266 result = FUNC(clog) (BUILD_COMPLEX (3, nan_value));
4267 check_isnan_maybe_exc ("real(clog(3 + i NaN)) = NaN plus maybe invalid exception",
4268 __real__ result, INVALID_EXCEPTION);
4269 check_isnan ("imag(clog(3 + i NaN)) = NaN plus maybe invalid exception",
4270 __imag__ result);
4271 result = FUNC(clog) (BUILD_COMPLEX (minus_zero, nan_value));
4272 check_isnan_maybe_exc ("real(clog(-0 + i NaN)) = NaN plus maybe invalid exception",
4273 __real__ result, INVALID_EXCEPTION);
4274 check_isnan ("imag(clog(-0 + i NaN)) = NaN plus maybe invalid exception",
4275 __imag__ result);
4276 result = FUNC(clog) (BUILD_COMPLEX (-3, nan_value));
4277 check_isnan_maybe_exc ("real(clog(-3 + i NaN)) = NaN plus maybe invalid exception",
4278 __real__ result, INVALID_EXCEPTION);
4279 check_isnan ("imag(clog(-3 + i NaN)) = NaN plus maybe invalid exception",
4280 __imag__ result);
4282 result = FUNC(clog) (BUILD_COMPLEX (nan_value, 0));
4283 check_isnan_maybe_exc ("real(clog(NaN + i0)) = NaN plus maybe invalid exception",
4284 __real__ result, INVALID_EXCEPTION);
4285 check_isnan ("imag(clog(NaN + i0)) = NaN plus maybe invalid exception",
4286 __imag__ result);
4287 result = FUNC(clog) (BUILD_COMPLEX (nan_value, 5));
4288 check_isnan_maybe_exc ("real(clog(NaN + i5)) = NaN plus maybe invalid exception",
4289 __real__ result, INVALID_EXCEPTION);
4290 check_isnan ("imag(clog(NaN + i5)) = NaN plus maybe invalid exception",
4291 __imag__ result);
4292 result = FUNC(clog) (BUILD_COMPLEX (nan_value, minus_zero));
4293 check_isnan_maybe_exc ("real(clog(NaN - i0)) = NaN plus maybe invalid exception",
4294 __real__ result, INVALID_EXCEPTION);
4295 check_isnan ("imag(clog(NaN - i0)) = NaN plus maybe invalid exception",
4296 __imag__ result);
4297 result = FUNC(clog) (BUILD_COMPLEX (nan_value, -5));
4298 check_isnan_maybe_exc ("real(clog(NaN - i5)) = NaN plus maybe invalid exception",
4299 __real__ result, INVALID_EXCEPTION);
4300 check_isnan ("imag(clog(NaN - i5)) = NaN plus maybe invalid exception",
4301 __imag__ result);
4303 result = FUNC(clog) (BUILD_COMPLEX (nan_value, nan_value));
4304 check_isnan ("real(clog(NaN + i NaN)) = NaN", __real__ result);
4305 check_isnan ("imag(clog(NaN + i NaN)) = NaN", __imag__ result);
4309 static void
4310 clog10_test (void)
4312 __complex__ MATHTYPE result;
4314 result = FUNC(clog10) (BUILD_COMPLEX (minus_zero, 0));
4315 check_isinfn_exc ("real(clog10(-0 + i0)) = -Inf plus divide-by-zero exception",
4316 __real__ result, DIVIDE_BY_ZERO_EXCEPTION);
4317 check ("imag(clog10(-0 + i0)) = pi plus divide-by-zero exception",
4318 __imag__ result, M_PI);
4319 result = FUNC(clog10) (BUILD_COMPLEX (minus_zero, minus_zero));
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)) = -pi plus divide-by-zero exception",
4323 __imag__ result, -M_PI);
4325 result = FUNC(clog10) (BUILD_COMPLEX (0, 0));
4326 check_isinfn_exc ("real(clog10(0 + i0)) = -Inf plus divide-by-zero exception",
4327 __real__ result, DIVIDE_BY_ZERO_EXCEPTION);
4328 check ("imag(clog10(0 + i0)) = 0 plus divide-by-zero exception",
4329 __imag__ result, 0);
4330 result = FUNC(clog10) (BUILD_COMPLEX (0, minus_zero));
4331 check_isinfn_exc ("real(clog10(0 - i0)) = -Inf plus divide-by-zero exception",
4332 __real__ result, DIVIDE_BY_ZERO_EXCEPTION);
4333 check ("imag(clog10(0 - i0)) = -0 plus divide-by-zero exception",
4334 __imag__ result, minus_zero);
4336 result = FUNC(clog10) (BUILD_COMPLEX (minus_infty, plus_infty));
4337 check_isinfp ("real(clog10(-Inf + i Inf)) = +Inf", __real__ result);
4338 check ("imag(clog10(-Inf + i Inf)) = 3*pi/4", __imag__ result, M_PI - M_PI_4);
4339 result = FUNC(clog10) (BUILD_COMPLEX (minus_infty, minus_infty));
4340 check_isinfp ("real(clog10(-Inf - i Inf)) = +Inf", __real__ result);
4341 check ("imag(clog10(-Inf - i Inf)) = -3*pi/4", __imag__ result, M_PI_4 - M_PI);
4343 result = FUNC(clog10) (BUILD_COMPLEX (plus_infty, plus_infty));
4344 check_isinfp ("real(clog10(+Inf + i Inf)) = +Inf", __real__ result);
4345 check ("imag(clog10(+Inf + i Inf)) = pi/4", __imag__ result, M_PI_4);
4346 result = FUNC(clog10) (BUILD_COMPLEX (plus_infty, minus_infty));
4347 check_isinfp ("real(clog10(+Inf - i Inf)) = +Inf", __real__ result);
4348 check ("imag(clog10(+Inf - i Inf)) = -pi/4", __imag__ result, -M_PI_4);
4350 result = FUNC(clog10) (BUILD_COMPLEX (0, 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 (minus_zero, plus_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, plus_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 (0, 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);
4368 result = FUNC(clog10) (BUILD_COMPLEX (minus_zero, minus_infty));
4369 check_isinfp ("real(clog10(-0 - i Inf)) = +Inf", __real__ result);
4370 check ("imag(clog10(-0 - i Inf)) = -pi/2", __imag__ result, -M_PI_2);
4371 result = FUNC(clog10) (BUILD_COMPLEX (-3, minus_infty));
4372 check_isinfp ("real(clog10(-3 - i Inf)) = +Inf", __real__ result);
4373 check ("imag(clog10(-3 - i Inf)) = -pi/2", __imag__ result, -M_PI_2);
4375 result = FUNC(clog10) (BUILD_COMPLEX (minus_infty, 0));
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);
4381 result = FUNC(clog10) (BUILD_COMPLEX (minus_infty, minus_zero));
4382 check_isinfp ("real(clog10(-Inf - i0)) = +Inf", __real__ result);
4383 check ("imag(clog10(-Inf - i0)) = -pi", __imag__ result, -M_PI);
4384 result = FUNC(clog10) (BUILD_COMPLEX (minus_infty, -1));
4385 check_isinfp ("real(clog10(-Inf - i1)) = +Inf", __real__ result);
4386 check ("imag(clog10(-Inf - i1)) = -pi", __imag__ result, -M_PI);
4388 result = FUNC(clog10) (BUILD_COMPLEX (plus_infty, 0));
4389 check_isinfp ("real(clog10(+Inf + i0)) = +Inf", __real__ result);
4390 check ("imag(clog10(+Inf + i0)) = 0", __imag__ result, 0);
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, 0);
4394 result = FUNC(clog10) (BUILD_COMPLEX (plus_infty, minus_zero));
4395 check_isinfp ("real(clog10(+Inf - i0)) = +Inf", __real__ result);
4396 check ("imag(clog10(+Inf - i0)) = -0", __imag__ result, minus_zero);
4397 result = FUNC(clog10) (BUILD_COMPLEX (plus_infty, -1));
4398 check_isinfp ("real(clog10(+Inf - i1)) = +Inf", __real__ result);
4399 check ("imag(clog10(+Inf - i1)) = -0", __imag__ result, minus_zero);
4401 result = FUNC(clog10) (BUILD_COMPLEX (plus_infty, nan_value));
4402 check_isinfp ("real(clog10(+Inf + i NaN)) = +Inf", __real__ result);
4403 check_isnan ("imag(clog10(+Inf + i NaN)) = NaN", __imag__ result);
4404 result = FUNC(clog10) (BUILD_COMPLEX (minus_infty, nan_value));
4405 check_isinfp ("real(clog10(-Inf + i NaN)) = +Inf", __real__ result);
4406 check_isnan ("imag(clog10(-Inf + i NaN)) = NaN", __imag__ result);
4408 result = FUNC(clog10) (BUILD_COMPLEX (nan_value, plus_infty));
4409 check_isinfp ("real(clog10(NaN + i Inf)) = +Inf", __real__ result);
4410 check_isnan ("imag(clog10(NaN + i Inf)) = NaN", __imag__ result);
4411 result = FUNC(clog10) (BUILD_COMPLEX (nan_value, minus_infty));
4412 check_isinfp ("real(clog10(NaN - i Inf)) = +Inf", __real__ result);
4413 check_isnan ("imag(clog10(NaN - i Inf)) = NaN", __imag__ result);
4415 result = FUNC(clog10) (BUILD_COMPLEX (0, nan_value));
4416 check_isnan_maybe_exc ("real(clog10(0 + i NaN)) = NaN plus maybe invalid exception",
4417 __real__ result, INVALID_EXCEPTION);
4418 check_isnan ("imag(clog10(0 + i NaN)) = NaN plus maybe invalid exception",
4419 __imag__ result);
4420 result = FUNC(clog10) (BUILD_COMPLEX (3, nan_value));
4421 check_isnan_maybe_exc ("real(clog10(3 + i NaN)) = NaN plus maybe invalid exception",
4422 __real__ result, INVALID_EXCEPTION);
4423 check_isnan ("imag(clog10(3 + i NaN)) = NaN plus maybe invalid exception",
4424 __imag__ result);
4425 result = FUNC(clog10) (BUILD_COMPLEX (minus_zero, nan_value));
4426 check_isnan_maybe_exc ("real(clog10(-0 + i NaN)) = NaN plus maybe invalid exception",
4427 __real__ result, INVALID_EXCEPTION);
4428 check_isnan ("imag(clog10(-0 + i NaN)) = NaN plus maybe invalid exception",
4429 __imag__ result);
4430 result = FUNC(clog10) (BUILD_COMPLEX (-3, nan_value));
4431 check_isnan_maybe_exc ("real(clog10(-3 + i NaN)) = NaN plus maybe invalid exception",
4432 __real__ result, INVALID_EXCEPTION);
4433 check_isnan ("imag(clog10(-3 + i NaN)) = NaN plus maybe invalid exception",
4434 __imag__ result);
4436 result = FUNC(clog10) (BUILD_COMPLEX (nan_value, 0));
4437 check_isnan_maybe_exc ("real(clog10(NaN + i0)) = NaN plus maybe invalid exception",
4438 __real__ result, INVALID_EXCEPTION);
4439 check_isnan ("imag(clog10(NaN + i0)) = NaN plus maybe invalid exception",
4440 __imag__ result);
4441 result = FUNC(clog10) (BUILD_COMPLEX (nan_value, 5));
4442 check_isnan_maybe_exc ("real(clog10(NaN + i5)) = NaN plus maybe invalid exception",
4443 __real__ result, INVALID_EXCEPTION);
4444 check_isnan ("imag(clog10(NaN + i5)) = NaN plus maybe invalid exception",
4445 __imag__ result);
4446 result = FUNC(clog10) (BUILD_COMPLEX (nan_value, minus_zero));
4447 check_isnan_maybe_exc ("real(clog10(NaN - i0)) = NaN plus maybe invalid exception",
4448 __real__ result, INVALID_EXCEPTION);
4449 check_isnan ("imag(clog10(NaN - i0)) = NaN plus maybe invalid exception",
4450 __imag__ result);
4451 result = FUNC(clog10) (BUILD_COMPLEX (nan_value, -5));
4452 check_isnan_maybe_exc ("real(clog10(NaN - i5)) = NaN plus maybe invalid exception",
4453 __real__ result, INVALID_EXCEPTION);
4454 check_isnan ("imag(clog10(NaN - i5)) = NaN plus maybe invalid exception",
4455 __imag__ result);
4457 result = FUNC(clog10) (BUILD_COMPLEX (nan_value, nan_value));
4458 check_isnan ("real(clog10(NaN + i NaN)) = NaN", __real__ result);
4459 check_isnan ("imag(clog10(NaN + i NaN)) = NaN", __imag__ result);
4463 static void
4464 csqrt_test (void)
4466 __complex__ MATHTYPE result;
4468 result = FUNC(csqrt) (BUILD_COMPLEX (0, 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 (0, minus_zero));
4472 check ("real(csqrt(0 - i0)) = 0", __real__ result, 0);
4473 check ("imag(csqrt(0 - i0)) = -0", __imag__ result, minus_zero);
4474 result = FUNC(csqrt) (BUILD_COMPLEX (minus_zero, 0));
4475 check ("real(csqrt(-0 + i0)) = 0", __real__ result, 0);
4476 check ("imag(csqrt(-0 + i0)) = 0", __imag__ result, 0);
4477 result = FUNC(csqrt) (BUILD_COMPLEX (minus_zero, minus_zero));
4478 check ("real(csqrt(-0 - i0)) = 0", __real__ result, 0);
4479 check ("imag(csqrt(-0 - i0)) = -0", __imag__ result, minus_zero);
4481 result = FUNC(csqrt) (BUILD_COMPLEX (minus_infty, 0));
4482 check ("real(csqrt(-Inf + i0)) = 0", __real__ result, 0);
4483 check_isinfp ("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_isinfp ("imag(csqrt(-Inf + i6)) = +Inf", __imag__ result);
4487 result = FUNC(csqrt) (BUILD_COMPLEX (minus_infty, minus_zero));
4488 check ("real(csqrt(-Inf - i0)) = 0", __real__ result, 0);
4489 check_isinfn ("imag(csqrt(-Inf - i0)) = -Inf", __imag__ result);
4490 result = FUNC(csqrt) (BUILD_COMPLEX (minus_infty, -6));
4491 check ("real(csqrt(-Inf - i6)) = 0", __real__ result, 0);
4492 check_isinfn ("imag(csqrt(-Inf - i6)) = -Inf", __imag__ result);
4494 result = FUNC(csqrt) (BUILD_COMPLEX (plus_infty, 0));
4495 check_isinfp ("real(csqrt(+Inf + i0)) = +Inf", __real__ result);
4496 check ("imag(csqrt(+Inf + i0)) = 0", __imag__ result, 0);
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, 0);
4500 result = FUNC(csqrt) (BUILD_COMPLEX (plus_infty, minus_zero));
4501 check_isinfp ("real(csqrt(+Inf - i0)) = +Inf", __real__ result);
4502 check ("imag(csqrt(+Inf - i0)) = -0", __imag__ result, minus_zero);
4503 result = FUNC(csqrt) (BUILD_COMPLEX (plus_infty, -6));
4504 check_isinfp ("real(csqrt(+Inf - i6)) = +Inf", __real__ result);
4505 check ("imag(csqrt(+Inf - i6)) = -0", __imag__ result, minus_zero);
4507 result = FUNC(csqrt) (BUILD_COMPLEX (0, plus_infty));
4508 check_isinfp ("real(csqrt(0 + i Inf)) = +Inf", __real__ result);
4509 check_isinfp ("imag(csqrt(0 + i Inf)) = +Inf", __imag__ result);
4510 result = FUNC(csqrt) (BUILD_COMPLEX (4, plus_infty));
4511 check_isinfp ("real(csqrt(4 + i Inf)) = +Inf", __real__ result);
4512 check_isinfp ("imag(csqrt(4 + i Inf)) = +Inf", __imag__ result);
4513 result = FUNC(csqrt) (BUILD_COMPLEX (plus_infty, plus_infty));
4514 check_isinfp ("real(csqrt(+Inf + i Inf)) = +Inf", __real__ result);
4515 check_isinfp ("imag(csqrt(+Inf + i Inf)) = +Inf", __imag__ result);
4516 result = FUNC(csqrt) (BUILD_COMPLEX (minus_zero, plus_infty));
4517 check_isinfp ("real(csqrt(-0 + i Inf)) = +Inf", __real__ result);
4518 check_isinfp ("imag(csqrt(-0 + i Inf)) = +Inf", __imag__ result);
4519 result = FUNC(csqrt) (BUILD_COMPLEX (-4, plus_infty));
4520 check_isinfp ("real(csqrt(-4 + i Inf)) = +Inf", __real__ result);
4521 check_isinfp ("imag(csqrt(-4 + i Inf)) = +Inf", __imag__ result);
4522 result = FUNC(csqrt) (BUILD_COMPLEX (minus_infty, plus_infty));
4523 check_isinfp ("real(csqrt(-Inf + i Inf)) = +Inf", __real__ result);
4524 check_isinfp ("imag(csqrt(-Inf + i Inf)) = +Inf", __imag__ result);
4525 result = FUNC(csqrt) (BUILD_COMPLEX (0, minus_infty));
4526 check_isinfp ("real(csqrt(0 - i Inf)) = +Inf", __real__ result);
4527 check_isinfn ("imag(csqrt(0 - i Inf)) = -Inf", __imag__ result);
4528 result = FUNC(csqrt) (BUILD_COMPLEX (4, minus_infty));
4529 check_isinfp ("real(csqrt(4 - i Inf)) = +Inf", __real__ result);
4530 check_isinfn ("imag(csqrt(4 - i Inf)) = -Inf", __imag__ result);
4531 result = FUNC(csqrt) (BUILD_COMPLEX (plus_infty, minus_infty));
4532 check_isinfp ("real(csqrt(+Inf - i Inf)) = +Inf", __real__ result);
4533 check_isinfn ("imag(csqrt(+Inf - i Inf)) = -Inf", __imag__ result);
4534 result = FUNC(csqrt) (BUILD_COMPLEX (minus_zero, minus_infty));
4535 check_isinfp ("real(csqrt(-0 - i Inf)) = +Inf", __real__ result);
4536 check_isinfn ("imag(csqrt(-0 - i Inf)) = -Inf", __imag__ result);
4537 result = FUNC(csqrt) (BUILD_COMPLEX (-4, minus_infty));
4538 check_isinfp ("real(csqrt(-4 - i Inf)) = +Inf", __real__ result);
4539 check_isinfn ("imag(csqrt(-4 - i Inf)) = -Inf", __imag__ result);
4540 result = FUNC(csqrt) (BUILD_COMPLEX (minus_infty, minus_infty));
4541 check_isinfp ("real(csqrt(-Inf - i Inf)) = +Inf", __real__ result);
4542 check_isinfn ("imag(csqrt(-Inf - i Inf)) = -Inf", __imag__ result);
4544 result = FUNC(csqrt) (BUILD_COMPLEX (minus_infty, nan_value));
4545 check_isnan ("real(csqrt(-Inf + i NaN)) = NaN", __real__ result);
4546 check_isinfp ("imag(csqrt(-Inf + i NaN)) = +-Inf",
4547 FUNC(fabs) (__imag__ result));
4549 result = FUNC(csqrt) (BUILD_COMPLEX (plus_infty, nan_value));
4550 check_isinfp ("real(csqrt(+Inf + i NaN)) = +Inf", __real__ result);
4551 check_isnan ("imag(csqrt(+Inf + i NaN)) = NaN", __imag__ result);
4553 result = FUNC(csqrt) (BUILD_COMPLEX (0, nan_value));
4554 check_isnan_maybe_exc ("real(csqrt(0 + i NaN)) = NaN plus maybe invalid exception",
4555 __real__ result, INVALID_EXCEPTION);
4556 check_isnan ("imag(csqrt(0 + i NaN)) = NaN plus maybe invalid exception",
4557 __imag__ result);
4558 result = FUNC(csqrt) (BUILD_COMPLEX (1, nan_value));
4559 check_isnan_maybe_exc ("real(csqrt(1 + i NaN)) = NaN plus maybe invalid exception",
4560 __real__ result, INVALID_EXCEPTION);
4561 check_isnan ("imag(csqrt(1 + i NaN)) = NaN plus maybe invalid exception",
4562 __imag__ result);
4563 result = FUNC(csqrt) (BUILD_COMPLEX (minus_zero, nan_value));
4564 check_isnan_maybe_exc ("real(csqrt(-0 + i NaN)) = NaN plus maybe invalid exception",
4565 __real__ result, INVALID_EXCEPTION);
4566 check_isnan ("imag(csqrt(-0 + i NaN)) = NaN plus maybe invalid exception",
4567 __imag__ result);
4568 result = FUNC(csqrt) (BUILD_COMPLEX (-1, nan_value));
4569 check_isnan_maybe_exc ("real(csqrt(-1 + i NaN)) = NaN plus maybe invalid exception",
4570 __real__ result, INVALID_EXCEPTION);
4571 check_isnan ("imag(csqrt(-1 + i NaN)) = NaN plus maybe invalid exception",
4572 __imag__ result);
4574 result = FUNC(csqrt) (BUILD_COMPLEX (nan_value, 0));
4575 check_isnan_maybe_exc ("real(csqrt(NaN + i0)) = NaN plus maybe invalid exception",
4576 __real__ result, INVALID_EXCEPTION);
4577 check_isnan ("imag(csqrt(NaN + i0)) = NaN plus maybe invalid exception",
4578 __imag__ result);
4579 result = FUNC(csqrt) (BUILD_COMPLEX (nan_value, 8));
4580 check_isnan_maybe_exc ("real(csqrt(NaN + i8)) = NaN plus maybe invalid exception",
4581 __real__ result, INVALID_EXCEPTION);
4582 check_isnan ("imag(csqrt(NaN + i8)) = NaN plus maybe invalid exception",
4583 __imag__ result);
4584 result = FUNC(csqrt) (BUILD_COMPLEX (nan_value, minus_zero));
4585 check_isnan_maybe_exc ("real(csqrt(NaN - i0)) = NaN plus maybe invalid exception",
4586 __real__ result, INVALID_EXCEPTION);
4587 check_isnan ("imag(csqrt(NaN - i0)) = NaN plus maybe invalid exception",
4588 __imag__ result);
4589 result = FUNC(csqrt) (BUILD_COMPLEX (nan_value, -8));
4590 check_isnan_maybe_exc ("real(csqrt(NaN - i8)) = NaN plus maybe invalid exception",
4591 __real__ result, INVALID_EXCEPTION);
4592 check_isnan ("imag(csqrt(NaN - i8)) = NaN plus maybe invalid exception",
4593 __imag__ result);
4595 result = FUNC(csqrt) (BUILD_COMPLEX (nan_value, nan_value));
4596 check_isnan ("real(csqrt(NaN + i NaN)) = NaN", __real__ result);
4597 check_isnan ("imag(csqrt(NaN + i NaN)) = NaN", __imag__ result);
4601 static void
4602 cpow_test (void)
4604 __complex__ MATHTYPE result;
4606 result = FUNC (cpow) (BUILD_COMPLEX (1, 0), BUILD_COMPLEX (0, 0));
4607 check ("real(cpow (1 + i0), (0 + i0)) = 0", __real__ result, 1);
4608 check ("imag(cpow (1 + i0), (0 + i0)) = 0", __imag__ result, 0);
4610 result = FUNC (cpow) (BUILD_COMPLEX (2, 0), BUILD_COMPLEX (10, 0));
4611 check_eps ("real(cpow (2 + i0), (10 + i0)) = 1024", __real__ result, 1024,
4612 CHOOSE (2e-16L, 0, 0));
4613 check ("imag(cpow (2 + i0), (10 + i0)) = 0", __imag__ result, 0);
4618 static void
4619 nearbyint_test (void)
4621 check ("nearbyint(+0) = 0", FUNC(nearbyint) (0.0), 0.0);
4622 check ("nearbyint(-0) = -0", FUNC(nearbyint) (minus_zero), minus_zero);
4623 check_isinfp ("nearbyint(+Inf) = +Inf", FUNC(nearbyint) (plus_infty));
4624 check_isinfn ("nearbyint(-Inf) = -Inf", FUNC(nearbyint) (minus_infty));
4628 static void
4629 rint_test (void)
4631 check ("rint(0) = 0", FUNC(rint) (0.0), 0.0);
4632 check ("rint(-0) = -0", FUNC(rint) (minus_zero), minus_zero);
4633 check_isinfp ("rint(+Inf) = +Inf", FUNC(rint) (plus_infty));
4634 check_isinfn ("rint(-Inf) = -Inf", FUNC(rint) (minus_infty));
4638 static void
4639 lrint_test (void)
4641 /* XXX this test is incomplete. We need to have a way to specifiy
4642 the rounding method and test the critical cases. So far, only
4643 unproblematic numbers are tested. */
4645 check_long ("lrint(0) = 0", FUNC(lrint) (0.0), 0);
4646 check_long ("lrint(-0) = 0", FUNC(lrint) (minus_zero), 0);
4647 check_long ("lrint(0.2) = 0", FUNC(lrint) (0.2), 0);
4648 check_long ("lrint(-0.2) = 0", FUNC(lrint) (-0.2), 0);
4650 check_long ("lrint(1.4) = 1", FUNC(lrint) (1.4), 1);
4651 check_long ("lrint(-1.4) = -1", FUNC(lrint) (-1.4), -1);
4653 check_long ("lrint(8388600.3) = 8388600", FUNC(lrint) (8388600.3), 8388600);
4654 check_long ("lrint(-8388600.3) = -8388600", FUNC(lrint) (-8388600.3),
4655 -8388600);
4659 static void
4660 llrint_test (void)
4662 /* XXX this test is incomplete. We need to have a way to specifiy
4663 the rounding method and test the critical cases. So far, only
4664 unproblematic numbers are tested. */
4666 check_longlong ("llrint(0) = 0", FUNC(llrint) (0.0), 0);
4667 check_longlong ("llrint(-0) = 0", FUNC(llrint) (minus_zero), 0);
4668 check_longlong ("llrint(0.2) = 0", FUNC(llrint) (0.2), 0);
4669 check_longlong ("llrint(-0.2) = 0", FUNC(llrint) (-0.2), 0);
4671 check_longlong ("llrint(1.4) = 1", FUNC(llrint) (1.4), 1);
4672 check_longlong ("llrint(-1.4) = -1", FUNC(llrint) (-1.4), -1);
4674 check_longlong ("llrint(8388600.3) = 8388600", FUNC(llrint) (8388600.3),
4675 8388600);
4676 check_longlong ("llrint(-8388600.3) = -8388600", FUNC(llrint) (-8388600.3),
4677 -8388600);
4679 /* Test boundary conditions. */
4680 /* 0x1FFFFF */
4681 check_longlong ("llrint(2097151.0) = 2097151", FUNC(llrint) (2097151.0),
4682 2097151LL);
4683 /* 0x800000 */
4684 check_longlong ("llrint(8388608.0) = 8388608", FUNC(llrint) (8388608.0),
4685 8388608LL);
4686 /* 0x1000000 */
4687 check_longlong ("llrint(16777216.0) = 16777216",
4688 FUNC(llrint) (16777216.0), 16777216LL);
4689 /* 0x20000000000 */
4690 check_longlong ("llrint(2199023255552.0) = 2199023255552",
4691 FUNC(llrint) (2199023255552.0), 2199023255552LL);
4692 /* 0x40000000000 */
4693 check_longlong ("llrint(4398046511104.0) = 4398046511104",
4694 FUNC(llrint) (4398046511104.0), 4398046511104LL);
4695 /* 0x10000000000000 */
4696 check_longlong ("llrint(4503599627370496.0) = 4503599627370496",
4697 FUNC(llrint) (4503599627370496.0), 4503599627370496LL);
4698 /* 0x10000080000000 */
4699 check_longlong ("llrint(4503601774854144.0) = 4503601774854144",
4700 FUNC(llrint) (4503601774854144.0), 4503601774854144LL);
4701 /* 0x20000000000000 */
4702 check_longlong ("llrint(9007199254740992.0) = 9007199254740992",
4703 FUNC(llrint) (9007199254740992.0), 9007199254740992LL);
4704 /* 0x80000000000000 */
4705 check_longlong ("llrint(36028797018963968.0) = 36028797018963968",
4706 FUNC(llrint) (36028797018963968.0), 36028797018963968LL);
4707 /* 0x100000000000000 */
4708 check_longlong ("llrint(72057594037927936.0) = 72057594037927936",
4709 FUNC(llrint) (72057594037927936.0), 72057594037927936LL);
4713 static void
4714 round_test (void)
4716 check ("round(0) = 0", FUNC(round) (0), 0);
4717 check ("round(-0) = -0", FUNC(round) (minus_zero), minus_zero);
4718 check ("round(0.2) = 0", FUNC(round) (0.2), 0.0);
4719 check ("round(-0.2) = -0", FUNC(round) (-0.2), minus_zero);
4720 check ("round(0.5) = 1", FUNC(round) (0.5), 1.0);
4721 check ("round(-0.5) = -1", FUNC(round) (-0.5), -1.0);
4722 check ("round(0.8) = 1", FUNC(round) (0.8), 1.0);
4723 check ("round(-0.8) = -1", FUNC(round) (-0.8), -1.0);
4724 check ("round(1.5) = 2", FUNC(round) (1.5), 2.0);
4725 check ("round(-1.5) = -2", FUNC(round) (-1.5), -2.0);
4726 check ("round(2097152.5) = 2097153", FUNC(round) (2097152.5), 2097153);
4727 check ("round(-2097152.5) = -2097153", FUNC(round) (-2097152.5), -2097153);
4731 static void
4732 lround_test (void)
4734 check_long ("lround(0) = 0", FUNC(lround) (0), 0);
4735 check_long ("lround(-0) = 0", FUNC(lround) (minus_zero), 0);
4736 check_long ("lround(0.2) = 0", FUNC(lround) (0.2), 0.0);
4737 check_long ("lround(-0.2) = 0", FUNC(lround) (-0.2), 0);
4738 check_long ("lround(0.5) = 1", FUNC(lround) (0.5), 1);
4739 check_long ("lround(-0.5) = -1", FUNC(lround) (-0.5), -1);
4740 check_long ("lround(0.8) = 1", FUNC(lround) (0.8), 1);
4741 check_long ("lround(-0.8) = -1", FUNC(lround) (-0.8), -1);
4742 check_long ("lround(1.5) = 2", FUNC(lround) (1.5), 2);
4743 check_long ("lround(-1.5) = -2", FUNC(lround) (-1.5), -2);
4744 check_long ("lround(22514.5) = 22515", FUNC(lround) (22514.5), 22515);
4745 check_long ("lround(-22514.5) = -22515", FUNC(lround) (-22514.5), -22515);
4746 #ifndef TEST_FLOAT
4747 check_long ("lround(2097152.5) = 2097153", FUNC(lround) (2097152.5),
4748 2097153);
4749 check_long ("lround(-2097152.5) = -2097153", FUNC(lround) (-2097152.5),
4750 -2097153);
4751 #endif
4755 static void
4756 llround_test (void)
4758 check_longlong ("llround(0) = 0", FUNC(llround) (0), 0);
4759 check_longlong ("llround(-0) = 0", FUNC(llround) (minus_zero), 0);
4760 check_longlong ("llround(0.2) = 0", FUNC(llround) (0.2), 0.0);
4761 check_longlong ("llround(-0.2) = 0", FUNC(llround) (-0.2), 0);
4762 check_longlong ("llround(0.5) = 1", FUNC(llround) (0.5), 1);
4763 check_longlong ("llround(-0.5) = -1", FUNC(llround) (-0.5), -1);
4764 check_longlong ("llround(0.8) = 1", FUNC(llround) (0.8), 1);
4765 check_longlong ("llround(-0.8) = -1", FUNC(llround) (-0.8), -1);
4766 check_longlong ("llround(1.5) = 2", FUNC(llround) (1.5), 2);
4767 check_longlong ("llround(-1.5) = -2", FUNC(llround) (-1.5), -2);
4768 check_longlong ("llround(22514.5) = 22515", FUNC(llround) (22514.5), 22515);
4769 check_longlong ("llround(-22514.5) = -22515", FUNC(llround) (-22514.5),
4770 -22515);
4771 #ifndef TEST_FLOAT
4772 check_longlong ("llround(2097152.5) = 2097153",
4773 FUNC(llround) (2097152.5), 2097153);
4774 check_longlong ("llround(-2097152.5) = -2097153",
4775 FUNC(llround) (-2097152.5), -2097153);
4776 check_longlong ("llround(34359738368.5) = 34359738369",
4777 FUNC(llround) (34359738368.5), 34359738369ll);
4778 check_longlong ("llround(-34359738368.5) = -34359738369",
4779 FUNC(llround) (-34359738368.5), -34359738369ll);
4780 #endif
4782 /* Test boundary conditions. */
4783 /* 0x1FFFFF */
4784 check_longlong ("llround(2097151.0) = 2097151", FUNC(llround) (2097151.0),
4785 2097151LL);
4786 /* 0x800000 */
4787 check_longlong ("llround(8388608.0) = 8388608", FUNC(llround) (8388608.0),
4788 8388608LL);
4789 /* 0x1000000 */
4790 check_longlong ("llround(16777216.0) = 16777216",
4791 FUNC(llround) (16777216.0), 16777216LL);
4792 /* 0x20000000000 */
4793 check_longlong ("llround(2199023255552.0) = 2199023255552",
4794 FUNC(llround) (2199023255552.0), 2199023255552LL);
4795 /* 0x40000000000 */
4796 check_longlong ("llround(4398046511104.0) = 4398046511104",
4797 FUNC(llround) (4398046511104.0), 4398046511104LL);
4798 /* 0x10000000000000 */
4799 check_longlong ("llround(4503599627370496.0) = 4503599627370496",
4800 FUNC(llround) (4503599627370496.0), 4503599627370496LL);
4801 /* 0x10000080000000 */
4802 check_longlong ("llrint(4503601774854144.0) = 4503601774854144",
4803 FUNC(llrint) (4503601774854144.0), 4503601774854144LL);
4804 /* 0x20000000000000 */
4805 check_longlong ("llround(9007199254740992.0) = 9007199254740992",
4806 FUNC(llround) (9007199254740992.0), 9007199254740992LL);
4807 /* 0x80000000000000 */
4808 check_longlong ("llround(36028797018963968.0) = 36028797018963968",
4809 FUNC(llround) (36028797018963968.0), 36028797018963968LL);
4810 /* 0x100000000000000 */
4811 check_longlong ("llround(72057594037927936.0) = 72057594037927936",
4812 FUNC(llround) (72057594037927936.0), 72057594037927936LL);
4816 static void
4817 fma_test (void)
4819 check ("fma(1.0, 2.0, 3.0) = 5.0", FUNC(fma) (1.0, 2.0, 3.0), 5.0);
4820 check_isnan ("fma(NaN, 2.0, 3.0) = NaN", FUNC(fma) (nan_value, 2.0, 3.0));
4821 check_isnan ("fma(1.0, NaN, 3.0) = NaN", FUNC(fma) (1.0, nan_value, 3.0));
4822 check_isnan_maybe_exc ("fma(1.0, 2.0, NaN) = NaN",
4823 FUNC(fma) (1.0, 2.0, nan_value), INVALID_EXCEPTION);
4824 check_isnan_maybe_exc ("fma(+Inf, 0.0, NaN) = NaN",
4825 FUNC(fma) (plus_infty, 0.0, nan_value),
4826 INVALID_EXCEPTION);
4827 check_isnan_maybe_exc ("fma(-Inf, 0.0, NaN) = NaN",
4828 FUNC(fma) (minus_infty, 0.0, nan_value),
4829 INVALID_EXCEPTION);
4830 check_isnan_maybe_exc ("fma(0.0, +Inf, NaN) = NaN",
4831 FUNC(fma) (0.0, plus_infty, nan_value),
4832 INVALID_EXCEPTION);
4833 check_isnan_maybe_exc ("fma(0.0, -Inf, NaN) = NaN",
4834 FUNC(fma) (0.0, minus_infty, nan_value),
4835 INVALID_EXCEPTION);
4836 check_isnan_exc ("fma(+Inf, 0.0, 1.0) = NaN",
4837 FUNC(fma) (plus_infty, 0.0, 1.0), INVALID_EXCEPTION);
4838 check_isnan_exc ("fma(-Inf, 0.0, 1.0) = NaN",
4839 FUNC(fma) (minus_infty, 0.0, 1.0), INVALID_EXCEPTION);
4840 check_isnan_exc ("fma(0.0, +Inf, 1.0) = NaN",
4841 FUNC(fma) (0.0, plus_infty, 1.0), INVALID_EXCEPTION);
4842 check_isnan_exc ("fma(0.0, -Inf, 1.0) = NaN",
4843 FUNC(fma) (0.0, minus_infty, 1.0), INVALID_EXCEPTION);
4845 check_isnan_exc ("fma(+Inf, +Inf, -Inf) = NaN",
4846 FUNC(fma) (plus_infty, plus_infty, minus_infty),
4847 INVALID_EXCEPTION);
4848 check_isnan_exc ("fma(-Inf, +Inf, +Inf) = NaN",
4849 FUNC(fma) (minus_infty, plus_infty, plus_infty),
4850 INVALID_EXCEPTION);
4851 check_isnan_exc ("fma(+Inf, -Inf, +Inf) = NaN",
4852 FUNC(fma) (plus_infty, minus_infty, plus_infty),
4853 INVALID_EXCEPTION);
4854 check_isnan_exc ("fma(-Inf, -Inf, -Inf) = NaN",
4855 FUNC(fma) (minus_infty, minus_infty, minus_infty),
4856 INVALID_EXCEPTION);
4860 static void
4861 inverse_func_pair_test (const char *test_name,
4862 mathfunc f1, mathfunc inverse,
4863 MATHTYPE x, MATHTYPE epsilon)
4865 MATHTYPE a, b, difference;
4866 int result;
4868 a = f1 (x);
4869 (void) &a;
4870 b = inverse (a);
4871 (void) &b;
4873 output_new_test (test_name);
4874 result = check_equal (b, x, epsilon, &difference);
4875 output_result (test_name, result,
4876 b, x, difference, PRINT, PRINT);
4880 static void
4881 inverse_functions (void)
4883 inverse_func_pair_test ("asin(sin(x)) == x",
4884 FUNC(sin), FUNC(asin), 1.0,
4885 CHOOSE (2e-18L, 0, 3e-7L));
4886 inverse_func_pair_test ("sin(asin(x)) == x",
4887 FUNC(asin), FUNC(sin), 1.0, 0.0);
4889 inverse_func_pair_test ("acos(cos(x)) == x",
4890 FUNC(cos), FUNC(acos), 1.0,
4891 CHOOSE (4e-18L, 1e-15L, 0));
4892 inverse_func_pair_test ("cos(acos(x)) == x",
4893 FUNC(acos), FUNC(cos), 1.0, 0.0);
4894 inverse_func_pair_test ("atan(tan(x)) == x",
4895 FUNC(tan), FUNC(atan), 1.0, CHOOSE (2e-18L, 0, 0));
4896 inverse_func_pair_test ("tan(atan(x)) == x",
4897 FUNC(atan), FUNC(tan), 1.0,
4898 CHOOSE (2e-18L, 1e-15L, 2e-7));
4900 inverse_func_pair_test ("asinh(sinh(x)) == x",
4901 FUNC(sinh), FUNC(asinh), 1.0, CHOOSE (1e-18L, 0, 1e-7));
4902 inverse_func_pair_test ("sinh(asinh(x)) == x",
4903 FUNC(asinh), FUNC(sinh), 1.0,
4904 CHOOSE (2e-18L, 2e-16L, 2e-7));
4906 inverse_func_pair_test ("acosh(cosh(x)) == x",
4907 FUNC(cosh), FUNC(acosh), 1.0,
4908 CHOOSE (1e-18L, 1e-15L, 6e-8));
4909 inverse_func_pair_test ("cosh(acosh(x)) == x",
4910 FUNC(acosh), FUNC(cosh), 1.0, 0.0);
4912 inverse_func_pair_test ("atanh(tanh(x)) == x",
4913 FUNC(tanh), FUNC(atanh), 1.0, CHOOSE (1e-18L, 1e-15L, 0));
4914 inverse_func_pair_test ("tanh(atanh(x)) == x",
4915 FUNC(atanh), FUNC(tanh), 1.0, 0.0);
4919 /* Test sin and cos with the identity: sin(x)^2 + cos(x)^2 = 1. */
4920 static void
4921 identities1_test (MATHTYPE x, MATHTYPE epsilon)
4923 MATHTYPE res1, res2, res3, diff;
4924 int result;
4926 res1 = FUNC(sin) (x);
4927 (void) &res1;
4928 res2 = FUNC(cos) (x);
4929 (void) &res2;
4930 res3 = res1 * res1 + res2 * res2;
4931 (void) &res3;
4933 output_new_test ("sin^2 + cos^2 == 1");
4934 result = check_equal (res3, 1.0, epsilon, &diff);
4935 output_result_ext ("sin^2 + cos^2 == 1", result,
4936 res3, 1.0, diff, x, PRINT, PRINT);
4940 /* Test sin, cos, tan with the following relation: tan = sin/cos. */
4941 static void
4942 identities2_test (MATHTYPE x, MATHTYPE epsilon)
4944 #ifndef TEST_INLINE
4945 MATHTYPE res1, res2, res3, res4, diff;
4946 int result;
4948 res1 = FUNC(sin) (x);
4949 (void) &res1;
4950 res2 = FUNC(cos) (x);
4951 (void) &res2;
4952 res3 = FUNC(tan) (x);
4953 (void) &res3;
4954 res4 = res1 / res2;
4955 (void) &res4;
4957 output_new_test ("sin/cos == tan");
4958 result = check_equal (res4, res3, epsilon, &diff);
4959 output_result_ext ("sin/cos == tan", result,
4960 res4, res3, diff, x, PRINT, PRINT);
4961 #endif
4965 /* Test cosh and sinh with the identity cosh^2 - sinh^2 = 1. */
4966 static void
4967 identities3_test (MATHTYPE x, MATHTYPE epsilon)
4969 MATHTYPE res1, res2, res3, diff;
4970 int result;
4972 res1 = FUNC(sinh) (x);
4973 (void) &res1;
4974 res2 = FUNC(cosh) (x);
4975 (void) &res2;
4976 res3 = res2 * res2 - res1 * res1;
4977 (void) &res3;
4979 output_new_test ("cosh^2 - sinh^2 == 1");
4980 result = check_equal (res3, 1.0, epsilon, &diff);
4981 output_result_ext ("cosh^2 - sinh^2 == 1", result,
4982 res3, 1.0, diff, x, PRINT, PRINT);
4986 static void
4987 identities (void)
4989 identities1_test (0.2L, CHOOSE (1e-18L, 0, 2e-7));
4990 identities1_test (0.9L, CHOOSE (1e-18L, 0, 1e-7));
4991 identities1_test (0, 0);
4992 identities1_test (-1, CHOOSE (1e-18L, 0, 1e-7));
4994 identities2_test (0.2L, CHOOSE (1e-19L, 1e-16, 0));
4995 identities2_test (0.9L, CHOOSE (0, 1e-15, 2e-7));
4996 identities2_test (0, 0);
4997 identities2_test (-1, CHOOSE (1e-18L, 1e-15, 2e-7));
4999 identities3_test (0.2L, CHOOSE (1e-18L, 0, 1e-7));
5000 identities3_test (0.9L, CHOOSE (1e-18L, 1e-15, 1e-6));
5001 identities3_test (0, CHOOSE (0, 0, 1e-6));
5002 identities3_test (-1, CHOOSE (1e-18L, 7e-16, 1e-6));
5007 Let's test that basic arithmetic is working
5008 tests: Infinity and NaN
5010 static void
5011 basic_tests (void)
5013 /* variables are declared volatile to forbid some compiler
5014 optimizations */
5015 volatile MATHTYPE Inf_var, NaN_var, zero_var, one_var;
5016 MATHTYPE x1, x2;
5018 zero_var = 0.0;
5019 one_var = 1.0;
5020 NaN_var = nan_value;
5021 Inf_var = one_var / zero_var;
5023 (void) &zero_var;
5024 (void) &one_var;
5025 (void) &NaN_var;
5026 (void) &Inf_var;
5028 /* Clear all exceptions. The previous computations raised exceptions. */
5029 feclearexcept (FE_ALL_EXCEPT);
5031 check_isinfp ("isinf (inf) == +1", Inf_var);
5032 check_isinfn ("isinf (-inf) == -1", -Inf_var);
5033 check_bool ("!isinf (1)", !(FUNC(isinf) (one_var)));
5034 check_bool ("!isinf (NaN)", !(FUNC(isinf) (NaN_var)));
5036 check_isnan ("isnan (NaN)", NaN_var);
5037 check_isnan ("isnan (-NaN)", -NaN_var);
5038 check_bool ("!isnan (1)", !(FUNC(isnan) (one_var)));
5039 check_bool ("!isnan (inf)", !(FUNC(isnan) (Inf_var)));
5041 check_bool ("inf == inf", Inf_var == Inf_var);
5042 check_bool ("-inf == -inf", -Inf_var == -Inf_var);
5043 check_bool ("inf != -inf", Inf_var != -Inf_var);
5044 check_bool ("NaN != NaN", NaN_var != NaN_var);
5047 the same tests but this time with NAN from <bits/nan.h>
5048 NAN is a double const
5050 check_bool ("isnan (NAN)", isnan (NAN));
5051 check_bool ("isnan (-NAN)", isnan (-NAN));
5052 check_bool ("!isinf (NAN)", !(isinf (NAN)));
5053 check_bool ("!isinf (-NAN)", !(isinf (-NAN)));
5054 check_bool ("NAN != NAN", NAN != NAN);
5057 And again with the value returned by the `nan' function.
5059 check_bool ("isnan (NAN)", FUNC(isnan) (FUNC(nan) ("")));
5060 check_bool ("isnan (-NAN)", FUNC(isnan) (-FUNC(nan) ("")));
5061 check_bool ("!isinf (NAN)", !(FUNC(isinf) (FUNC(nan) (""))));
5062 check_bool ("!isinf (-NAN)", !(FUNC(isinf) (-FUNC(nan) (""))));
5063 check_bool ("NAN != NAN", FUNC(nan) ("") != FUNC(nan) (""));
5065 /* test if EPSILON is ok */
5066 x1 = MATHCONST (1.0);
5067 x2 = x1 + CHOOSE (LDBL_EPSILON, DBL_EPSILON, FLT_EPSILON);
5068 check_bool ("1 != 1+EPSILON", x1 != x2);
5070 x1 = MATHCONST (1.0);
5071 x2 = x1 - CHOOSE (LDBL_EPSILON, DBL_EPSILON, FLT_EPSILON);
5072 check_bool ("1 != 1-EPSILON", x1 != x2);
5074 /* test if HUGE_VALx is ok */
5075 x1 = CHOOSE (HUGE_VALL, HUGE_VAL, HUGE_VALF);
5076 check_bool ("isinf (HUGE_VALx) == +1", ISINF (x1) == +1);
5077 x1 = -CHOOSE (HUGE_VALL, HUGE_VAL, HUGE_VALF);
5078 check_bool ("isinf (-HUGE_VALx) == -1", ISINF (x1) == -1);
5083 static void
5084 initialize (void)
5086 fpstack_test ("start *init*");
5087 plus_zero = 0.0;
5088 nan_value = plus_zero / plus_zero; /* Suppress GCC warning */
5090 minus_zero = FUNC (copysign) (0.0, -1.0);
5091 plus_infty = CHOOSE (HUGE_VALL, HUGE_VAL, HUGE_VALF);
5092 minus_infty = -CHOOSE (HUGE_VALL, HUGE_VAL, HUGE_VALF);
5094 (void) &plus_zero;
5095 (void) &nan_value;
5096 (void) &minus_zero;
5097 (void) &plus_infty;
5098 (void) &minus_infty;
5100 /* Clear all exceptions. From now on we must not get random exceptions. */
5101 feclearexcept (FE_ALL_EXCEPT);
5103 /* Test to make sure we start correctly. */
5104 fpstack_test ("end *init*");
5108 static struct option long_options[] =
5110 {"verbose", optional_argument, NULL, 'v'},
5111 {"silent", no_argument, NULL, 's'},
5112 {0, 0, 0, 0}
5116 static void
5117 parse_options (int argc, char *argv[])
5119 int c;
5120 int option_index;
5122 verbose = 1;
5124 while (1)
5126 c = getopt_long (argc, argv, "v::s",
5127 long_options, &option_index);
5129 /* Detect the end of the options. */
5130 if (c == -1)
5131 break;
5133 switch (c)
5135 case 'v':
5136 if (optarg)
5137 verbose = (unsigned int) strtoul (optarg, NULL, 0);
5138 else
5139 verbose = 4;
5140 break;
5141 case 's':
5142 verbose = 0;
5143 default:
5144 break;
5151 main (int argc, char *argv[])
5154 parse_options (argc, argv);
5156 initialize ();
5157 printf (TEST_MSG);
5159 basic_tests ();
5161 /* keep the tests a wee bit ordered (according to ISO 9X) */
5162 /* classification functions */
5163 fpclassify_test ();
5164 isfinite_test ();
5165 isnormal_test ();
5166 signbit_test ();
5168 /* trigonometric functions */
5169 acos_test ();
5170 asin_test ();
5171 atan_test ();
5172 atan2_test ();
5173 cos_test ();
5174 sin_test ();
5175 sincos_test ();
5176 tan_test ();
5178 /* hyperbolic functions */
5179 acosh_test ();
5180 asinh_test ();
5181 atanh_test ();
5182 cosh_test ();
5183 sinh_test ();
5184 tanh_test ();
5186 /* exponential and logarithmic functions */
5187 exp_test ();
5188 exp2_test ();
5189 expm1_test ();
5190 frexp_test ();
5191 ldexp_test ();
5192 log_test ();
5193 log10_test ();
5194 log1p_test ();
5195 log2_test ();
5196 logb_test ();
5197 modf_test ();
5198 ilogb_test ();
5199 scalb_test ();
5200 scalbn_test ();
5202 /* power and absolute value functions */
5203 cbrt_test ();
5204 fabs_test ();
5205 hypot_test ();
5206 pow_test ();
5207 sqrt_test ();
5209 /* error and gamma functions */
5210 erf_test ();
5211 erfc_test ();
5212 gamma_test ();
5213 lgamma_test ();
5215 /* nearest integer functions */
5216 ceil_test ();
5217 floor_test ();
5218 nearbyint_test ();
5219 rint_test ();
5220 lrint_test ();
5221 llrint_test ();
5222 round_test ();
5223 lround_test ();
5224 llround_test ();
5225 trunc_test ();
5227 /* remainder functions */
5228 fmod_test ();
5229 remainder_test ();
5230 remquo_test ();
5232 /* manipulation functions */
5233 copysign_test ();
5234 nextafter_test ();
5236 /* maximum, minimum and positive difference functions */
5237 fdim_test ();
5238 fmin_test ();
5239 fmax_test ();
5241 /* complex functions */
5242 cexp_test ();
5243 csin_test ();
5244 csinh_test ();
5245 ccos_test ();
5246 ccosh_test ();
5247 clog_test ();
5248 clog10_test ();
5249 cacos_test ();
5250 cacosh_test ();
5251 casin_test ();
5252 casinh_test ();
5253 catan_test ();
5254 catanh_test ();
5255 ctanh_test ();
5256 csqrt_test ();
5257 cpow_test ();
5258 fma_test ();
5260 /* special tests */
5261 identities ();
5262 inverse_functions ();
5264 if (noErrors)
5266 printf ("\n%d errors occured.\n", noErrors);
5267 exit (1);
5269 printf ("\n All tests passed successfully.\n");
5270 exit (0);