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:
27 FUNC(function): converts general function name (like cos) to
28 name with correct suffix (e.g. cosl or cosf)
29 MATHCONST(x): like FUNC but for constants (e.g convert 0.0 to 0.0L)
30 MATHTYPE: floating point type to test
31 TEST_MSG: informal message to be displayed
32 CHOOSE(Clongdouble,Cdouble,Cfloat):
33 chooses one of the parameters as epsilon for testing
35 PRINTF_EXPR Floating point conversion specification to print a variable
36 of type MATHTYPE with printf. PRINTF_EXPR just contains
37 the specifier, not the percent and width arguments,
39 PRINTF_XEXPR Like PRINTF_EXPR, but print in hexadecimal format.
42 /* This program isn't finished yet.
44 acos, acosh, asin, asinh, atan, atan2, atanh,
45 cbrt, ceil, copysign, cos, cosh, erf, erfc, exp, exp2, expm1,
46 fabs, fdim, floor, fma, fmax, fmin, fmod, fpclassify,
48 ilogb, isfinite, isinf, isnan, isnormal,
49 ldexp, lgamma, log, log10, log1p, log2, logb,
50 modf, nearbyint, nextafter,
51 pow, remainder, remquo, rint, lrint, llrint,
52 round, lround, llround,
53 scalb, scalbn, signbit, sin, sincos, sinh, sqrt, tan, tanh, trunc
55 and for the following complex math functions:
56 cabs, cacos, cacosh, carg, casin, casinh, catan, catanh,
57 ccos, ccosh, cexp, clog, cpow, csin, csinh, csqrt, ctan, ctanh.
59 At the moment the following functions aren't tested:
60 conj, cproj, cimag, creal, drem,
61 j0, j1, jn, y0, y1, yn,
63 nan, comparison macros (isless,isgreater,...).
65 The routines using random variables are still under construction. I don't
66 like it the way it's working now and will change it.
68 Parameter handling is primitive in the moment:
69 --verbose=[0..4] for different levels of output:
71 1: basic report on failed tests (default)
72 2: full report on failed tests
73 3: full report on failed and passed tests
74 4: additional report on exceptions
75 -v for full output (equals --verbose=4)
76 -s,--silent outputs only the error count (equals --verbose=0)
81 This suite tests some aspects of the correct implementation of
82 mathematical functions in libm. Some simple, specific parameters
83 are tested for correctness but there's no exhaustive
84 testing. Handling of specific inputs (e.g. infinity, not-a-number)
85 is also tested. Correct handling of exceptions is checked
86 against. These implemented tests should check all cases that are
87 specified in ISO C 9X.
89 Exception testing: At the moment only divide-by-zero and invalid
90 exceptions are tested. Overflow/underflow and inexact exceptions
91 aren't checked at the moment.
93 NaN values: There exist signalling and quiet NaNs. This implementation
94 only uses signalling NaN as parameter but does not differenciate
95 between the two kinds of NaNs as result.
97 Inline functions: Inlining functions should give an improvement in
98 speed - but not in precission. The inlined functions return
99 reasonable values for a reasonable range of input values. The
100 result is not necessarily correct for all values and exceptions are
101 not correctly raised in all cases. Problematic input and return
102 values are infinity, not-a-number and minus zero. This suite
103 therefore does not check these specific inputs and the exception
104 handling for inlined mathematical functions - just the "reasonable"
107 Beware: The tests might fail for any of the following reasons:
109 - Functions are wrong
110 - Floating Point Unit not working properly
111 - Compiler has errors
113 With e.g. gcc 2.7.2.2 the test for cexp fails because of a compiler error.
131 /* Possible exceptions */
132 #define NO_EXCEPTION 0x0
133 #define INVALID_EXCEPTION 0x1
134 #define DIVIDE_BY_ZERO_EXCEPTION 0x2
139 /* Various constants (we must supply them precalculated for accuracy). */
140 #define M_PI_6 .52359877559829887308L
142 static int noErrors
; /* number of errors */
143 static int noTests
; /* number of tests (without testing exceptions) */
144 static int noExcTests
; /* number of tests for exception flags */
146 static int verbose
= 3;
147 static MATHTYPE minus_zero
, plus_zero
;
148 static MATHTYPE plus_infty
, minus_infty
, nan_value
;
150 typedef MATHTYPE (*mathfunc
) (MATHTYPE
);
152 #define BUILD_COMPLEX(real, imag) \
153 ({ __complex__ MATHTYPE __retval; \
154 __real__ __retval = (real); \
155 __imag__ __retval = (imag); \
160 (sizeof (x) == sizeof (float) ? \
162 : sizeof (x) == sizeof (double) ? \
163 isinf (x) : isinfl (x))
167 Test if Floating-Point stack hasn't changed
170 fpstack_test (const char *test_name
)
173 static int old_stack
;
175 asm ("fnstsw":"=a" (sw
));
180 printf ("FP-Stack wrong after test %s\n", test_name
);
182 printf ("=======> stack = %d\n", sw
);
191 Get a random value x with min_value < x < max_value
192 and min_value, max_value finite,
193 max_value and min_value shouldn't be too close together
196 random_value (MATHTYPE min_value
, MATHTYPE max_value
)
203 x
= (max_value
- min_value
) / RAND_MAX
* (MATHTYPE
) r
+ min_value
;
205 if ((x
<= min_value
) || (x
>= max_value
) || !isfinite (x
))
206 x
= (max_value
- min_value
) / 2 + min_value
;
208 /* Make sure the RNG has no influence on the exceptions. */
209 feclearexcept (FE_ALL_EXCEPT
);
214 /* Get a random value x with x > min_value. */
216 random_greater (MATHTYPE min_value
)
218 return random_value (min_value
, 1e6
); /* CHOOSE (LDBL_MAX, DBL_MAX, FLT_MAX) */
221 /* Get a random value x with x < max_value. */
223 random_less (MATHTYPE max_value
)
225 return random_value (-1e6
, max_value
);
230 output_new_test (const char *test_name
)
233 printf ("\nTesting: %s\n", test_name
);
238 output_pass_value (void)
241 printf ("Pass: Value Ok.\n");
246 output_fail_value (const char * test_name
)
248 if (verbose
> 0 && verbose
< 3)
249 printf ("Fail: %s\n", test_name
);
255 /* Test whether a given exception was raised. */
257 test_single_exception (const char *test_name
,
261 const char *flag_name
)
264 if (exception
& exc_flag
)
266 if (fetestexcept (fe_flag
))
269 printf ("Pass: Exception \"%s\" set\n", flag_name
);
273 if (verbose
&& verbose
< 3)
274 printf ("Fail: %s: Exception \"%s\" not set\n",
275 test_name
, flag_name
);
277 printf ("Fail: Exception \"%s\" not set\n",
284 if (fetestexcept (fe_flag
))
286 if (verbose
&& verbose
< 3)
287 printf ("Fail: %s: Exception \"%s\" set\n",
288 test_name
, flag_name
);
290 printf ("Fail: Exception \"%s\" set\n",
297 printf ("Pass: Exception \"%s\" not set\n",
305 /* Test whether exception given by EXCEPTION are raised. */
307 test_not_exception (const char *test_name
, short int exception
)
311 if ((exception
& DIVIDE_BY_ZERO_EXCEPTION
) == 0)
312 test_single_exception (test_name
, exception
,
313 DIVIDE_BY_ZERO_EXCEPTION
, FE_DIVBYZERO
,
317 if ((exception
& INVALID_EXCEPTION
) == 0)
318 test_single_exception (test_name
, exception
, INVALID_EXCEPTION
, FE_INVALID
,
319 "Invalid operation");
321 feclearexcept (FE_ALL_EXCEPT
);
325 /* Test whether exceptions given by EXCEPTION are raised. */
327 test_exceptions (const char *test_name
, short int exception
)
331 test_single_exception (test_name
, exception
,
332 DIVIDE_BY_ZERO_EXCEPTION
, FE_DIVBYZERO
,
336 test_single_exception (test_name
, exception
, INVALID_EXCEPTION
, FE_INVALID
,
337 "Invalid operation");
339 feclearexcept (FE_ALL_EXCEPT
);
343 /* Test if two floating point numbers are equal. */
345 check_equal (MATHTYPE computed
, MATHTYPE supplied
, MATHTYPE eps
, MATHTYPE
* diff
)
349 /* Both plus Infinity or both minus infinity. */
350 if (ISINF (computed
) && (ISINF (computed
) == ISINF (supplied
)))
353 if (isnan (computed
) && isnan (supplied
)) /* isnan works for all types */
356 *diff
= FUNC(fabs
) (computed
- supplied
);
359 ret_value
= (*diff
<= eps
&&
360 (signbit (computed
) == signbit (supplied
) || eps
!= 0.0));
362 /* Make sure the subtraction/comparsion have no influence on the exceptions. */
363 feclearexcept (FE_ALL_EXCEPT
);
371 output_result_bool (const char *test_name
, int result
)
376 output_pass_value ();
380 output_fail_value (test_name
);
382 printf (" Value: %d\n", result
);
386 fpstack_test (test_name
);
391 output_isvalue (const char *test_name
, int result
,
397 output_pass_value ();
401 output_fail_value (test_name
);
403 printf (" Value: % .20" PRINTF_EXPR
" % .20" PRINTF_XEXPR
"\n",
408 fpstack_test (test_name
);
413 output_isvalue_ext (const char *test_name
, int result
,
414 MATHTYPE value
, MATHTYPE parameter
)
419 output_pass_value ();
423 output_fail_value (test_name
);
426 printf (" Value: % .20" PRINTF_EXPR
" % .20" PRINTF_XEXPR
"\n",
428 printf (" Parameter: % .20" PRINTF_EXPR
" % .20" PRINTF_XEXPR
"\n",
429 parameter
, parameter
);
434 fpstack_test (test_name
);
439 output_result (const char *test_name
, int result
,
440 MATHTYPE computed
, MATHTYPE expected
,
442 int print_values
, int print_diff
)
447 output_pass_value ();
451 output_fail_value (test_name
);
452 if (verbose
> 1 && print_values
)
454 printf ("Result:\n");
455 printf (" is: % .20" PRINTF_EXPR
" % .20" PRINTF_XEXPR
"\n",
457 printf (" should be: % .20" PRINTF_EXPR
" % .20" PRINTF_XEXPR
"\n",
460 printf (" difference: % .20" PRINTF_EXPR
" % .20" PRINTF_XEXPR
461 "\n", difference
, difference
);
466 fpstack_test (test_name
);
471 output_result_ext (const char *test_name
, int result
,
472 MATHTYPE computed
, MATHTYPE expected
,
475 int print_values
, int print_diff
)
480 output_pass_value ();
484 output_fail_value (test_name
);
485 if (verbose
> 1 && print_values
)
487 printf ("Result:\n");
488 printf (" is: % .20" PRINTF_EXPR
" % .20" PRINTF_XEXPR
"\n",
490 printf (" should be: % .20" PRINTF_EXPR
" % .20" PRINTF_XEXPR
"\n",
493 printf (" difference: % .20" PRINTF_EXPR
" % .20" PRINTF_XEXPR
494 "\n", difference
, difference
);
495 printf ("Parameter: % .20" PRINTF_EXPR
" % .20" PRINTF_XEXPR
"\n",
496 parameter
, parameter
);
501 fpstack_test (test_name
);
505 check that computed and expected values are the same
508 check (const char *test_name
, MATHTYPE computed
, MATHTYPE expected
)
513 output_new_test (test_name
);
514 test_exceptions (test_name
, NO_EXCEPTION
);
515 result
= check_equal (computed
, expected
, 0, &diff
);
516 output_result (test_name
, result
,
517 computed
, expected
, diff
, PRINT
, PRINT
);
522 check that computed and expected values are the same,
523 outputs the parameter to the function
526 check_ext (const char *test_name
, MATHTYPE computed
, MATHTYPE expected
,
532 output_new_test (test_name
);
533 test_exceptions (test_name
, NO_EXCEPTION
);
534 result
= check_equal (computed
, expected
, 0, &diff
);
535 output_result_ext (test_name
, result
,
536 computed
, expected
, diff
, parameter
, PRINT
, PRINT
);
541 check that computed and expected values are the same and
542 checks also for exception flags
545 check_exc (const char *test_name
, MATHTYPE computed
, MATHTYPE expected
,
551 output_new_test (test_name
);
552 test_exceptions (test_name
, exception
);
553 result
= check_equal (computed
, expected
, 0, &diff
);
554 output_result (test_name
, result
,
555 computed
, expected
, diff
, PRINT
, PRINT
);
559 check that computed and expected values are close enough
562 check_eps (const char *test_name
, MATHTYPE computed
, MATHTYPE expected
,
568 output_new_test (test_name
);
569 test_exceptions (test_name
, NO_EXCEPTION
);
570 result
= check_equal (computed
, expected
, epsilon
, &diff
);
571 output_result (test_name
, result
,
572 computed
, expected
, diff
, PRINT
, PRINT
);
576 check a boolean condition
579 check_bool (const char *test_name
, int computed
)
581 output_new_test (test_name
);
582 test_exceptions (test_name
, NO_EXCEPTION
);
583 output_result_bool (test_name
, computed
);
589 check that computed and expected values are equal (int values)
592 check_int (const char *test_name
, int computed
, int expected
)
594 int diff
= computed
- expected
;
595 int result
= diff
== 0;
597 output_new_test (test_name
);
598 test_exceptions (test_name
, NO_EXCEPTION
);
602 output_pass_value ();
606 output_fail_value (test_name
);
609 printf ("Result:\n");
610 printf (" is: %d\n", computed
);
611 printf (" should be: %d\n", expected
);
616 fpstack_test (test_name
);
621 check that computed and expected values are equal (long int values)
624 check_long (const char *test_name
, long int computed
, long int expected
)
626 long int diff
= computed
- expected
;
627 int result
= diff
== 0;
630 output_new_test (test_name
);
631 test_exceptions (test_name
, NO_EXCEPTION
);
635 output_pass_value ();
639 output_fail_value (test_name
);
642 printf ("Result:\n");
643 printf (" is: %ld\n", computed
);
644 printf (" should be: %ld\n", expected
);
649 fpstack_test (test_name
);
653 check that computed and expected values are equal (long long int values)
656 check_longlong (const char *test_name
, long long int computed
,
657 long long int expected
)
659 long long int diff
= computed
- expected
;
660 int result
= diff
== 0;
663 output_new_test (test_name
);
664 test_exceptions (test_name
, NO_EXCEPTION
);
668 output_pass_value ();
672 output_fail_value (test_name
);
675 printf ("Result:\n");
676 printf (" is: %lld\n", computed
);
677 printf (" should be: %lld\n", expected
);
682 fpstack_test (test_name
);
686 check that computed value is not-a-number
689 check_isnan (const char *test_name
, MATHTYPE computed
)
691 output_new_test (test_name
);
692 test_exceptions (test_name
, NO_EXCEPTION
);
693 output_isvalue (test_name
, isnan (computed
), computed
);
698 check that computed value is not-a-number and test for exceptions
701 check_isnan_exc (const char *test_name
, MATHTYPE computed
,
704 output_new_test (test_name
);
705 test_exceptions (test_name
, exception
);
706 output_isvalue (test_name
, isnan (computed
), computed
);
711 check that computed value is not-a-number and test for exceptions
714 check_isnan_maybe_exc (const char *test_name
, MATHTYPE computed
,
717 output_new_test (test_name
);
718 test_not_exception (test_name
, exception
);
719 output_isvalue (test_name
, isnan (computed
), computed
);
723 check that computed value is not-a-number and supply parameter
727 check_isnan_ext (const char *test_name
, MATHTYPE computed
,
730 output_new_test (test_name
);
731 test_exceptions (test_name
, NO_EXCEPTION
);
732 output_isvalue_ext (test_name
, isnan (computed
), computed
, parameter
);
737 check that computed value is not-a-number, test for exceptions
741 check_isnan_exc_ext (const char *test_name
, MATHTYPE computed
,
742 short exception
, MATHTYPE parameter
)
744 output_new_test (test_name
);
745 test_exceptions (test_name
,exception
);
746 output_isvalue_ext (test_name
, isnan (computed
), computed
, parameter
);
750 /* Tests if computed is +Inf */
752 check_isinfp (const char *test_name
, MATHTYPE computed
)
754 output_new_test (test_name
);
755 test_exceptions (test_name
, NO_EXCEPTION
);
756 output_isvalue (test_name
, (ISINF (computed
) == +1), computed
);
761 check_isinfp_ext (const char *test_name
, MATHTYPE computed
,
764 output_new_test (test_name
);
765 test_exceptions (test_name
, NO_EXCEPTION
);
766 output_isvalue_ext (test_name
, (ISINF (computed
) == +1), computed
, parameter
);
770 /* Tests if computed is +Inf */
772 check_isinfp_exc (const char *test_name
, MATHTYPE computed
,
775 output_new_test (test_name
);
776 test_exceptions (test_name
, exception
);
777 output_isvalue (test_name
, (ISINF (computed
) == +1), computed
);
780 /* Tests if computed is -Inf */
782 check_isinfn (const char *test_name
, MATHTYPE computed
)
784 output_new_test (test_name
);
785 test_exceptions (test_name
, NO_EXCEPTION
);
786 output_isvalue (test_name
, (ISINF (computed
) == -1), computed
);
792 check_isinfn_ext (const char *test_name
, MATHTYPE computed
,
795 output_new_test (test_name
);
796 test_exceptions (test_name
, NO_EXCEPTION
);
797 output_isvalue_ext (test_name
, (ISINF (computed
) == -1), computed
, parameter
);
802 /* Tests if computed is -Inf */
804 check_isinfn_exc (const char *test_name
, MATHTYPE computed
,
807 output_new_test (test_name
);
808 test_exceptions (test_name
, exception
);
809 output_isvalue (test_name
, (ISINF (computed
) == -1), computed
);
813 /* This is to prevent messages from the SVID libm emulation. */
815 matherr (struct exception
*x
__attribute__ ((unused
)))
821 /****************************************************************************
822 Test for single functions of libm
823 ****************************************************************************/
831 x
= random_greater (1);
832 check_isnan_exc ("acos (x) == NaN plus invalid exception for |x| > 1",
837 check_isnan_exc ("acos (x) == NaN plus invalid exception for |x| > 1",
841 check ("acos (0) == pi/2", FUNC(acos
) (0), M_PI_2
);
842 check ("acos (-0) == pi/2", FUNC(acos
) (minus_zero
), M_PI_2
);
844 check ("acos (1) == 0", FUNC(acos
) (1), 0);
845 check ("acos (-1) == pi", FUNC(acos
) (-1), M_PI
);
847 check_eps ("acos (0.5) == pi/3", FUNC(acos
) (0.5), M_PI_6
* 2.0,
848 CHOOSE (1e-18, 0, 0));
849 check_eps ("acos (-0.5) == 2*pi/3", FUNC(acos
) (-0.5), M_PI_6
* 4.0,
850 CHOOSE (1e-17, 0, 0));
852 check_eps ("acos (0.7) == 0.795398830...", FUNC(acos
) (0.7),
853 0.7953988301841435554L, CHOOSE(7e-17L, 0, 0));
864 check_isinfp ("acosh(+inf) == +inf", FUNC(acosh
) (plus_infty
));
867 check_isnan_exc ("acosh(x) == NaN plus invalid exception if x < 1",
868 FUNC(acosh
) (x
), INVALID_EXCEPTION
);
871 check ("acosh(1) == 0", FUNC(acosh
) (1), 0);
872 check ("acosh(7) == 2.633915793...", FUNC(acosh
) (7),
873 2.6339157938496334172L);
883 x
= random_greater (1);
884 check_isnan_exc ("asin x == NaN plus invalid exception for |x| > 1",
889 check_isnan_exc ("asin x == NaN plus invalid exception for |x| > 1",
894 check ("asin (0) == 0", FUNC(asin
) (0), 0);
895 check ("asin (-0) == -0", FUNC(asin
) (minus_zero
), minus_zero
);
896 check_eps ("asin (0.5) == pi/6", FUNC(asin
) (0.5), M_PI_6
,
897 CHOOSE(3.5e-18, 0, 2e-7));
898 check_eps ("asin (-0.5) == -pi/6", FUNC(asin
) (-0.5), -M_PI_6
,
899 CHOOSE(3.5e-18, 0, 2e-7));
900 check ("asin (1.0) == pi/2", FUNC(asin
) (1.0), M_PI_2
);
901 check ("asin (-1.0) == -pi/2", FUNC(asin
) (-1.0), -M_PI_2
);
902 check_eps ("asin (0.7) == 0.775397496...", FUNC(asin
) (0.7),
903 0.7753974966107530637L, CHOOSE(7e-17L, 2e-16, 0));
911 check ("asinh(+0) == +0", FUNC(asinh
) (0), 0);
913 check ("asinh(-0) == -0", FUNC(asinh
) (minus_zero
), minus_zero
);
914 check_isinfp ("asinh(+inf) == +inf", FUNC(asinh
) (plus_infty
));
915 check_isinfn ("asinh(-inf) == -inf", FUNC(asinh
) (minus_infty
));
917 check_eps ("asinh(0.7) == 0.652666566...", FUNC(asinh
) (0.7),
918 0.652666566082355786L, CHOOSE(4e-17L, 0, 0));
926 check ("atan (0) == 0", FUNC(atan
) (0), 0);
927 check ("atan (-0) == -0", FUNC(atan
) (minus_zero
), minus_zero
);
929 check ("atan (+inf) == pi/2", FUNC(atan
) (plus_infty
), M_PI_2
);
930 check ("atan (-inf) == -pi/2", FUNC(atan
) (minus_infty
), -M_PI_2
);
932 check_eps ("atan (1) == pi/4", FUNC(atan
) (1), M_PI_4
,
933 CHOOSE (1e-18, 0, 0));
934 check_eps ("atan (-1) == -pi/4", FUNC(atan
) (1), M_PI_4
,
935 CHOOSE (1e-18, 0, 0));
937 check_eps ("atan (0.7) == 0.610725964...", FUNC(atan
) (0.7),
938 0.6107259643892086165L, CHOOSE(3e-17L, 0, 0));
947 x
= random_greater (0);
948 check ("atan2 (0,x) == 0 for x > 0",
949 FUNC(atan2
) (0, x
), 0);
950 x
= random_greater (0);
951 check ("atan2 (-0,x) == -0 for x > 0",
952 FUNC(atan2
) (minus_zero
, x
), minus_zero
);
954 check ("atan2 (+0,+0) == +0", FUNC(atan2
) (0, 0), 0);
955 check ("atan2 (-0,+0) == -0", FUNC(atan2
) (minus_zero
, 0), minus_zero
);
957 x
= -random_greater (0);
958 check ("atan2 (+0,x) == +pi for x < 0", FUNC(atan2
) (0, x
), M_PI
);
960 x
= -random_greater (0);
961 check ("atan2 (-0,x) == -pi for x < 0", FUNC(atan2
) (minus_zero
, x
), -M_PI
);
963 check ("atan2 (+0,-0) == +pi", FUNC(atan2
) (0, minus_zero
), M_PI
);
964 check ("atan2 (-0,-0) == -pi", FUNC(atan2
) (minus_zero
, minus_zero
), -M_PI
);
966 x
= random_greater (0);
967 check ("atan2 (y,+0) == pi/2 for y > 0", FUNC(atan2
) (x
, 0), M_PI_2
);
969 x
= random_greater (0);
970 check ("atan2 (y,-0) == pi/2 for y > 0", FUNC(atan2
) (x
, minus_zero
), M_PI_2
);
973 check ("atan2 (y,+0) == -pi/2 for y < 0", FUNC(atan2
) (x
, 0), -M_PI_2
);
976 check ("atan2 (y,-0) == -pi/2 for y < 0", FUNC(atan2
) (x
, minus_zero
), -M_PI_2
);
978 x
= random_greater (0);
979 check ("atan2 (y,inf) == +0 for finite y > 0",
980 FUNC(atan2
) (x
, plus_infty
), 0);
982 x
= -random_greater (0);
983 check ("atan2 (y,inf) == -0 for finite y < 0",
984 FUNC(atan2
) (x
, plus_infty
), minus_zero
);
986 x
= random_value (-1e4
, 1e4
);
987 check ("atan2(+inf, x) == pi/2 for finite x",
988 FUNC(atan2
) (plus_infty
, x
), M_PI_2
);
990 x
= random_value (-1e4
, 1e4
);
991 check ("atan2(-inf, x) == -pi/2 for finite x",
992 FUNC(atan2
) (minus_infty
, x
), -M_PI_2
);
994 x
= random_greater (0);
995 check ("atan2 (y,-inf) == +pi for finite y > 0",
996 FUNC(atan2
) (x
, minus_infty
), M_PI
);
998 x
= -random_greater (0);
999 check ("atan2 (y,-inf) == -pi for finite y < 0",
1000 FUNC(atan2
) (x
, minus_infty
), -M_PI
);
1002 check ("atan2 (+inf,+inf) == +pi/4",
1003 FUNC(atan2
) (plus_infty
, plus_infty
), M_PI_4
);
1005 check ("atan2 (-inf,+inf) == -pi/4",
1006 FUNC(atan2
) (minus_infty
, plus_infty
), -M_PI_4
);
1008 check ("atan2 (+inf,-inf) == +3*pi/4",
1009 FUNC(atan2
) (plus_infty
, minus_infty
), 3 * M_PI_4
);
1011 check ("atan2 (-inf,-inf) == -3*pi/4",
1012 FUNC(atan2
) (minus_infty
, minus_infty
), -3 * M_PI_4
);
1014 /* FIXME: Add some specific tests */
1015 check_eps ("atan2 (0.7,1) == 0.61072...", FUNC(atan2
) (0.7,1),
1016 0.6107259643892086165L, CHOOSE(3e-17L, 0, 0));
1017 check_eps ("atan2 (0.4,0.0003) == 1.57004...", FUNC(atan2
) (0.4, 0.0003),
1018 1.5700463269355215718L, CHOOSE(2e-19L, 0, 0));
1030 check ("atanh(+0) == +0", FUNC(atanh
) (0), 0);
1032 check ("atanh(-0) == -0", FUNC(atanh
) (minus_zero
), minus_zero
);
1034 check_isinfp_exc ("atanh(+1) == +inf plus divide-by-zero exception",
1035 FUNC(atanh
) (1), DIVIDE_BY_ZERO_EXCEPTION
);
1036 check_isinfn_exc ("atanh(-1) == -inf plus divide-by-zero exception",
1037 FUNC(atanh
) (-1), DIVIDE_BY_ZERO_EXCEPTION
);
1039 x
= random_greater (1.0);
1040 check_isnan_exc_ext ("atanh (x) == NaN plus invalid exception if |x| > 1",
1041 FUNC(atanh
) (x
), INVALID_EXCEPTION
, x
);
1043 x
= random_less (1.0);
1044 check_isnan_exc_ext ("atanh (x) == NaN plus invalid exception if |x| > 1",
1045 FUNC(atanh
) (x
), INVALID_EXCEPTION
, x
);
1048 check_eps ("atanh(0.7) == 0.867300527...", FUNC(atanh
) (0.7),
1049 0.8673005276940531944L, CHOOSE(9e-17L, 2e-16, 0));
1056 check ("cbrt (+0) == +0", FUNC(cbrt
) (0.0), 0.0);
1057 check ("cbrt (-0) == -0", FUNC(cbrt
) (minus_zero
), minus_zero
);
1060 check_isinfp ("cbrt (+inf) == +inf", FUNC(cbrt
) (plus_infty
));
1061 check_isinfn ("cbrt (-inf) == -inf", FUNC(cbrt
) (minus_infty
));
1062 check_isnan ("cbrt (NaN) == NaN", FUNC(cbrt
) (nan_value
));
1064 check_eps ("cbrt (-0.001) == -0.1", FUNC(cbrt
) (-0.001), -0.1,
1065 CHOOSE (5e-18L, 0, 0));
1066 check_eps ("cbrt (8) == 2", FUNC(cbrt
) (8), 2, CHOOSE (5e-17L, 0, 0));
1067 check_eps ("cbrt (-27) == -3", FUNC(cbrt
) (-27.0), -3.0,
1068 CHOOSE (3e-16L, 5e-16, 0));
1069 check_eps ("cbrt (0.970299) == 0.99", FUNC(cbrt
) (0.970299), 0.99,
1070 CHOOSE (2e-17L, 0, 0));
1071 check_eps ("cbrt (0.7) == .8879040017...", FUNC(cbrt
) (0.7),
1072 0.8879040017426007084L, CHOOSE(2e-17L, 2e-16, 0));
1080 check ("ceil (+0) == +0", FUNC(ceil
) (0.0), 0.0);
1081 check ("ceil (-0) == -0", FUNC(ceil
) (minus_zero
), minus_zero
);
1082 check_isinfp ("ceil (+inf) == +inf", FUNC(ceil
) (plus_infty
));
1083 check_isinfn ("ceil (-inf) == -inf", FUNC(ceil
) (minus_infty
));
1085 check ("ceil (pi) == 4", FUNC(ceil
) (M_PI
), 4.0);
1086 check ("ceil (-pi) == -3", FUNC(ceil
) (-M_PI
), -3.0);
1094 check ("cos (+0) == 1", FUNC(cos
) (0), 1);
1095 check ("cos (-0) == 1", FUNC(cos
) (minus_zero
), 1);
1096 check_isnan_exc ("cos (+inf) == NaN plus invalid exception",
1097 FUNC(cos
) (plus_infty
),
1099 check_isnan_exc ("cos (-inf) == NaN plus invalid exception",
1100 FUNC(cos
) (minus_infty
),
1103 check_eps ("cos (pi/3) == 0.5", FUNC(cos
) (M_PI_6
* 2.0),
1104 0.5, CHOOSE (4e-18L, 1e-15L, 1e-7L));
1105 check_eps ("cos (2*pi/3) == -0.5", FUNC(cos
) (M_PI_6
* 4.0),
1106 -0.5, CHOOSE (4e-18L, 1e-15L, 1e-7L));
1107 check_eps ("cos (pi/2) == 0", FUNC(cos
) (M_PI_2
),
1108 0, CHOOSE (1e-19L, 1e-16L, 1e-7L));
1110 check_eps ("cos (0.7) == 0.7648421872...", FUNC(cos
) (0.7),
1111 0.7648421872844884262L, CHOOSE(3e-17, 2e-16, 0));
1117 check ("cosh (+0) == 1", FUNC(cosh
) (0), 1);
1118 check ("cosh (-0) == 1", FUNC(cosh
) (minus_zero
), 1);
1121 check_isinfp ("cosh (+inf) == +inf", FUNC(cosh
) (plus_infty
));
1122 check_isinfp ("cosh (-inf) == +inf", FUNC(cosh
) (minus_infty
));
1125 check_eps ("cosh (0.7) == 1.2551690056...", FUNC(cosh
) (0.7),
1126 1.255169005630943018L, CHOOSE(4e-17L, 0, 0));
1135 if (errno
== ENOSYS
)
1136 /* Function not implemented. */
1139 check ("erf (+0) == +0", FUNC(erf
) (0), 0);
1140 check ("erf (-0) == -0", FUNC(erf
) (minus_zero
), minus_zero
);
1141 check ("erf (+inf) == +1", FUNC(erf
) (plus_infty
), 1);
1142 check ("erf (-inf) == -1", FUNC(erf
) (minus_infty
), -1);
1144 check_eps ("erf (0.7) == 0.6778011938...", FUNC(erf
) (0.7),
1145 0.67780119383741847297L, CHOOSE(0, 2e-16, 0));
1154 if (errno
== ENOSYS
)
1155 /* Function not implemented. */
1158 check ("erfc (+inf) == 0", FUNC(erfc
) (plus_infty
), 0.0);
1159 check ("erfc (-inf) == 2", FUNC(erfc
) (minus_infty
), 2.0);
1160 check ("erfc (+0) == 1", FUNC(erfc
) (0.0), 1.0);
1161 check ("erfc (-0) == 1", FUNC(erfc
) (minus_zero
), 1.0);
1163 check_eps ("erfc (0.7) == 0.3221988061...", FUNC(erfc
) (0.7),
1164 0.32219880616258152702L, CHOOSE(0, 6e-17, 0));
1171 check ("exp (+0) == 1", FUNC(exp
) (0), 1);
1172 check ("exp (-0) == 1", FUNC(exp
) (minus_zero
), 1);
1175 check_isinfp ("exp (+inf) == +inf", FUNC(exp
) (plus_infty
));
1176 check ("exp (-inf) == 0", FUNC(exp
) (minus_infty
), 0);
1178 check_eps ("exp (1) == e", FUNC(exp
) (1), M_E
, CHOOSE (4e-18L, 5e-16, 0));
1180 check_eps ("exp (2) == e^2", FUNC(exp
) (2), M_E
* M_E
,
1181 CHOOSE (1e-18, 0, 0));
1182 check_eps ("exp (3) == e^3", FUNC(exp
) (3), M_E
* M_E
* M_E
,
1183 CHOOSE (1.5e-17, 0, 0));
1184 check_eps ("exp (0.7) == 2.0137527074...", FUNC(exp
) (0.7),
1185 2.0137527074704765216L, CHOOSE(9e-17L, 0, 0));
1194 if (errno
== ENOSYS
)
1195 /* Function not implemented. */
1198 check ("exp2 (+0) == 1", FUNC(exp2
) (0), 1);
1199 check ("exp2 (-0) == 1", FUNC(exp2
) (minus_zero
), 1);
1201 check_isinfp ("exp2 (+inf) == +inf", FUNC(exp2
) (plus_infty
));
1202 check ("exp2 (-inf) == 0", FUNC(exp2
) (minus_infty
), 0);
1203 check ("exp2 (10) == 1024", FUNC(exp2
) (10), 1024);
1204 check ("exp2 (-1) == 0.5", FUNC(exp2
) (-1), 0.5);
1205 check_isinfp ("exp2 (1e6) == +inf", FUNC(exp2
) (1e6
));
1206 check ("exp2 (-1e6) == 0", FUNC(exp2
) (-1e6
), 0);
1207 check_eps ("exp2 (0.7) == 1.6245047927...", FUNC(exp2
) (0.7),
1208 1.6245047927124710452L, CHOOSE(6e-17L, 0, 6e-8));
1215 check ("expm1 (+0) == 0", FUNC(expm1
) (0), 0);
1217 check ("expm1 (-0) == -0", FUNC(expm1
) (minus_zero
), minus_zero
);
1219 check_isinfp ("expm1 (+inf) == +inf", FUNC(expm1
) (plus_infty
));
1220 check ("expm1 (-inf) == -1", FUNC(expm1
) (minus_infty
), -1);
1223 check_eps ("expm1 (1) == e-1", FUNC(expm1
) (1), M_E
- 1.0,
1224 CHOOSE (4e-18L, 0, 2e-7));
1226 check_eps ("expm1 (0.7) == 1.01375...", FUNC(expm1
) (0.7),
1227 1.0137527074704765216L, CHOOSE(9e-17L, 0, 0));
1234 check_frexp (const char *test_name
, MATHTYPE computed
, MATHTYPE expected
,
1235 int comp_int
, int exp_int
)
1240 result
= (check_equal (computed
, expected
, 0, &diff
)
1241 && (comp_int
== exp_int
));
1246 printf ("Pass: %s\n", test_name
);
1251 printf ("Fail: %s\n", test_name
);
1254 printf ("Result:\n");
1255 printf (" is: %.20" PRINTF_EXPR
" *2^%d %.20"
1256 PRINTF_XEXPR
"*2^%d\n",
1257 computed
, comp_int
, computed
, comp_int
);
1258 printf (" should be: %.20" PRINTF_EXPR
" *2^%d %.20"
1259 PRINTF_XEXPR
"*2^%d\n",
1260 expected
, exp_int
, expected
, exp_int
);
1261 printf (" difference: %.20" PRINTF_EXPR
" %.20" PRINTF_XEXPR
"\n",
1266 fpstack_test (test_name
);
1267 output_result (test_name
, result
,
1268 computed
, expected
, diff
, PRINT
, PRINT
);
1278 result
= FUNC(frexp
) (plus_infty
, &x_int
);
1279 check_isinfp ("frexp (+inf, expr) == +inf", result
);
1281 result
= FUNC(frexp
) (minus_infty
, &x_int
);
1282 check_isinfn ("frexp (-inf, expr) == -inf", result
);
1284 result
= FUNC(frexp
) (nan_value
, &x_int
);
1285 check_isnan ("frexp (Nan, expr) == NaN", result
);
1287 result
= FUNC(frexp
) (0, &x_int
);
1288 check_frexp ("frexp: +0 == 0 * 2^0", result
, 0, x_int
, 0);
1290 result
= FUNC(frexp
) (minus_zero
, &x_int
);
1291 check_frexp ("frexp: -0 == -0 * 2^0", result
, minus_zero
, x_int
, 0);
1293 result
= FUNC(frexp
) (12.8L, &x_int
);
1294 check_frexp ("frexp: 12.8 == 0.8 * 2^4", result
, 0.8L, x_int
, 4);
1296 result
= FUNC(frexp
) (-27.34L, &x_int
);
1297 check_frexp ("frexp: -27.34 == -0.854375 * 2^5", result
, -0.854375L, x_int
, 5);
1302 #if __GLIBC__ < 2 || (__GLIBC__ == 2 && __GLIBC_MINOR__ < 1)
1303 /* All floating-point numbers can be put in one of these categories. */
1307 #define FP_NAN FP_NAN
1309 #define FP_INFINITE FP_INFINITE
1311 #define FP_ZERO FP_ZERO
1313 #define FP_SUBNORMAL FP_SUBNORMAL
1315 #define FP_NORMAL FP_NORMAL
1321 fpclassify_test (void)
1325 /* fpclassify is a macro, don't give it constants as parameter */
1326 check_bool ("fpclassify (NaN) == FP_NAN", fpclassify (nan_value
) == FP_NAN
);
1327 check_bool ("fpclassify (+inf) == FP_INFINITE",
1328 fpclassify (plus_infty
) == FP_INFINITE
);
1329 check_bool ("fpclassify (-inf) == FP_INFINITE",
1330 fpclassify (minus_infty
) == FP_INFINITE
);
1331 check_bool ("fpclassify (+0) == FP_ZERO",
1332 fpclassify (plus_zero
) == FP_ZERO
);
1333 check_bool ("fpclassify (-0) == FP_ZERO",
1334 fpclassify (minus_zero
) == FP_ZERO
);
1337 check_bool ("fpclassify (1000) == FP_NORMAL",
1338 fpclassify (x
) == FP_NORMAL
);
1343 isfinite_test (void)
1345 check_bool ("isfinite (0) != 0", isfinite (0));
1346 check_bool ("isfinite (-0) != 0", isfinite (minus_zero
));
1347 check_bool ("isfinite (10) != 0", isfinite (10));
1348 check_bool ("isfinite (+inf) == 0", isfinite (plus_infty
) == 0);
1349 check_bool ("isfinite (-inf) == 0", isfinite (minus_infty
) == 0);
1350 check_bool ("isfinite (NaN) == 0", isfinite (nan_value
) == 0);
1355 isnormal_test (void)
1357 check_bool ("isnormal (0) == 0", isnormal (0) == 0);
1358 check_bool ("isnormal (-0) == 0", isnormal (minus_zero
) == 0);
1359 check_bool ("isnormal (10) != 0", isnormal (10));
1360 check_bool ("isnormal (+inf) == 0", isnormal (plus_infty
) == 0);
1361 check_bool ("isnormal (-inf) == 0", isnormal (minus_infty
) == 0);
1362 check_bool ("isnormal (NaN) == 0", isnormal (nan_value
) == 0);
1372 check_bool ("signbit (+0) == 0", signbit (0) == 0);
1373 check_bool ("signbit (-0) != 0", signbit (minus_zero
));
1374 check_bool ("signbit (+inf) == 0", signbit (plus_infty
) == 0);
1375 check_bool ("signbit (-inf) != 0", signbit (minus_infty
));
1377 x
= random_less (0);
1378 check_bool ("signbit (x) != 0 for x < 0", signbit (x
));
1380 x
= random_greater (0);
1381 check_bool ("signbit (x) == 0 for x > 0", signbit (x
) == 0);
1387 gamma has different semantics depending on _LIB_VERSION:
1388 if _LIB_VERSION is _SVID, gamma is just an alias for lgamma,
1389 otherwise gamma is the real gamma function as definied in ISO C 9X.
1394 int save_lib_version
= _LIB_VERSION
;
1397 if (errno
== ENOSYS
)
1398 /* Function not implemented. */
1400 feclearexcept (FE_ALL_EXCEPT
);
1403 _LIB_VERSION
= _SVID_
;
1405 check_isinfp ("gamma (+inf) == +inf", FUNC(gamma
) (plus_infty
));
1406 check_isinfp_exc ("gamma (0) == +inf plus divide by zero exception",
1407 FUNC(gamma
) (0), DIVIDE_BY_ZERO_EXCEPTION
);
1409 check_isinfp_exc ("gamma (x) == +inf plus divide by zero exception for integer x <= 0",
1410 FUNC(gamma
) (-3), DIVIDE_BY_ZERO_EXCEPTION
);
1411 check_isnan_exc ("gamma (-inf) == NaN plus invalid exception",
1412 FUNC(gamma
) (minus_infty
), INVALID_EXCEPTION
);
1415 check ("gamma (1) == 0", FUNC(gamma
) (1), 0);
1416 check_int ("gamma (0) sets signgam to 1", signgam
, 1);
1419 check ("gamma (3) == M_LN2", FUNC(gamma
) (3), M_LN2
);
1420 check_int ("gamma (3) sets signgam to 1", signgam
, 1);
1423 check_eps ("gamma (0.5) == log(sqrt(pi))", FUNC(gamma
) (0.5),
1424 FUNC(log
) (FUNC(sqrt
) (M_PI
)), CHOOSE (0, 1e-15, 1e-7));
1425 check_int ("gamma (0.5) sets signgam to 1", signgam
, 1);
1428 check_eps ("gamma (-0.5) == log(2*sqrt(pi))", FUNC(gamma
) (-0.5),
1429 FUNC(log
) (2*FUNC(sqrt
) (M_PI
)), CHOOSE (0, 1e-15, 0));
1431 check_int ("gamma (-0.5) sets signgam to -1", signgam
, -1);
1434 _LIB_VERSION
= _IEEE_
;
1436 check_isinfp ("gamma (+inf) == +inf", FUNC(gamma
) (plus_infty
));
1437 check_isnan_exc ("gamma (0) == NaN plus invalid exception",
1438 FUNC(gamma
) (0), INVALID_EXCEPTION
);
1440 check_isnan_exc_ext ("gamma (x) == NaN plus invalid exception for integer x <= 0",
1441 FUNC(gamma
) (-2), INVALID_EXCEPTION
, -2);
1442 check_isnan_exc ("gamma (-inf) == NaN plus invalid exception",
1443 FUNC(gamma
) (minus_infty
), INVALID_EXCEPTION
);
1446 check_eps ("gamma (0.5) == sqrt(pi)", FUNC(gamma
) (0.5), FUNC(sqrt
) (M_PI
),
1447 CHOOSE (0, 5e-16, 2e-7));
1449 check_eps ("gamma (-0.5) == -2*sqrt(pi)", FUNC(gamma
) (-0.5),
1450 -2*FUNC(sqrt
) (M_PI
), CHOOSE (0, 5e-16, 3e-7));
1452 check ("gamma (1) == 1", FUNC(gamma
) (1), 1);
1453 check ("gamma (4) == 6", FUNC(gamma
) (4), 6);
1455 check_eps ("gamma (0.7) == 1.29805...", FUNC(gamma
) (0.7),
1456 1.29805533264755778568L, CHOOSE(0, 3e-16, 2e-7));
1457 check ("gamma (1.2) == 0.91816...", FUNC(gamma
) (1.2), 0.91816874239976061064L);
1459 _LIB_VERSION
= save_lib_version
;
1468 if (errno
== ENOSYS
)
1469 /* Function not implemented. */
1471 feclearexcept (FE_ALL_EXCEPT
);
1473 check_isinfp ("lgamma (+inf) == +inf", FUNC(lgamma
) (plus_infty
));
1474 check_isinfp_exc ("lgamma (0) == +inf plus divide by zero exception",
1475 FUNC(lgamma
) (0), DIVIDE_BY_ZERO_EXCEPTION
);
1477 check_isinfp_exc ("lgamma (x) == +inf plus divide by zero exception for integer x <= 0",
1478 FUNC(lgamma
) (-3), DIVIDE_BY_ZERO_EXCEPTION
);
1479 check_isnan_exc ("lgamma (-inf) == NaN plus invalid exception",
1480 FUNC(lgamma
) (minus_infty
), INVALID_EXCEPTION
);
1483 check ("lgamma (1) == 0", FUNC(lgamma
) (1), 0);
1484 check_int ("lgamma (0) sets signgam to 1", signgam
, 1);
1487 check ("lgamma (3) == M_LN2", FUNC(lgamma
) (3), M_LN2
);
1488 check_int ("lgamma (3) sets signgam to 1", signgam
, 1);
1491 check_eps ("lgamma (0.5) == log(sqrt(pi))", FUNC(lgamma
) (0.5),
1492 FUNC(log
) (FUNC(sqrt
) (M_PI
)), CHOOSE (0, 1e-15, 1e-7));
1493 check_int ("lgamma (0.5) sets signgam to 1", signgam
, 1);
1496 check_eps ("lgamma (-0.5) == log(2*sqrt(pi))", FUNC(lgamma
) (-0.5),
1497 FUNC(log
) (2*FUNC(sqrt
) (M_PI
)), CHOOSE (0, 1e-15, 0));
1499 check_int ("lgamma (-0.5) sets signgam to -1", signgam
, -1);
1502 check_eps ("lgamma (0.7) == 0.26086...", FUNC(lgamma
) (0.7),
1503 0.26086724653166651439L, CHOOSE(0, 6e-17, 3e-8));
1504 check_int ("lgamma (0.7) sets signgam to 1", signgam
, 1);
1507 check_eps ("lgamma (1.2) == -0.08537...", FUNC(lgamma
) (1.2),
1508 -0.853740900033158497197e-1L, CHOOSE(0, 2e-17, 2e-8));
1509 check_int ("lgamma (1.2) sets signgam to 1", signgam
, 1);
1519 check_int ("ilogb (1) == 0", FUNC(ilogb
) (1), 0);
1520 check_int ("ilogb (e) == 1", FUNC(ilogb
) (M_E
), 1);
1521 check_int ("ilogb (1024) == 10", FUNC(ilogb
) (1024), 10);
1522 check_int ("ilogb (-2000) == 10", FUNC(ilogb
) (-2000), 10);
1524 /* XXX We have a problem here: the standard does not tell us whether
1525 exceptions are allowed/required. ignore them for now. */
1526 i
= FUNC (ilogb
) (0.0);
1527 feclearexcept (FE_ALL_EXCEPT
);
1528 check_int ("ilogb (0) == FP_ILOGB0", i
, FP_ILOGB0
);
1529 i
= FUNC(ilogb
) (nan_value
);
1530 feclearexcept (FE_ALL_EXCEPT
);
1531 check_int ("ilogb (NaN) == FP_ILOGBNAN", i
, FP_ILOGBNAN
);
1541 check ("ldexp (0, 0) == 0", FUNC(ldexp
) (0, 0), 0);
1543 check_isinfp ("ldexp (+inf, 1) == +inf", FUNC(ldexp
) (plus_infty
, 1));
1544 check_isinfn ("ldexp (-inf, 1) == -inf", FUNC(ldexp
) (minus_infty
, 1));
1545 check_isnan ("ldexp (NaN, 1) == NaN", FUNC(ldexp
) (nan_value
, 1));
1547 check ("ldexp (0.8, 4) == 12.8", FUNC(ldexp
) (0.8L, 4), 12.8L);
1548 check ("ldexp (-0.854375, 5) == -27.34", FUNC(ldexp
) (-0.854375L, 5), -27.34L);
1550 x
= random_greater (0.0);
1551 check_ext ("ldexp (x, 0) == x", FUNC(ldexp
) (x
, 0L), x
, x
);
1559 check_isinfn_exc ("log (+0) == -inf plus divide-by-zero exception",
1560 FUNC(log
) (0), DIVIDE_BY_ZERO_EXCEPTION
);
1561 check_isinfn_exc ("log (-0) == -inf plus divide-by-zero exception",
1562 FUNC(log
) (minus_zero
), DIVIDE_BY_ZERO_EXCEPTION
);
1564 check ("log (1) == 0", FUNC(log
) (1), 0);
1566 check_isnan_exc ("log (x) == NaN plus invalid exception if x < 0",
1567 FUNC(log
) (-1), INVALID_EXCEPTION
);
1568 check_isinfp ("log (+inf) == +inf", FUNC(log
) (plus_infty
));
1570 check_eps ("log (e) == 1", FUNC(log
) (M_E
), 1, CHOOSE (1e-18L, 0, 9e-8L));
1571 check_eps ("log (1/e) == -1", FUNC(log
) (1.0 / M_E
), -1,
1572 CHOOSE (2e-18L, 0, 0));
1573 check ("log (2) == M_LN2", FUNC(log
) (2), M_LN2
);
1574 check_eps ("log (10) == M_LN10", FUNC(log
) (10), M_LN10
,
1575 CHOOSE (1e-18L, 0, 0));
1576 check_eps ("log (0.7) == -0.3566749439...", FUNC(log
) (0.7),
1577 -0.35667494393873237891L, CHOOSE(7e-17L, 6e-17, 3e-8));
1584 check_isinfn_exc ("log10 (+0) == -inf plus divide-by-zero exception",
1585 FUNC(log10
) (0), DIVIDE_BY_ZERO_EXCEPTION
);
1586 check_isinfn_exc ("log10 (-0) == -inf plus divide-by-zero exception",
1587 FUNC(log10
) (minus_zero
), DIVIDE_BY_ZERO_EXCEPTION
);
1589 check ("log10 (1) == +0", FUNC(log10
) (1), 0);
1591 check_isnan_exc ("log10 (x) == NaN plus invalid exception if x < 0",
1592 FUNC(log10
) (-1), INVALID_EXCEPTION
);
1594 check_isinfp ("log10 (+inf) == +inf", FUNC(log10
) (plus_infty
));
1596 check_eps ("log10 (0.1) == -1", FUNC(log10
) (0.1L), -1,
1597 CHOOSE (1e-18L, 0, 0));
1598 check_eps ("log10 (10) == 1", FUNC(log10
) (10.0), 1,
1599 CHOOSE (1e-18L, 0, 0));
1600 check_eps ("log10 (100) == 2", FUNC(log10
) (100.0), 2,
1601 CHOOSE (1e-18L, 0, 0));
1602 check ("log10 (10000) == 4", FUNC(log10
) (10000.0), 4);
1603 check_eps ("log10 (e) == M_LOG10E", FUNC(log10
) (M_E
), M_LOG10E
,
1604 CHOOSE (1e-18, 0, 9e-8));
1605 check_eps ("log10 (0.7) == -0.1549019599...", FUNC(log10
) (0.7),
1606 -0.15490195998574316929L, CHOOSE(3e-17L, 3e-17, 0));
1613 check ("log1p (+0) == +0", FUNC(log1p
) (0), 0);
1614 check ("log1p (-0) == -0", FUNC(log1p
) (minus_zero
), minus_zero
);
1616 check_isinfn_exc ("log1p (-1) == -inf plus divide-by-zero exception",
1617 FUNC(log1p
) (-1), DIVIDE_BY_ZERO_EXCEPTION
);
1618 check_isnan_exc ("log1p (x) == NaN plus invalid exception if x < -1",
1619 FUNC(log1p
) (-2), INVALID_EXCEPTION
);
1621 check_isinfp ("log1p (+inf) == +inf", FUNC(log1p
) (plus_infty
));
1623 check_eps ("log1p (e-1) == 1", FUNC(log1p
) (M_E
- 1.0), 1,
1624 CHOOSE (1e-18L, 0, 6e-8));
1626 check_eps ("log1p (-0.3) == -0.35667...", FUNC(log1p
) (-0.3),
1627 -0.35667494393873237891L, CHOOSE(2e-17L, 6e-17, 3e-8));
1634 check_isinfn_exc ("log2 (+0) == -inf plus divide-by-zero exception",
1635 FUNC(log2
) (0), DIVIDE_BY_ZERO_EXCEPTION
);
1636 check_isinfn_exc ("log2 (-0) == -inf plus divide-by-zero exception",
1637 FUNC(log2
) (minus_zero
), DIVIDE_BY_ZERO_EXCEPTION
);
1639 check ("log2 (1) == +0", FUNC(log2
) (1), 0);
1641 check_isnan_exc ("log2 (x) == NaN plus invalid exception if x < 0",
1642 FUNC(log2
) (-1), INVALID_EXCEPTION
);
1644 check_isinfp ("log2 (+inf) == +inf", FUNC(log2
) (plus_infty
));
1646 check_eps ("log2 (e) == M_LOG2E", FUNC(log2
) (M_E
), M_LOG2E
,
1647 CHOOSE (1e-18L, 0, 0));
1648 check ("log2 (2) == 1", FUNC(log2
) (2.0), 1);
1649 check_eps ("log2 (16) == 4", FUNC(log2
) (16.0), 4, CHOOSE (1e-18L, 0, 0));
1650 check ("log2 (256) == 8", FUNC(log2
) (256.0), 8);
1651 check_eps ("log2 (0.7) == -0.5145731728...", FUNC(log2
) (0.7),
1652 -0.51457317282975824043L, CHOOSE(1e-16L, 2e-16, 6e-8));
1660 check_isinfp ("logb (+inf) == +inf", FUNC(logb
) (plus_infty
));
1661 check_isinfp ("logb (-inf) == +inf", FUNC(logb
) (minus_infty
));
1663 check_isinfn_exc ("logb (+0) == -inf plus divide-by-zero exception",
1664 FUNC(logb
) (0), DIVIDE_BY_ZERO_EXCEPTION
);
1666 check_isinfn_exc ("logb (-0) == -inf plus divide-by-zero exception",
1667 FUNC(logb
) (minus_zero
), DIVIDE_BY_ZERO_EXCEPTION
);
1669 check ("logb (1) == 0", FUNC(logb
) (1), 0);
1670 check ("logb (e) == 1", FUNC(logb
) (M_E
), 1);
1671 check ("logb (1024) == 10", FUNC(logb
) (1024), 10);
1672 check ("logb (-2000) == 10", FUNC(logb
) (-2000), 10);
1680 MATHTYPE result
, intpart
;
1682 result
= FUNC(modf
) (plus_infty
, &intpart
);
1683 check ("modf (+inf, &x) returns +0", result
, 0);
1684 check_isinfp ("modf (+inf, &x) set x to +inf", intpart
);
1686 result
= FUNC(modf
) (minus_infty
, &intpart
);
1687 check ("modf (-inf, &x) returns -0", result
, minus_zero
);
1688 check_isinfn ("modf (-inf, &x) sets x to -inf", intpart
);
1690 result
= FUNC(modf
) (nan_value
, &intpart
);
1691 check_isnan ("modf (NaN, &x) returns NaN", result
);
1692 check_isnan ("modf (NaN, &x) sets x to NaN", intpart
);
1694 result
= FUNC(modf
) (0, &intpart
);
1695 check ("modf (0, &x) returns 0", result
, 0);
1696 check ("modf (0, &x) sets x to 0", intpart
, 0);
1698 result
= FUNC(modf
) (minus_zero
, &intpart
);
1699 check ("modf (-0, &x) returns -0", result
, minus_zero
);
1700 check ("modf (-0, &x) sets x to -0", intpart
, minus_zero
);
1702 result
= FUNC(modf
) (2.5, &intpart
);
1703 check ("modf (2.5, &x) returns 0.5", result
, 0.5);
1704 check ("modf (2.5, &x) sets x to 2", intpart
, 2);
1706 result
= FUNC(modf
) (-2.5, &intpart
);
1707 check ("modf (-2.5, &x) returns -0.5", result
, -0.5);
1708 check ("modf (-2.5, &x) sets x to -2", intpart
, -2);
1718 check_isnan ("scalb (2, 0.5) == NaN", FUNC(scalb
) (2, 0.5));
1719 check_isnan ("scalb (3, -2.5) == NaN", FUNC(scalb
) (3, -2.5));
1721 check_isnan ("scalb (0, NaN) == NaN", FUNC(scalb
) (0, nan_value
));
1722 check_isnan ("scalb (1, NaN) == NaN", FUNC(scalb
) (1, nan_value
));
1724 x
= random_greater (0.0);
1725 check ("scalb (x, 0) == 0", FUNC(scalb
) (x
, 0), x
);
1726 x
= random_greater (0.0);
1727 check ("scalb (-x, 0) == 0", FUNC(scalb
) (-x
, 0), -x
);
1729 check_isnan_exc ("scalb (+0, +inf) == NaN plus invalid exception",
1730 FUNC(scalb
) (0, plus_infty
), INVALID_EXCEPTION
);
1731 check_isnan_exc ("scalb (-0, +inf) == NaN plus invalid exception",
1732 FUNC(scalb
) (minus_zero
, plus_infty
), INVALID_EXCEPTION
);
1734 check ("scalb (+0, 2) == +0", FUNC(scalb
) (0, 2), 0);
1735 check ("scalb (-0, 4) == -0", FUNC(scalb
) (minus_zero
, -4), minus_zero
);
1736 check ("scalb (+0, 0) == +0", FUNC(scalb
) (0, 0), 0);
1737 check ("scalb (-0, 0) == -0", FUNC(scalb
) (minus_zero
, 0), minus_zero
);
1738 check ("scalb (+0, -1) == +0", FUNC(scalb
) (0, -1), 0);
1739 check ("scalb (-0, -10) == -0", FUNC(scalb
) (minus_zero
, -10), minus_zero
);
1740 check ("scalb (+0, -inf) == +0", FUNC(scalb
) (0, minus_infty
), 0);
1741 check ("scalb (-0, -inf) == -0", FUNC(scalb
) (minus_zero
, minus_infty
),
1744 check_isinfp ("scalb (+inf, -1) == +inf", FUNC(scalb
) (plus_infty
, -1));
1745 check_isinfn ("scalb (-inf, -10) == -inf", FUNC(scalb
) (minus_infty
, -10));
1746 check_isinfp ("scalb (+inf, 0) == +inf", FUNC(scalb
) (plus_infty
, 0));
1747 check_isinfn ("scalb (-inf, 0) == -inf", FUNC(scalb
) (minus_infty
, 0));
1748 check_isinfp ("scalb (+inf, 2) == +inf", FUNC(scalb
) (plus_infty
, 2));
1749 check_isinfn ("scalb (-inf, 100) == -inf", FUNC(scalb
) (minus_infty
, 100));
1751 x
= random_greater (0.0);
1752 check ("scalb (x, -inf) == 0", FUNC(scalb
) (x
, minus_infty
), 0.0);
1753 check ("scalb (-x, -inf) == -0", FUNC(scalb
) (-x
, minus_infty
), minus_zero
);
1755 x
= random_greater (0.0);
1756 check_isinfp ("scalb (x, +inf) == +inf", FUNC(scalb
) (x
, plus_infty
));
1757 x
= random_greater (0.0);
1758 check_isinfn ("scalb (-x, +inf) == -inf", FUNC(scalb
) (-x
, plus_infty
));
1759 check_isinfp ("scalb (+inf, +inf) == +inf",
1760 FUNC(scalb
) (plus_infty
, plus_infty
));
1761 check_isinfn ("scalb (-inf, +inf) == -inf",
1762 FUNC(scalb
) (minus_infty
, plus_infty
));
1764 check_isnan ("scalb (+inf, -inf) == NaN",
1765 FUNC(scalb
) (plus_infty
, minus_infty
));
1766 check_isnan ("scalb (-inf, -inf) == NaN",
1767 FUNC(scalb
) (minus_infty
, minus_infty
));
1769 check_isnan ("scalb (NaN, 1) == NaN", FUNC(scalb
) (nan_value
, 1));
1770 check_isnan ("scalb (1, NaN) == NaN", FUNC(scalb
) (1, nan_value
));
1771 check_isnan ("scalb (NaN, 0) == NaN", FUNC(scalb
) (nan_value
, 0));
1772 check_isnan ("scalb (0, NaN) == NaN", FUNC(scalb
) (0, nan_value
));
1773 check_isnan ("scalb (NaN, +inf) == NaN",
1774 FUNC(scalb
) (nan_value
, plus_infty
));
1775 check_isnan ("scalb (+inf, NaN) == NaN",
1776 FUNC(scalb
) (plus_infty
, nan_value
));
1777 check_isnan ("scalb (NaN, NaN) == NaN", FUNC(scalb
) (nan_value
, nan_value
));
1779 check ("scalb (0.8, 4) == 12.8", FUNC(scalb
) (0.8L, 4), 12.8L);
1780 check ("scalb (-0.854375, 5) == -27.34", FUNC(scalb
) (-0.854375L, 5), -27.34L);
1789 check ("scalbn (0, 0) == 0", FUNC(scalbn
) (0, 0), 0);
1791 check_isinfp ("scalbn (+inf, 1) == +inf", FUNC(scalbn
) (plus_infty
, 1));
1792 check_isinfn ("scalbn (-inf, 1) == -inf", FUNC(scalbn
) (minus_infty
, 1));
1793 check_isnan ("scalbn (NaN, 1) == NaN", FUNC(scalbn
) (nan_value
, 1));
1795 check ("scalbn (0.8, 4) == 12.8", FUNC(scalbn
) (0.8L, 4), 12.8L);
1796 check ("scalbn (-0.854375, 5) == -27.34", FUNC(scalbn
) (-0.854375L, 5), -27.34L);
1798 x
= random_greater (0.0);
1799 check_ext ("scalbn (x, 0) == x", FUNC(scalbn
) (x
, 0L), x
, x
);
1806 check ("sin (+0) == +0", FUNC(sin
) (0), 0);
1807 check ("sin (-0) == -0", FUNC(sin
) (minus_zero
), minus_zero
);
1808 check_isnan_exc ("sin (+inf) == NaN plus invalid exception",
1809 FUNC(sin
) (plus_infty
),
1811 check_isnan_exc ("sin (-inf) == NaN plus invalid exception",
1812 FUNC(sin
) (minus_infty
),
1815 check_eps ("sin (pi/6) == 0.5", FUNC(sin
) (M_PI_6
),
1816 0.5, CHOOSE (4e-18L, 0, 0));
1817 check_eps ("sin (-pi/6) == -0.5", FUNC(sin
) (-M_PI_6
),
1818 -0.5, CHOOSE (4e-18L, 0, 0));
1819 check ("sin (pi/2) == 1", FUNC(sin
) (M_PI_2
), 1);
1820 check ("sin (-pi/2) == -1", FUNC(sin
) (-M_PI_2
), -1);
1821 check_eps ("sin (0.7) == 0.6442176872...", FUNC(sin
) (0.7),
1822 0.64421768723769105367L, CHOOSE(4e-17L, 0, 0));
1829 check ("sinh (+0) == +0", FUNC(sinh
) (0), 0);
1832 check ("sinh (-0) == -0", FUNC(sinh
) (minus_zero
), minus_zero
);
1834 check_isinfp ("sinh (+inf) == +inf", FUNC(sinh
) (plus_infty
));
1835 check_isinfn ("sinh (-inf) == -inf", FUNC(sinh
) (minus_infty
));
1838 check_eps ("sinh (0.7) == 0.7585837018...", FUNC(sinh
) (0.7),
1839 0.75858370183953350346L, CHOOSE(6e-17L, 0, 6e-8));
1846 MATHTYPE sin_res
, cos_res
;
1849 FUNC(sincos
) (0, &sin_res
, &cos_res
);
1851 check ("sincos (+0, &sin, &cos) puts +0 in sin", sin_res
, 0);
1853 check ("sincos (+0, &sin, &cos) puts 1 in cos", cos_res
, 1);
1855 FUNC(sincos
) (minus_zero
, &sin_res
, &cos_res
);
1857 check ("sincos (-0, &sin, &cos) puts -0 in sin", sin_res
, minus_zero
);
1859 check ("sincos (-0, &sin, &cos) puts 1 in cos", cos_res
, 1);
1861 FUNC(sincos
) (plus_infty
, &sin_res
, &cos_res
);
1863 check_isnan_exc ("sincos (+inf, &sin, &cos) puts NaN in sin plus invalid exception",
1864 sin_res
, INVALID_EXCEPTION
);
1866 check_isnan_exc ("sincos (+inf, &sin, &cos) puts NaN in cos plus invalid exception",
1867 cos_res
, INVALID_EXCEPTION
);
1869 FUNC(sincos
) (minus_infty
, &sin_res
, &cos_res
);
1871 check_isnan_exc ("sincos (-inf,&sin, &cos) puts NaN in sin plus invalid exception",
1872 sin_res
, INVALID_EXCEPTION
);
1874 check_isnan_exc ("sincos (-inf,&sin, &cos) puts NaN in cos plus invalid exception",
1875 cos_res
, INVALID_EXCEPTION
);
1877 FUNC(sincos
) (M_PI_2
, &sin_res
, &cos_res
);
1879 check ("sincos (pi/2, &sin, &cos) puts 1 in sin", sin_res
, 1);
1881 check_eps ("sincos (pi/2, &sin, &cos) puts 0 in cos", cos_res
, 0,
1882 CHOOSE (1e-18L, 1e-16, 1e-7));
1884 FUNC(sincos
) (M_PI_6
, &sin_res
, &cos_res
);
1885 check_eps ("sincos (pi/6, &sin, &cos) puts 0.5 in sin", sin_res
, 0.5,
1886 CHOOSE (5e-18L, 0, 0));
1888 FUNC(sincos
) (M_PI_6
*2.0, &sin_res
, &cos_res
);
1889 check_eps ("sincos (pi/3, &sin, &cos) puts 0.5 in cos", cos_res
, 0.5,
1890 CHOOSE (5e-18L, 1e-15, 1e-7));
1892 FUNC(sincos
) (0.7, &sin_res
, &cos_res
);
1893 check_eps ("sincos (0.7, &sin, &cos) puts 0.6442176872... in sin", sin_res
,
1894 0.64421768723769105367L, CHOOSE(4e-17L, 0, 0));
1895 check_eps ("sincos (0.7, &sin, &cos) puts 0.7648421872... in cos", cos_res
,
1896 0.76484218728448842626L, CHOOSE(3e-17L, 2e-16, 0));
1903 check ("tan (+0) == +0", FUNC(tan
) (0), 0);
1904 check ("tan (-0) == -0", FUNC(tan
) (minus_zero
), minus_zero
);
1905 check_isnan_exc ("tan (+inf) == NaN plus invalid exception",
1906 FUNC(tan
) (plus_infty
), INVALID_EXCEPTION
);
1907 check_isnan_exc ("tan (-inf) == NaN plus invalid exception",
1908 FUNC(tan
) (minus_infty
), INVALID_EXCEPTION
);
1910 check_eps ("tan (pi/4) == 1", FUNC(tan
) (M_PI_4
), 1,
1911 CHOOSE (2e-18L, 1e-15L, 2e-7));
1912 check_eps ("tan (0.7) == 0.8422883804...", FUNC(tan
) (0.7),
1913 0.84228838046307944813L, CHOOSE(8e-17L, 0, 0));
1920 check ("tanh (+0) == +0", FUNC(tanh
) (0), 0);
1922 check ("tanh (-0) == -0", FUNC(tanh
) (minus_zero
), minus_zero
);
1924 check ("tanh (+inf) == +1", FUNC(tanh
) (plus_infty
), 1);
1925 check ("tanh (-inf) == -1", FUNC(tanh
) (minus_infty
), -1);
1927 check_eps ("tanh (0.7) == 0.6043677771...", FUNC(tanh
) (0.7),
1928 0.60436777711716349631L, CHOOSE(3e-17L, 0, 0));
1935 check ("fabs (+0) == +0", FUNC(fabs
) (0), 0);
1936 check ("fabs (-0) == +0", FUNC(fabs
) (minus_zero
), 0);
1938 check_isinfp ("fabs (+inf) == +inf", FUNC(fabs
) (plus_infty
));
1939 check_isinfp ("fabs (-inf) == +inf", FUNC(fabs
) (minus_infty
));
1941 check ("fabs (+38) == 38", FUNC(fabs
) (38.0), 38.0);
1942 check ("fabs (-e) == e", FUNC(fabs
) (-M_E
), M_E
);
1949 check ("floor (+0) == +0", FUNC(floor
) (0.0), 0.0);
1950 check ("floor (-0) == -0", FUNC(floor
) (minus_zero
), minus_zero
);
1951 check_isinfp ("floor (+inf) == +inf", FUNC(floor
) (plus_infty
));
1952 check_isinfn ("floor (-inf) == -inf", FUNC(floor
) (minus_infty
));
1954 check ("floor (pi) == 3", FUNC(floor
) (M_PI
), 3.0);
1955 check ("floor (-pi) == -4", FUNC(floor
) (-M_PI
), -4.0);
1964 a
= random_greater (0);
1965 check_isinfp_ext ("hypot (+inf, x) == +inf", FUNC(hypot
) (plus_infty
, a
), a
);
1966 check_isinfp_ext ("hypot (-inf, x) == +inf", FUNC(hypot
) (minus_infty
, a
), a
);
1969 check_isinfp ("hypot (+inf, NaN) == +inf", FUNC(hypot
) (minus_infty
, nan_value
));
1970 check_isinfp ("hypot (-inf, NaN) == +inf", FUNC(hypot
) (minus_infty
, nan_value
));
1973 check_isnan ("hypot (NaN, NaN) == NaN", FUNC(hypot
) (nan_value
, nan_value
));
1975 a
= FUNC(hypot
) (12.4L, 0.7L);
1976 check ("hypot (x,y) == hypot (y,x)", FUNC(hypot
) (0.7L, 12.4L), a
);
1977 check ("hypot (x,y) == hypot (-x,y)", FUNC(hypot
) (-12.4L, 0.7L), a
);
1978 check ("hypot (x,y) == hypot (-y,x)", FUNC(hypot
) (-0.7L, 12.4L), a
);
1979 check ("hypot (x,y) == hypot (-x,-y)", FUNC(hypot
) (-12.4L, -0.7L), a
);
1980 check ("hypot (x,y) == hypot (-y,-x)", FUNC(hypot
) (-0.7L, -12.4L), a
);
1981 check ("hypot (x,0) == fabs (x)", FUNC(hypot
) (-0.7L, 0), 0.7L);
1982 check ("hypot (x,0) == fabs (x)", FUNC(hypot
) (0.7L, 0), 0.7L);
1983 check ("hypot (x,0) == fabs (x)", FUNC(hypot
) (-1.0L, 0), 1.0L);
1984 check ("hypot (x,0) == fabs (x)", FUNC(hypot
) (1.0L, 0), 1.0L);
1985 check ("hypot (x,0) == fabs (x)", FUNC(hypot
) (-5.7e7L
, 0), 5.7e7L
);
1986 check ("hypot (x,0) == fabs (x)", FUNC(hypot
) (5.7e7L
, 0), 5.7e7L
);
1988 check_eps ("hypot (0.7,1.2) == 1.38924...", FUNC(hypot
) (0.7, 1.2),
1989 1.3892443989449804508L, CHOOSE(7e-17L, 3e-16, 0));
1998 check ("pow (+0, +0) == 1", FUNC(pow
) (0, 0), 1);
1999 check ("pow (+0, -0) == 1", FUNC(pow
) (0, minus_zero
), 1);
2000 check ("pow (-0, +0) == 1", FUNC(pow
) (minus_zero
, 0), 1);
2001 check ("pow (-0, -0) == 1", FUNC(pow
) (minus_zero
, minus_zero
), 1);
2003 check ("pow (+10, +0) == 1", FUNC(pow
) (10, 0), 1);
2004 check ("pow (+10, -0) == 1", FUNC(pow
) (10, minus_zero
), 1);
2005 check ("pow (-10, +0) == 1", FUNC(pow
) (-10, 0), 1);
2006 check ("pow (-10, -0) == 1", FUNC(pow
) (-10, minus_zero
), 1);
2008 check ("pow (NaN, +0) == 1", FUNC(pow
) (nan_value
, 0), 1);
2009 check ("pow (NaN, -0) == 1", FUNC(pow
) (nan_value
, minus_zero
), 1);
2012 check_isinfp ("pow (+1.1, +inf) == +inf", FUNC(pow
) (1.1, plus_infty
));
2013 check_isinfp ("pow (+inf, +inf) == +inf", FUNC(pow
) (plus_infty
, plus_infty
));
2014 check_isinfp ("pow (-1.1, +inf) == +inf", FUNC(pow
) (-1.1, plus_infty
));
2015 check_isinfp ("pow (-inf, +inf) == +inf", FUNC(pow
) (minus_infty
, plus_infty
));
2017 check ("pow (0.9, +inf) == +0", FUNC(pow
) (0.9L, plus_infty
), 0);
2018 check ("pow (1e-7, +inf) == +0", FUNC(pow
) (1e-7L, plus_infty
), 0);
2019 check ("pow (-0.9, +inf) == +0", FUNC(pow
) (-0.9L, plus_infty
), 0);
2020 check ("pow (-1e-7, +inf) == +0", FUNC(pow
) (-1e-7L, plus_infty
), 0);
2022 check ("pow (+1.1, -inf) == 0", FUNC(pow
) (1.1, minus_infty
), 0);
2023 check ("pow (+inf, -inf) == 0", FUNC(pow
) (plus_infty
, minus_infty
), 0);
2024 check ("pow (-1.1, -inf) == 0", FUNC(pow
) (-1.1, minus_infty
), 0);
2025 check ("pow (-inf, -inf) == 0", FUNC(pow
) (minus_infty
, minus_infty
), 0);
2027 check_isinfp ("pow (0.9, -inf) == +inf", FUNC(pow
) (0.9L, minus_infty
));
2028 check_isinfp ("pow (1e-7, -inf) == +inf", FUNC(pow
) (1e-7L, minus_infty
));
2029 check_isinfp ("pow (-0.9, -inf) == +inf", FUNC(pow
) (-0.9L, minus_infty
));
2030 check_isinfp ("pow (-1e-7, -inf) == +inf", FUNC(pow
) (-1e-7L, minus_infty
));
2032 check_isinfp ("pow (+inf, 1e-7) == +inf", FUNC(pow
) (plus_infty
, 1e-7L));
2033 check_isinfp ("pow (+inf, 1) == +inf", FUNC(pow
) (plus_infty
, 1));
2034 check_isinfp ("pow (+inf, 1e7) == +inf", FUNC(pow
) (plus_infty
, 1e7L
));
2036 check ("pow (+inf, -1e-7) == 0", FUNC(pow
) (plus_infty
, -1e-7L), 0);
2037 check ("pow (+inf, -1) == 0", FUNC(pow
) (plus_infty
, -1), 0);
2038 check ("pow (+inf, -1e7) == 0", FUNC(pow
) (plus_infty
, -1e7L
), 0);
2040 check_isinfn ("pow (-inf, 1) == -inf", FUNC(pow
) (minus_infty
, 1));
2041 check_isinfn ("pow (-inf, 11) == -inf", FUNC(pow
) (minus_infty
, 11));
2042 check_isinfn ("pow (-inf, 1001) == -inf", FUNC(pow
) (minus_infty
, 1001));
2044 check_isinfp ("pow (-inf, 2) == +inf", FUNC(pow
) (minus_infty
, 2));
2045 check_isinfp ("pow (-inf, 12) == +inf", FUNC(pow
) (minus_infty
, 12));
2046 check_isinfp ("pow (-inf, 1002) == +inf", FUNC(pow
) (minus_infty
, 1002));
2047 check_isinfp ("pow (-inf, 0.1) == +inf", FUNC(pow
) (minus_infty
, 0.1));
2048 check_isinfp ("pow (-inf, 1.1) == +inf", FUNC(pow
) (minus_infty
, 1.1));
2049 check_isinfp ("pow (-inf, 11.1) == +inf", FUNC(pow
) (minus_infty
, 11.1));
2050 check_isinfp ("pow (-inf, 1001.1) == +inf", FUNC(pow
) (minus_infty
, 1001.1));
2052 check ("pow (-inf, -1) == -0", FUNC(pow
) (minus_infty
, -1), minus_zero
);
2053 check ("pow (-inf, -11) == -0", FUNC(pow
) (minus_infty
, -11), minus_zero
);
2054 check ("pow (-inf, -1001) == -0", FUNC(pow
) (minus_infty
, -1001), minus_zero
);
2056 check ("pow (-inf, -2) == +0", FUNC(pow
) (minus_infty
, -2), 0);
2057 check ("pow (-inf, -12) == +0", FUNC(pow
) (minus_infty
, -12), 0);
2058 check ("pow (-inf, -1002) == +0", FUNC(pow
) (minus_infty
, -1002), 0);
2059 check ("pow (-inf, -0.1) == +0", FUNC(pow
) (minus_infty
, -0.1), 0);
2060 check ("pow (-inf, -1.1) == +0", FUNC(pow
) (minus_infty
, -1.1), 0);
2061 check ("pow (-inf, -11.1) == +0", FUNC(pow
) (minus_infty
, -11.1), 0);
2062 check ("pow (-inf, -1001.1) == +0", FUNC(pow
) (minus_infty
, -1001.1), 0);
2064 check_isnan ("pow (NaN, NaN) == NaN", FUNC(pow
) (nan_value
, nan_value
));
2065 check_isnan ("pow (0, NaN) == NaN", FUNC(pow
) (0, nan_value
));
2066 check_isnan ("pow (1, NaN) == NaN", FUNC(pow
) (1, nan_value
));
2067 check_isnan ("pow (-1, NaN) == NaN", FUNC(pow
) (-1, nan_value
));
2068 check_isnan ("pow (NaN, 1) == NaN", FUNC(pow
) (nan_value
, 1));
2069 check_isnan ("pow (NaN, -1) == NaN", FUNC(pow
) (nan_value
, -1));
2071 x
= random_greater (0.0);
2072 check_isnan_ext ("pow (x, NaN) == NaN", FUNC(pow
) (x
, nan_value
), x
);
2074 check_isnan_exc ("pow (+1, +inf) == NaN plus invalid exception",
2075 FUNC(pow
) (1, plus_infty
), INVALID_EXCEPTION
);
2076 check_isnan_exc ("pow (-1, +inf) == NaN plus invalid exception",
2077 FUNC(pow
) (-1, plus_infty
), INVALID_EXCEPTION
);
2078 check_isnan_exc ("pow (+1, -inf) == NaN plus invalid exception",
2079 FUNC(pow
) (1, minus_infty
), INVALID_EXCEPTION
);
2080 check_isnan_exc ("pow (-1, -inf) == NaN plus invalid exception",
2081 FUNC(pow
) (-1, minus_infty
), INVALID_EXCEPTION
);
2083 check_isnan_exc ("pow (-0.1, 1.1) == NaN plus invalid exception",
2084 FUNC(pow
) (-0.1, 1.1), INVALID_EXCEPTION
);
2085 check_isnan_exc ("pow (-0.1, -1.1) == NaN plus invalid exception",
2086 FUNC(pow
) (-0.1, -1.1), INVALID_EXCEPTION
);
2087 check_isnan_exc ("pow (-10.1, 1.1) == NaN plus invalid exception",
2088 FUNC(pow
) (-10.1, 1.1), INVALID_EXCEPTION
);
2089 check_isnan_exc ("pow (-10.1, -1.1) == NaN plus invalid exception",
2090 FUNC(pow
) (-10.1, -1.1), INVALID_EXCEPTION
);
2092 check_isinfp_exc ("pow (+0, -1) == +inf plus divide-by-zero exception",
2093 FUNC(pow
) (0, -1), DIVIDE_BY_ZERO_EXCEPTION
);
2094 check_isinfp_exc ("pow (+0, -11) == +inf plus divide-by-zero exception",
2095 FUNC(pow
) (0, -11), DIVIDE_BY_ZERO_EXCEPTION
);
2096 check_isinfn_exc ("pow (-0, -1) == -inf plus divide-by-zero exception",
2097 FUNC(pow
) (minus_zero
, -1), DIVIDE_BY_ZERO_EXCEPTION
);
2098 check_isinfn_exc ("pow (-0, -11) == -inf plus divide-by-zero exception",
2099 FUNC(pow
) (minus_zero
, -11), DIVIDE_BY_ZERO_EXCEPTION
);
2101 check_isinfp_exc ("pow (+0, -2) == +inf plus divide-by-zero exception",
2102 FUNC(pow
) (0, -2), DIVIDE_BY_ZERO_EXCEPTION
);
2103 check_isinfp_exc ("pow (+0, -11.1) == +inf plus divide-by-zero exception",
2104 FUNC(pow
) (0, -11.1), DIVIDE_BY_ZERO_EXCEPTION
);
2105 check_isinfp_exc ("pow (-0, -2) == +inf plus divide-by-zero exception",
2106 FUNC(pow
) (minus_zero
, -2), DIVIDE_BY_ZERO_EXCEPTION
);
2107 check_isinfp_exc ("pow (-0, -11.1) == +inf plus divide-by-zero exception",
2108 FUNC(pow
) (minus_zero
, -11.1), DIVIDE_BY_ZERO_EXCEPTION
);
2111 check ("pow (+0, 1) == +0", FUNC(pow
) (0, 1), 0);
2112 check ("pow (+0, 11) == +0", FUNC(pow
) (0, 11), 0);
2114 check ("pow (-0, 1) == -0", FUNC(pow
) (minus_zero
, 1), minus_zero
);
2115 check ("pow (-0, 11) == -0", FUNC(pow
) (minus_zero
, 11), minus_zero
);
2118 check ("pow (+0, 2) == +0", FUNC(pow
) (0, 2), 0);
2119 check ("pow (+0, 11.1) == +0", FUNC(pow
) (0, 11.1), 0);
2122 check ("pow (-0, 2) == +0", FUNC(pow
) (minus_zero
, 2), 0);
2123 check ("pow (-0, 11.1) == +0", FUNC(pow
) (minus_zero
, 11.1), 0);
2125 x
= random_greater (1.0);
2126 check_isinfp_ext ("pow (x, +inf) == +inf for |x| > 1",
2127 FUNC(pow
) (x
, plus_infty
), x
);
2129 x
= random_value (-1.0, 1.0);
2130 check_ext ("pow (x, +inf) == +0 for |x| < 1",
2131 FUNC(pow
) (x
, plus_infty
), 0.0, x
);
2133 x
= random_greater (1.0);
2134 check_ext ("pow (x, -inf) == +0 for |x| > 1",
2135 FUNC(pow
) (x
, minus_infty
), 0.0, x
);
2137 x
= random_value (-1.0, 1.0);
2138 check_isinfp_ext ("pow (x, -inf) == +inf for |x| < 1",
2139 FUNC(pow
) (x
, minus_infty
), x
);
2141 x
= random_greater (0.0);
2142 check_isinfp_ext ("pow (+inf, y) == +inf for y > 0",
2143 FUNC(pow
) (plus_infty
, x
), x
);
2145 x
= random_less (0.0);
2146 check_ext ("pow (+inf, y) == +0 for y < 0",
2147 FUNC(pow
) (plus_infty
, x
), 0.0, x
);
2149 x
= (rand () % 1000000) * 2.0 + 1; /* Get random odd integer > 0 */
2150 check_isinfn_ext ("pow (-inf, y) == -inf for y an odd integer > 0",
2151 FUNC(pow
) (minus_infty
, x
), x
);
2153 x
= ((rand () % 1000000) + 1) * 2.0; /* Get random even integer > 1 */
2154 check_isinfp_ext ("pow (-inf, y) == +inf for y > 0 and not an odd integer",
2155 FUNC(pow
) (minus_infty
, x
), x
);
2157 x
= -((rand () % 1000000) * 2.0 + 1); /* Get random odd integer < 0 */
2158 check_ext ("pow (-inf, y) == -0 for y an odd integer < 0",
2159 FUNC(pow
) (minus_infty
, x
), minus_zero
, x
);
2161 x
= ((rand () % 1000000) + 1) * -2.0; /* Get random even integer < 0 */
2162 check_ext ("pow (-inf, y) == +0 for y < 0 and not an odd integer",
2163 FUNC(pow
) (minus_infty
, x
), 0.0, x
);
2166 x
= (rand () % 1000000) * 2.0 + 1; /* Get random odd integer > 0 */
2167 check_ext ("pow (+0, y) == +0 for y an odd integer > 0",
2168 FUNC(pow
) (0.0, x
), 0.0, x
);
2170 x
= (rand () % 1000000) * 2.0 + 1; /* Get random odd integer > 0 */
2171 check_ext ("pow (-0, y) == -0 for y an odd integer > 0",
2172 FUNC(pow
) (minus_zero
, x
), minus_zero
, x
);
2175 x
= ((rand () % 1000000) + 1) * 2.0; /* Get random even integer > 1 */
2176 check_ext ("pow (+0, y) == +0 for y > 0 and not an odd integer",
2177 FUNC(pow
) (0.0, x
), 0.0, x
);
2179 x
= ((rand () % 1000000) + 1) * 2.0; /* Get random even integer > 1 */
2180 check_ext ("pow (-0, y) == +0 for y > 0 and not an odd integer",
2181 FUNC(pow
) (minus_zero
, x
), 0.0, x
);
2183 check_eps ("pow (0.7, 1.2) == 0.65180...", FUNC(pow
) (0.7, 1.2),
2184 0.65180494056638638188L, CHOOSE(4e-17L, 0, 0));
2191 check ("fdim (+0, +0) = +0", FUNC(fdim
) (0, 0), 0);
2192 check ("fdim (9, 0) = 9", FUNC(fdim
) (9, 0), 9);
2193 check ("fdim (0, 9) = 0", FUNC(fdim
) (0, 9), 0);
2194 check ("fdim (-9, 0) = 9", FUNC(fdim
) (-9, 0), 0);
2195 check ("fdim (0, -9) = 9", FUNC(fdim
) (0, -9), 9);
2197 check_isinfp ("fdim (+inf, 9) = +inf", FUNC(fdim
) (plus_infty
, 9));
2198 check_isinfp ("fdim (+inf, -9) = +inf", FUNC(fdim
) (plus_infty
, -9));
2199 check ("fdim (-inf, 9) = 0", FUNC(fdim
) (minus_infty
, 9), 0);
2200 check ("fdim (-inf, -9) = 0", FUNC(fdim
) (minus_infty
, -9), 0);
2201 check_isinfp ("fdim (+9, -inf) = +inf", FUNC(fdim
) (9, minus_infty
));
2202 check_isinfp ("fdim (-9, -inf) = +inf", FUNC(fdim
) (-9, minus_infty
));
2203 check ("fdim (9, inf) = 0", FUNC(fdim
) (9, plus_infty
), 0);
2204 check ("fdim (-9, inf) = 0", FUNC(fdim
) (-9, plus_infty
), 0);
2206 check_isnan ("fdim (0, NaN) = NaN", FUNC(fdim
) (0, nan_value
));
2207 check_isnan ("fdim (9, NaN) = NaN", FUNC(fdim
) (9, nan_value
));
2208 check_isnan ("fdim (-9, NaN) = NaN", FUNC(fdim
) (-9, nan_value
));
2209 check_isnan ("fdim (NaN, 9) = NaN", FUNC(fdim
) (nan_value
, 9));
2210 check_isnan ("fdim (NaN, -9) = NaN", FUNC(fdim
) (nan_value
, -9));
2211 check_isnan ("fdim (+inf, NaN) = NaN", FUNC(fdim
) (plus_infty
, nan_value
));
2212 check_isnan ("fdim (-inf, NaN) = NaN", FUNC(fdim
) (minus_infty
, nan_value
));
2213 check_isnan ("fdim (NaN, +inf) = NaN", FUNC(fdim
) (nan_value
, plus_infty
));
2214 check_isnan ("fdim (NaN, -inf) = NaN", FUNC(fdim
) (nan_value
, minus_infty
));
2215 check_isnan ("fdim (NaN, NaN) = NaN", FUNC(fdim
) (nan_value
, nan_value
));
2222 check ("fmin (+0, +0) = +0", FUNC(fmin
) (0, 0), 0);
2223 check ("fmin (9, 0) = 0", FUNC(fmin
) (9, 0), 0);
2224 check ("fmin (0, 9) = 0", FUNC(fmin
) (0, 9), 0);
2225 check ("fmin (-9, 0) = -9", FUNC(fmin
) (-9, 0), -9);
2226 check ("fmin (0, -9) = -9", FUNC(fmin
) (0, -9), -9);
2228 check ("fmin (+inf, 9) = 9", FUNC(fmin
) (plus_infty
, 9), 9);
2229 check ("fmin (9, +inf) = 9", FUNC(fmin
) (9, plus_infty
), 9);
2230 check ("fmin (+inf, -9) = -9", FUNC(fmin
) (plus_infty
, -9), -9);
2231 check ("fmin (-9, +inf) = -9", FUNC(fmin
) (-9, plus_infty
), -9);
2232 check_isinfn ("fmin (-inf, 9) = -inf", FUNC(fmin
) (minus_infty
, 9));
2233 check_isinfn ("fmin (-inf, -9) = -inf", FUNC(fmin
) (minus_infty
, -9));
2234 check_isinfn ("fmin (+9, -inf) = -inf", FUNC(fmin
) (9, minus_infty
));
2235 check_isinfn ("fmin (-9, -inf) = -inf", FUNC(fmin
) (-9, minus_infty
));
2237 check ("fmin (0, NaN) = 0", FUNC(fmin
) (0, nan_value
), 0);
2238 check ("fmin (9, NaN) = 9", FUNC(fmin
) (9, nan_value
), 9);
2239 check ("fmin (-9, NaN) = 9", FUNC(fmin
) (-9, nan_value
), -9);
2240 check ("fmin (NaN, 0) = 0", FUNC(fmin
) (nan_value
, 0), 0);
2241 check ("fmin (NaN, 9) = NaN", FUNC(fmin
) (nan_value
, 9), 9);
2242 check ("fmin (NaN, -9) = NaN", FUNC(fmin
) (nan_value
, -9), -9);
2243 check_isinfp ("fmin (+inf, NaN) = +inf", FUNC(fmin
) (plus_infty
, nan_value
));
2244 check_isinfn ("fmin (-inf, NaN) = -inf", FUNC(fmin
) (minus_infty
, nan_value
));
2245 check_isinfp ("fmin (NaN, +inf) = +inf", FUNC(fmin
) (nan_value
, plus_infty
));
2246 check_isinfn ("fmin (NaN, -inf) = -inf", FUNC(fmin
) (nan_value
, minus_infty
));
2247 check_isnan ("fmin (NaN, NaN) = NaN", FUNC(fmin
) (nan_value
, nan_value
));
2254 check ("fmax (+0, +0) = +0", FUNC(fmax
) (0, 0), 0);
2255 check ("fmax (9, 0) = 9", FUNC(fmax
) (9, 0), 9);
2256 check ("fmax (0, 9) = 9", FUNC(fmax
) (0, 9), 9);
2257 check ("fmax (-9, 0) = 0", FUNC(fmax
) (-9, 0), 0);
2258 check ("fmax (0, -9) = 0", FUNC(fmax
) (0, -9), 0);
2260 check_isinfp ("fmax (+inf, 9) = +inf", FUNC(fmax
) (plus_infty
, 9));
2261 check_isinfp ("fmax (9, +inf) = +inf", FUNC(fmax
) (0, plus_infty
));
2262 check_isinfp ("fmax (-9, +inf) = +inf", FUNC(fmax
) (-9, plus_infty
));
2263 check_isinfp ("fmax (+inf, -9) = +inf", FUNC(fmax
) (plus_infty
, -9));
2264 check ("fmax (-inf, 9) = 9", FUNC(fmax
) (minus_infty
, 9), 9);
2265 check ("fmax (-inf, -9) = -9", FUNC(fmax
) (minus_infty
, -9), -9);
2266 check ("fmax (+9, -inf) = 9", FUNC(fmax
) (9, minus_infty
), 9);
2267 check ("fmax (-9, -inf) = -9", FUNC(fmax
) (-9, minus_infty
), -9);
2269 check ("fmax (0, NaN) = 0", FUNC(fmax
) (0, nan_value
), 0);
2270 check ("fmax (9, NaN) = 9", FUNC(fmax
) (9, nan_value
), 9);
2271 check ("fmax (-9, NaN) = 9", FUNC(fmax
) (-9, nan_value
), -9);
2272 check ("fmax (NaN, 0) = 0", FUNC(fmax
) (nan_value
, 0), 0);
2273 check ("fmax (NaN, 9) = NaN", FUNC(fmax
) (nan_value
, 9), 9);
2274 check ("fmax (NaN, -9) = NaN", FUNC(fmax
) (nan_value
, -9), -9);
2275 check_isinfp ("fmax (+inf, NaN) = +inf", FUNC(fmax
) (plus_infty
, nan_value
));
2276 check_isinfn ("fmax (-inf, NaN) = -inf", FUNC(fmax
) (minus_infty
, nan_value
));
2277 check_isinfp ("fmax (NaN, +inf) = +inf", FUNC(fmax
) (nan_value
, plus_infty
));
2278 check_isinfn ("fmax (NaN, -inf) = -inf", FUNC(fmax
) (nan_value
, minus_infty
));
2279 check_isnan ("fmax (NaN, NaN) = NaN", FUNC(fmax
) (nan_value
, nan_value
));
2288 x
= random_greater (0);
2289 check_ext ("fmod (+0, y) == +0 for y != 0", FUNC(fmod
) (0, x
), 0, x
);
2291 x
= random_greater (0);
2292 check_ext ("fmod (-0, y) == -0 for y != 0", FUNC(fmod
) (minus_zero
, x
),
2295 check_isnan_exc_ext ("fmod (+inf, y) == NaN plus invalid exception",
2296 FUNC(fmod
) (plus_infty
, x
), INVALID_EXCEPTION
, x
);
2297 check_isnan_exc_ext ("fmod (-inf, y) == NaN plus invalid exception",
2298 FUNC(fmod
) (minus_infty
, x
), INVALID_EXCEPTION
, x
);
2299 check_isnan_exc_ext ("fmod (x, +0) == NaN plus invalid exception",
2300 FUNC(fmod
) (x
, 0), INVALID_EXCEPTION
, x
);
2301 check_isnan_exc_ext ("fmod (x, -0) == NaN plus invalid exception",
2302 FUNC(fmod
) (x
, minus_zero
), INVALID_EXCEPTION
, x
);
2304 x
= random_greater (0);
2305 check_ext ("fmod (x, +inf) == x for x not infinite",
2306 FUNC(fmod
) (x
, plus_infty
), x
, x
);
2307 x
= random_greater (0);
2308 check_ext ("fmod (x, -inf) == x for x not infinite",
2309 FUNC(fmod
) (x
, minus_infty
), x
, x
);
2311 check_eps ("fmod (6.5, 2.3) == 1.9", FUNC(fmod
) (6.5, 2.3), 1.9,
2312 CHOOSE(5e-16, 1e-15, 2e-7));
2313 check_eps ("fmod (-6.5, 2.3) == -1.9", FUNC(fmod
) (-6.5, 2.3), -1.9,
2314 CHOOSE(5e-16, 1e-15, 2e-7));
2315 check_eps ("fmod (6.5, -2.3) == 1.9", FUNC(fmod
) (6.5, -2.3), 1.9,
2316 CHOOSE(5e-16, 1e-15, 2e-7));
2317 check_eps ("fmod (-6.5, -2.3) == -1.9", FUNC(fmod
) (-6.5, -2.3), -1.9,
2318 CHOOSE(5e-16, 1e-15, 2e-7));
2325 nextafter_test (void)
2329 check ("nextafter (+0, +0) = +0", FUNC(nextafter
) (0, 0), 0);
2330 check ("nextafter (-0, +0) = +0", FUNC(nextafter
) (minus_zero
, 0), 0);
2331 check ("nextafter (+0, -0) = -0", FUNC(nextafter
) (0, minus_zero
),
2333 check ("nextafter (-0, -0) = -0", FUNC(nextafter
) (minus_zero
, minus_zero
),
2336 check ("nextafter (9, 9) = 9", FUNC(nextafter
) (9, 9), 9);
2337 check ("nextafter (-9, -9) = -9", FUNC(nextafter
) (-9, -9), -9);
2338 check_isinfp ("nextafter (+inf, +inf) = +inf",
2339 FUNC(nextafter
) (plus_infty
, plus_infty
));
2340 check_isinfn ("nextafter (-inf, -inf) = -inf",
2341 FUNC(nextafter
) (minus_infty
, minus_infty
));
2344 check_isnan ("nextafter (NaN, x) = NaN", FUNC(nextafter
) (nan_value
, x
));
2345 check_isnan ("nextafter (x, NaN) = NaN", FUNC(nextafter
) (x
, nan_value
));
2346 check_isnan ("nextafter (NaN, NaN) = NaN", FUNC(nextafter
) (nan_value
,
2349 /* XXX We need the hexadecimal FP number representation here for further
2355 copysign_test (void)
2357 check ("copysign (0, 4) = 0", FUNC(copysign
) (0, 4), 0);
2358 check ("copysign (0, -4) = -0", FUNC(copysign
) (0, -4), minus_zero
);
2359 check ("copysign (-0, 4) = 0", FUNC(copysign
) (minus_zero
, 4), 0);
2360 check ("copysign (-0, -4) = -0", FUNC(copysign
) (minus_zero
, -4),
2363 check_isinfp ("copysign (+inf, 0) = +inf", FUNC(copysign
) (plus_infty
, 0));
2364 check_isinfn ("copysign (+inf, -0) = -inf", FUNC(copysign
) (plus_infty
,
2366 check_isinfp ("copysign (-inf, 0) = +inf", FUNC(copysign
) (minus_infty
, 0));
2367 check_isinfn ("copysign (-inf, -0) = -inf", FUNC(copysign
) (minus_infty
,
2370 check ("copysign (0, +inf) = 0", FUNC(copysign
) (0, plus_infty
), 0);
2371 check ("copysign (0, -inf) = -0", FUNC(copysign
) (0, minus_zero
),
2373 check ("copysign (-0, +inf) = 0", FUNC(copysign
) (minus_zero
, plus_infty
),
2375 check ("copysign (-0, -inf) = -0", FUNC(copysign
) (minus_zero
, minus_zero
),
2378 /* XXX More correctly we would have to check the sign of the NaN. */
2379 check_isnan ("copysign (+NaN, 0) = +NaN", FUNC(copysign
) (nan_value
, 0));
2380 check_isnan ("copysign (+NaN, -0) = -NaN", FUNC(copysign
) (nan_value
,
2382 check_isnan ("copysign (-NaN, 0) = +NaN", FUNC(copysign
) (-nan_value
, 0));
2383 check_isnan ("copysign (-NaN, -0) = -NaN", FUNC(copysign
) (-nan_value
,
2391 check ("trunc(0) = 0", FUNC(trunc
) (0), 0);
2392 check ("trunc(-0) = -0", FUNC(trunc
) (minus_zero
), minus_zero
);
2393 check ("trunc(0.625) = 0", FUNC(trunc
) (0.625), 0);
2394 check ("trunc(-0.625) = -0", FUNC(trunc
) (-0.625), minus_zero
);
2395 check ("trunc(1) = 1", FUNC(trunc
) (1), 1);
2396 check ("trunc(-1) = -1", FUNC(trunc
) (-1), -1);
2397 check ("trunc(1.625) = 1", FUNC(trunc
) (1.625), 1);
2398 check ("trunc(-1.625) = -1", FUNC(trunc
) (-1.625), -1);
2400 check ("trunc(1048580.625) = 1048580", FUNC(trunc
) (1048580.625L),
2402 check ("trunc(-1048580.625) = -1048580", FUNC(trunc
) (-1048580.625L),
2405 check ("trunc(8388610.125) = 8388610", FUNC(trunc
) (8388610.125L),
2407 check ("trunc(-8388610.125) = -8388610", FUNC(trunc
) (-8388610.125L),
2410 check ("trunc(4294967296.625) = 4294967296", FUNC(trunc
) (4294967296.625L),
2412 check ("trunc(-4294967296.625) = -4294967296",
2413 FUNC(trunc
) (-4294967296.625L), -4294967296.0L);
2415 check_isinfp ("trunc(+inf) = +inf", FUNC(trunc
) (plus_infty
));
2416 check_isinfn ("trunc(-inf) = -inf", FUNC(trunc
) (minus_infty
));
2417 check_isnan ("trunc(NaN) = NaN", FUNC(trunc
) (nan_value
));
2427 /* XXX Tests fuer negative x are missing */
2428 check ("sqrt (0) == 0", FUNC(sqrt
) (0), 0);
2429 check_isnan ("sqrt (NaN) == NaN", FUNC(sqrt
) (nan_value
));
2430 check_isinfp ("sqrt (+inf) == +inf", FUNC(sqrt
) (plus_infty
));
2432 check ("sqrt (-0) == -0", FUNC(sqrt
) (0), 0);
2434 x
= random_less (0.0);
2435 check_isnan_exc_ext ("sqrt (x) == NaN plus invalid exception for x < 0",
2436 FUNC(sqrt
) (x
), INVALID_EXCEPTION
, x
);
2438 x
= random_value (0, 10000);
2439 check_ext ("sqrt (x*x) == x", FUNC(sqrt
) (x
*x
), x
, x
);
2440 check ("sqrt (4) == 2", FUNC(sqrt
) (4), 2);
2441 check ("sqrt (0.25) == 0.5", FUNC(sqrt
) (0.25), 0.5);
2442 check ("sqrt (6642.25) == 81.5", FUNC(sqrt
) (6642.25), 81.5);
2443 check_eps ("sqrt (15239.903) == 123.45", FUNC(sqrt
) (15239.903), 123.45,
2444 CHOOSE (3e-6L, 3e-6, 8e-6));
2445 check_eps ("sqrt (0.7) == 0.8366600265", FUNC(sqrt
) (0.7),
2446 0.83666002653407554798L, CHOOSE(3e-17L, 0, 0));
2450 remainder_test (void)
2454 result
= FUNC(remainder
) (1, 0);
2455 check_isnan_exc ("remainder(1, +0) == NaN plus invalid exception",
2456 result
, INVALID_EXCEPTION
);
2458 result
= FUNC(remainder
) (1, minus_zero
);
2459 check_isnan_exc ("remainder(1, -0) == NaN plus invalid exception",
2460 result
, INVALID_EXCEPTION
);
2462 result
= FUNC(remainder
) (plus_infty
, 1);
2463 check_isnan_exc ("remainder(+inf, 1) == NaN plus invalid exception",
2464 result
, INVALID_EXCEPTION
);
2466 result
= FUNC(remainder
) (minus_infty
, 1);
2467 check_isnan_exc ("remainder(-inf, 1) == NaN plus invalid exception",
2468 result
, INVALID_EXCEPTION
);
2470 result
= FUNC(remainder
) (1.625, 1.0);
2471 check ("remainder(1.625, 1.0) == -0.375", result
, -0.375);
2473 result
= FUNC(remainder
) (-1.625, 1.0);
2474 check ("remainder(-1.625, 1.0) == 0.375", result
, 0.375);
2476 result
= FUNC(remainder
) (1.625, -1.0);
2477 check ("remainder(1.625, -1.0) == -0.375", result
, -0.375);
2479 result
= FUNC(remainder
) (-1.625, -1.0);
2480 check ("remainder(-1.625, -1.0) == 0.375", result
, 0.375);
2482 result
= FUNC(remainder
) (5.0, 2.0);
2483 check ("remainder(5.0, 2.0) == 1.0", result
, 1.0);
2485 result
= FUNC(remainder
) (3.0, 2.0);
2486 check ("remainder(3.0, 2.0) == -1.0", result
, -1.0);
2496 result
= FUNC(remquo
) (1, 0, &quo
);
2497 check_isnan_exc ("remquo(1, +0, &x) == NaN plus invalid exception",
2498 result
, INVALID_EXCEPTION
);
2500 result
= FUNC(remquo
) (1, minus_zero
, &quo
);
2501 check_isnan_exc ("remquo(1, -0, &x) == NaN plus invalid exception",
2502 result
, INVALID_EXCEPTION
);
2504 result
= FUNC(remquo
) (plus_infty
, 1, &quo
);
2505 check_isnan_exc ("remquo(+inf, 1, &x) == NaN plus invalid exception",
2506 result
, INVALID_EXCEPTION
);
2508 result
= FUNC(remquo
) (minus_infty
, 1, &quo
);
2509 check_isnan_exc ("remquo(-inf, 1, &x) == NaN plus invalid exception",
2510 result
, INVALID_EXCEPTION
);
2512 result
= FUNC(remquo
) (1.625, 1.0, &quo
);
2513 check ("remquo(1.625, 1.0, &x) == -0.375", result
, -0.375);
2514 check_long ("remquo(1.625, 1.0, &x) puts 2 in x", quo
, 2);
2516 result
= FUNC(remquo
) (-1.625, 1.0, &quo
);
2517 check ("remquo(-1.625, 1.0, &x) == 0.375", result
, 0.375);
2518 check_long ("remquo(-1.625, 1.0, &x) puts -2 in x", quo
, -2);
2520 result
= FUNC(remquo
) (1.625, -1.0, &quo
);
2521 check ("remquo(1.625, -1.0, &x) == -0.375", result
, -0.375);
2522 check_long ("remquo(1.625, -1.0, &x) puts -2 in x", quo
, -2);
2524 result
= FUNC(remquo
) (-1.625, -1.0, &quo
);
2525 check ("remquo(-1.625, -1.0, &x) == 0.375", result
, 0.375);
2526 check_long ("remquo(-1.625, -1.0, &x) puts 2 in x", quo
, 2);
2528 result
= FUNC(remquo
) (5.0, 2.0, &quo
);
2529 check ("remquo(5.0, 2.0, &x) == 1.0", result
, 1.0);
2530 check_long ("remquo (5.0, 2.0, &x) puts 2 in x", quo
, 2);
2532 result
= FUNC(remquo
) (3.0, 2.0, &quo
);
2533 check ("remquo(3.0, 2.0, &x) == -1.0", result
, -1.0);
2534 check_long ("remquo (3.0, 2.0, &x) puts 2 in x", quo
, 2);
2541 __complex__ MATHTYPE result
;
2543 result
= FUNC(cexp
) (BUILD_COMPLEX (plus_zero
, plus_zero
));
2544 check ("real(cexp(0 + 0i)) = 1", __real__ result
, 1);
2545 check ("imag(cexp(0 + 0i)) = 0", __imag__ result
, 0);
2546 result
= FUNC(cexp
) (BUILD_COMPLEX (minus_zero
, plus_zero
));
2547 check ("real(cexp(-0 + 0i)) = 1", __real__ result
, 1);
2548 check ("imag(cexp(-0 + 0i)) = 0", __imag__ result
, 0);
2549 result
= FUNC(cexp
) (BUILD_COMPLEX (plus_zero
, minus_zero
));
2550 check ("real(cexp(0 - 0i)) = 1", __real__ result
, 1);
2551 check ("imag(cexp(0 - 0i)) = -0", __imag__ result
, minus_zero
);
2552 result
= FUNC(cexp
) (BUILD_COMPLEX (minus_zero
, minus_zero
));
2553 check ("real(cexp(-0 - 0i)) = 1", __real__ result
, 1);
2554 check ("imag(cexp(-0 - 0i)) = -0", __imag__ result
, minus_zero
);
2556 result
= FUNC(cexp
) (BUILD_COMPLEX (plus_infty
, plus_zero
));
2557 check_isinfp ("real(cexp(+inf + 0i)) = +inf", __real__ result
);
2558 check ("imag(cexp(+inf + 0i)) = 0", __imag__ result
, 0);
2559 result
= FUNC(cexp
) (BUILD_COMPLEX (plus_infty
, minus_zero
));
2560 check_isinfp ("real(cexp(+inf - 0i)) = +inf", __real__ result
);
2561 check ("imag(cexp(+inf - 0i)) = -0", __imag__ result
, minus_zero
);
2563 result
= FUNC(cexp
) (BUILD_COMPLEX (minus_infty
, plus_zero
));
2564 check ("real(cexp(-inf + 0i)) = 0", __real__ result
, 0);
2565 check ("imag(cexp(-inf + 0i)) = 0", __imag__ result
, 0);
2566 result
= FUNC(cexp
) (BUILD_COMPLEX (minus_infty
, minus_zero
));
2567 check ("real(cexp(-inf - 0i)) = 0", __real__ result
, 0);
2568 check ("imag(cexp(-inf - 0i)) = -0", __imag__ result
, minus_zero
);
2571 result
= FUNC(cexp
) (BUILD_COMPLEX (0.0, plus_infty
));
2572 check_isnan_exc ("real(cexp(0 + i inf)) = NaN plus invalid exception",
2573 __real__ result
, INVALID_EXCEPTION
);
2574 check_isnan ("imag(cexp(0 + i inf)) = NaN plus invalid exception",
2577 #if defined __GNUC__ && __GNUC__ <= 2 && __GNUC_MINOR__ <= 7
2579 printf ("The following test for cexp might fail due to a gcc compiler error!\n");
2582 result
= FUNC(cexp
) (BUILD_COMPLEX (minus_zero
, plus_infty
));
2583 check_isnan_exc ("real(cexp(-0 + i inf)) = NaN plus invalid exception",
2584 __real__ result
, INVALID_EXCEPTION
);
2585 check_isnan ("imag(cexp(-0 + i inf)) = NaN plus invalid exception",
2587 result
= FUNC(cexp
) (BUILD_COMPLEX (0.0, minus_infty
));
2588 check_isnan_exc ("real(cexp(0 - i inf)) = NaN plus invalid exception",
2589 __real__ result
, INVALID_EXCEPTION
);
2590 check_isnan ("imag(cexp(0 - i inf)) = NaN plus invalid exception",
2592 result
= FUNC(cexp
) (BUILD_COMPLEX (minus_zero
, minus_infty
));
2593 check_isnan_exc ("real(cexp(-0 - i inf)) = NaN plus invalid exception",
2594 __real__ result
, INVALID_EXCEPTION
);
2595 check_isnan ("imag(cexp(-0 - i inf)) = NaN plus invalid exception",
2598 result
= FUNC(cexp
) (BUILD_COMPLEX (100.0, plus_infty
));
2599 check_isnan_exc ("real(cexp(100.0 + i inf)) = NaN plus invalid exception",
2600 __real__ result
, INVALID_EXCEPTION
);
2601 check_isnan ("imag(cexp(100.0 + i inf)) = NaN plus invalid exception",
2603 result
= FUNC(cexp
) (BUILD_COMPLEX (-100.0, plus_infty
));
2604 check_isnan_exc ("real(cexp(-100.0 + i inf)) = NaN plus invalid exception",
2605 __real__ result
, INVALID_EXCEPTION
);
2606 check_isnan ("imag(cexp(-100.0 + i inf)) = NaN plus invalid exception",
2608 result
= FUNC(cexp
) (BUILD_COMPLEX (100.0, minus_infty
));
2609 check_isnan_exc ("real(cexp(100.0 - i inf)) = NaN plus invalid exception",
2610 __real__ result
, INVALID_EXCEPTION
);
2611 check_isnan ("imag(cexp(100.0 - i inf)) = NaN plus invalid exception",
2613 result
= FUNC(cexp
) (BUILD_COMPLEX (-100.0, minus_infty
));
2614 check_isnan_exc ("real(cexp(-100.0 - i inf)) = NaN plus invalid exception",
2615 __real__ result
, INVALID_EXCEPTION
);
2616 check_isnan ("imag(cexp(-100.0 - i inf)) = NaN", __imag__ result
);
2618 result
= FUNC(cexp
) (BUILD_COMPLEX (minus_infty
, 2.0));
2619 check ("real(cexp(-inf + 2.0i)) = -0", __real__ result
, minus_zero
);
2620 check ("imag(cexp(-inf + 2.0i)) = 0", __imag__ result
, 0);
2621 result
= FUNC(cexp
) (BUILD_COMPLEX (minus_infty
, 4.0));
2622 check ("real(cexp(-inf + 4.0i)) = -0", __real__ result
, minus_zero
);
2623 check ("imag(cexp(-inf + 4.0i)) = -0", __imag__ result
, minus_zero
);
2625 result
= FUNC(cexp
) (BUILD_COMPLEX (plus_infty
, 2.0));
2626 check_isinfn ("real(cexp(+inf + 2.0i)) = -inf", __real__ result
);
2627 check_isinfp ("imag(cexp(+inf + 2.0i)) = +inf", __imag__ result
);
2628 result
= FUNC(cexp
) (BUILD_COMPLEX (plus_infty
, 4.0));
2629 check_isinfn ("real(cexp(+inf + 4.0i)) = -inf", __real__ result
);
2630 check_isinfn ("imag(cexp(+inf + 4.0i)) = -inf", __imag__ result
);
2632 result
= FUNC(cexp
) (BUILD_COMPLEX (plus_infty
, plus_infty
));
2633 check_isinfp_exc ("real(cexp(+inf + i inf)) = +inf plus invalid exception",
2634 __real__ result
, INVALID_EXCEPTION
);
2635 check_isnan ("imag(cexp(+inf + i inf)) = NaN plus invalid exception",
2637 result
= FUNC(cexp
) (BUILD_COMPLEX (plus_infty
, minus_infty
));
2638 check_isinfp_exc ("real(cexp(+inf - i inf)) = +inf plus invalid exception",
2639 __real__ result
, INVALID_EXCEPTION
);
2640 check_isnan ("imag(cexp(+inf - i inf)) = NaN plus invalid exception",
2643 result
= FUNC(cexp
) (BUILD_COMPLEX (minus_infty
, plus_infty
));
2644 check ("real(cexp(-inf + i inf)) = 0", __real__ result
, 0);
2645 check ("imag(cexp(-inf + i inf)) = 0", __imag__ result
, 0);
2646 result
= FUNC(cexp
) (BUILD_COMPLEX (minus_infty
, minus_infty
));
2647 check ("real(cexp(-inf - i inf)) = 0", __real__ result
, 0);
2648 check ("imag(cexp(-inf - i inf)) = -0", __imag__ result
, minus_zero
);
2650 result
= FUNC(cexp
) (BUILD_COMPLEX (minus_infty
, nan_value
));
2651 check ("real(cexp(-inf + i NaN)) = 0", __real__ result
, 0);
2652 check ("imag(cexp(-inf + i NaN)) = 0", fabs (__imag__ result
), 0);
2654 result
= FUNC(cexp
) (BUILD_COMPLEX (plus_infty
, nan_value
));
2655 check_isinfp ("real(cexp(+inf + i NaN)) = +inf", __real__ result
);
2656 check_isnan ("imag(cexp(+inf + i NaN)) = NaN", __imag__ result
);
2658 result
= FUNC(cexp
) (BUILD_COMPLEX (nan_value
, 0.0));
2659 check_isnan_maybe_exc ("real(cexp(NaN + i0)) = NaN plus maybe invalid exception",
2660 __real__ result
, INVALID_EXCEPTION
);
2661 check_isnan ("imag(cexp(NaN + i0)) = NaN plus maybe invalid exception",
2663 result
= FUNC(cexp
) (BUILD_COMPLEX (nan_value
, 1.0));
2664 check_isnan_maybe_exc ("real(cexp(NaN + 1i)) = NaN plus maybe invalid exception",
2665 __real__ result
, INVALID_EXCEPTION
);
2666 check_isnan ("imag(cexp(NaN + 1i)) = NaN plus maybe invalid exception",
2668 result
= FUNC(cexp
) (BUILD_COMPLEX (nan_value
, plus_infty
));
2669 check_isnan_maybe_exc ("real(cexp(NaN + i inf)) = NaN plus maybe invalid exception",
2670 __real__ result
, INVALID_EXCEPTION
);
2671 check_isnan ("imag(cexp(NaN + i inf)) = NaN plus maybe invalid exception",
2674 result
= FUNC(cexp
) (BUILD_COMPLEX (0, nan_value
));
2675 check_isnan_maybe_exc ("real(cexp(0 + i NaN)) = NaN plus maybe invalid exception",
2676 __real__ result
, INVALID_EXCEPTION
);
2677 check_isnan ("imag(cexp(0 + i NaN)) = NaN plus maybe invalid exception",
2679 result
= FUNC(cexp
) (BUILD_COMPLEX (1, nan_value
));
2680 check_isnan_maybe_exc ("real(cexp(1 + i NaN)) = NaN plus maybe invalid exception",
2681 __real__ result
, INVALID_EXCEPTION
);
2682 check_isnan ("imag(cexp(1 + i NaN)) = NaN plus maybe invalid exception",
2685 result
= FUNC(cexp
) (BUILD_COMPLEX (nan_value
, nan_value
));
2686 check_isnan ("real(cexp(NaN + i NaN)) = NaN", __real__ result
);
2687 check_isnan ("imag(cexp(NaN + i NaN)) = NaN", __imag__ result
);
2689 result
= FUNC(cexp
) (BUILD_COMPLEX (0.7, 1.2));
2690 check_eps ("real(cexp(0.7 + i 1.2)) == 0.72969...", __real__ result
,
2691 0.7296989091503236012L, CHOOSE(6e-17L, 0, 6e-8));
2692 check_eps ("imag(cexp(0.7 + i 1.2)) == 1.87689...", __imag__ result
,
2693 1.8768962328348102821L, CHOOSE(2e-16L, 0, 0));
2695 result
= FUNC(cexp
) (BUILD_COMPLEX (-2, -3));
2696 check_eps ("real(cexp(-2 - i 3)) == --0.13398...", __real__ result
,
2697 -0.1339809149295426134L, CHOOSE(6e-20L, 0, 0));
2698 check_eps ("imag(cexp(-2 - i 3)) == -0.01909...", __imag__ result
,
2699 -0.0190985162611351964L, CHOOSE(4e-20L, 0, 0));
2706 __complex__ MATHTYPE result
;
2708 result
= FUNC(csin
) (BUILD_COMPLEX (0.0, 0.0));
2709 check ("real(csin(0 + 0i)) = 0", __real__ result
, 0);
2710 check ("imag(csin(0 + 0i)) = 0", __imag__ result
, 0);
2711 result
= FUNC(csin
) (BUILD_COMPLEX (minus_zero
, 0.0));
2712 check ("real(csin(-0 + 0i)) = -0", __real__ result
, minus_zero
);
2713 check ("imag(csin(-0 + 0i)) = 0", __imag__ result
, 0);
2714 result
= FUNC(csin
) (BUILD_COMPLEX (0.0, minus_zero
));
2715 check ("real(csin(0 - 0i)) = 0", __real__ result
, 0);
2716 check ("imag(csin(0 - 0i)) = -0", __imag__ result
, minus_zero
);
2717 result
= FUNC(csin
) (BUILD_COMPLEX (minus_zero
, minus_zero
));
2718 check ("real(csin(-0 - 0i)) = -0", __real__ result
, minus_zero
);
2719 check ("imag(csin(-0 - 0i)) = -0", __imag__ result
, minus_zero
);
2721 result
= FUNC(csin
) (BUILD_COMPLEX (0.0, plus_infty
));
2722 check ("real(csin(0 + i Inf)) = 0", __real__ result
, 0);
2723 check_isinfp ("imag(csin(0 + i Inf)) = +Inf", __imag__ result
);
2724 result
= FUNC(csin
) (BUILD_COMPLEX (minus_zero
, plus_infty
));
2725 check ("real(csin(-0 + i Inf)) = -0", __real__ result
, minus_zero
);
2726 check_isinfp ("imag(csin(-0 + i Inf)) = +Inf", __imag__ result
);
2727 result
= FUNC(csin
) (BUILD_COMPLEX (0.0, minus_infty
));
2728 check ("real(csin(0 - i Inf)) = 0", __real__ result
, 0);
2729 check_isinfn ("imag(csin(0 - i Inf)) = -Inf", __imag__ result
);
2730 result
= FUNC(csin
) (BUILD_COMPLEX (minus_zero
, minus_infty
));
2731 check ("real(csin(-0 - i Inf)) = -0", __real__ result
, minus_zero
);
2732 check_isinfn("imag(csin(-0 - i Inf)) = -Inf", __imag__ result
);
2734 result
= FUNC(csin
) (BUILD_COMPLEX (plus_infty
, 0.0));
2735 check_isnan_exc ("real(csin(+Inf + 0i)) = NaN plus invalid exception",
2736 __real__ result
, INVALID_EXCEPTION
);
2737 check ("imag(csin(+Inf + 0i)) = +-0 plus invalid exception",
2738 FUNC(fabs
) (__imag__ result
), 0);
2739 result
= FUNC(csin
) (BUILD_COMPLEX (minus_infty
, 0.0));
2740 check_isnan_exc ("real(csin(-Inf + 0i)) = NaN plus invalid exception",
2741 __real__ result
, INVALID_EXCEPTION
);
2742 check ("imag(csin(-Inf + 0i)) = +-0 plus invalid exception",
2743 FUNC(fabs
) (__imag__ result
), 0);
2744 result
= FUNC(csin
) (BUILD_COMPLEX (plus_infty
, minus_zero
));
2745 check_isnan_exc ("real(csin(+Inf - 0i)) = NaN plus invalid exception",
2746 __real__ result
, INVALID_EXCEPTION
);
2747 check ("imag(csin(+Inf - 0i)) = +-0 plus invalid exception",
2748 FUNC(fabs
) (__imag__ result
), 0.0);
2749 result
= FUNC(csin
) (BUILD_COMPLEX (minus_infty
, minus_zero
));
2750 check_isnan_exc ("real(csin(-Inf - 0i)) = NaN plus invalid exception",
2751 __real__ result
, INVALID_EXCEPTION
);
2752 check ("imag(csin(-Inf - 0i)) = +-0 plus invalid exception",
2753 FUNC(fabs
) (__imag__ result
), 0.0);
2755 result
= FUNC(csin
) (BUILD_COMPLEX (plus_infty
, plus_infty
));
2756 check_isnan_exc ("real(csin(+Inf + i Inf)) = NaN plus invalid exception",
2757 __real__ result
, INVALID_EXCEPTION
);
2758 check_isinfp ("imag(csin(+Inf + i Inf)) = +-Inf plus invalid exception",
2759 FUNC(fabs
) (__imag__ result
));
2760 result
= FUNC(csin
) (BUILD_COMPLEX (minus_infty
, plus_infty
));
2761 check_isnan_exc ("real(csin(-Inf + i Inf)) = NaN plus invalid exception",
2762 __real__ result
, INVALID_EXCEPTION
);
2763 check_isinfp ("imag(csin(-Inf + i Inf)) = +-Inf plus invalid exception",
2764 FUNC(fabs
) (__imag__ result
));
2765 result
= FUNC(csin
) (BUILD_COMPLEX (plus_infty
, minus_infty
));
2766 check_isnan_exc ("real(csin(Inf - i Inf)) = NaN plus invalid exception",
2767 __real__ result
, INVALID_EXCEPTION
);
2768 check_isinfp ("imag(csin(Inf - i Inf)) = +-Inf plus invalid exception",
2769 FUNC(fabs
) (__imag__ result
));
2770 result
= FUNC(csin
) (BUILD_COMPLEX (minus_infty
, minus_infty
));
2771 check_isnan_exc ("real(csin(-Inf - i Inf)) = NaN plus invalid exception",
2772 __real__ result
, INVALID_EXCEPTION
);
2773 check_isinfp ("imag(csin(-Inf - i Inf)) = +-Inf plus invalid exception",
2774 FUNC(fabs
) (__imag__ result
));
2776 result
= FUNC(csin
) (BUILD_COMPLEX (plus_infty
, 6.75));
2777 check_isnan_exc ("real(csin(+Inf + i 6.75)) = NaN plus invalid exception",
2778 __real__ result
, INVALID_EXCEPTION
);
2779 check_isnan ("imag(csin(+Inf + i6.75)) = NaN plus invalid exception",
2781 result
= FUNC(csin
) (BUILD_COMPLEX (plus_infty
, -6.75));
2782 check_isnan_exc ("real(csin(+Inf - i 6.75)) = NaN plus invalid exception",
2783 __real__ result
, INVALID_EXCEPTION
);
2784 check_isnan ("imag(csin(+Inf - i6.75)) = NaN plus invalid exception",
2786 result
= FUNC(csin
) (BUILD_COMPLEX (minus_infty
, 6.75));
2787 check_isnan_exc ("real(csin(-Inf + i6.75)) = NaN plus invalid exception",
2788 __real__ result
, INVALID_EXCEPTION
);
2789 check_isnan ("imag(csin(-Inf + i6.75)) = NaN plus invalid exception",
2791 result
= FUNC(csin
) (BUILD_COMPLEX (minus_infty
, -6.75));
2792 check_isnan_exc ("real(csin(-Inf - i6.75)) = NaN plus invalid exception",
2793 __real__ result
, INVALID_EXCEPTION
);
2794 check_isnan ("imag(csin(-Inf - i6.75)) = NaN plus invalid exception",
2797 result
= FUNC(csin
) (BUILD_COMPLEX (4.625, plus_infty
));
2798 check_isinfn ("real(csin(4.625 + i Inf)) = -Inf", __real__ result
);
2799 check_isinfn ("imag(csin(4.625 + i Inf)) = -Inf", __imag__ result
);
2800 result
= FUNC(csin
) (BUILD_COMPLEX (4.625, minus_infty
));
2801 check_isinfn ("real(csin(4.625 - i Inf)) = -Inf", __real__ result
);
2802 check_isinfp ("imag(csin(4.625 - i Inf)) = +Inf", __imag__ result
);
2803 result
= FUNC(csin
) (BUILD_COMPLEX (-4.625, plus_infty
));
2804 check_isinfp ("real(csin(-4.625 + i Inf)) = +Inf", __real__ result
);
2805 check_isinfn ("imag(csin(-4.625 + i Inf)) = -Inf", __imag__ result
);
2806 result
= FUNC(csin
) (BUILD_COMPLEX (-4.625, minus_infty
));
2807 check_isinfp ("real(csin(-4.625 - i Inf)) = +Inf", __real__ result
);
2808 check_isinfp ("imag(csin(-4.625 - i Inf)) = +Inf", __imag__ result
);
2810 result
= FUNC(csin
) (BUILD_COMPLEX (nan_value
, 0.0));
2811 check_isnan ("real(csin(NaN + i0)) = NaN", __real__ result
);
2812 check ("imag(csin(NaN + i0)) = +-0", FUNC(fabs
) (__imag__ result
), 0);
2813 result
= FUNC(csin
) (BUILD_COMPLEX (nan_value
, minus_zero
));
2814 check_isnan ("real(csin(NaN - i0)) = NaN", __real__ result
);
2815 check ("imag(csin(NaN - i0)) = +-0", FUNC(fabs
) (__imag__ result
), 0);
2817 result
= FUNC(csin
) (BUILD_COMPLEX (nan_value
, plus_infty
));
2818 check_isnan ("real(csin(NaN + i Inf)) = NaN", __real__ result
);
2819 check_isinfp ("imag(csin(NaN + i Inf)) = +-Inf",
2820 FUNC(fabs
) (__imag__ result
));
2821 result
= FUNC(csin
) (BUILD_COMPLEX (nan_value
, minus_infty
));
2822 check_isnan ("real(csin(NaN - i Inf)) = NaN", __real__ result
);
2823 check_isinfp ("real(csin(NaN - i Inf)) = +-Inf",
2824 FUNC(fabs
) (__imag__ result
));
2826 result
= FUNC(csin
) (BUILD_COMPLEX (nan_value
, 9.0));
2827 check_isnan_maybe_exc ("real(csin(NaN + i9.0)) = NaN plus maybe invalid exception",
2828 __real__ result
, INVALID_EXCEPTION
);
2829 check_isnan ("imag(csin(NaN + i9.0)) = NaN plus maybe invalid exception",
2831 result
= FUNC(csin
) (BUILD_COMPLEX (nan_value
, -9.0));
2832 check_isnan_maybe_exc ("real(csin(NaN - i9.0)) = NaN plus maybe invalid exception",
2833 __real__ result
, INVALID_EXCEPTION
);
2834 check_isnan ("imag(csin(NaN - i9.0)) = NaN plus maybe invalid exception",
2837 result
= FUNC(csin
) (BUILD_COMPLEX (0.0, nan_value
));
2838 check ("real(csin(0 + i NaN))", __real__ result
, 0.0);
2839 check_isnan ("imag(csin(0 + i NaN)) = NaN", __imag__ result
);
2840 result
= FUNC(csin
) (BUILD_COMPLEX (minus_zero
, nan_value
));
2841 check ("real(csin(-0 + i NaN)) = -0", __real__ result
, minus_zero
);
2842 check_isnan ("imag(csin(-0 + NaN)) = NaN", __imag__ result
);
2844 result
= FUNC(csin
) (BUILD_COMPLEX (10.0, nan_value
));
2845 check_isnan_maybe_exc ("real(csin(10 + i NaN)) = NaN plus maybe invalid exception",
2846 __real__ result
, INVALID_EXCEPTION
);
2847 check_isnan ("imag(csin(10 + i NaN)) = NaN plus maybe invalid exception",
2849 result
= FUNC(csin
) (BUILD_COMPLEX (nan_value
, -10.0));
2850 check_isnan_maybe_exc ("real(csin(-10 + i NaN)) = NaN plus maybe invalid exception",
2851 __real__ result
, INVALID_EXCEPTION
);
2852 check_isnan ("imag(csin(-10 + i NaN)) = NaN plus maybe invalid exception",
2855 result
= FUNC(csin
) (BUILD_COMPLEX (plus_infty
, nan_value
));
2856 check_isnan_maybe_exc ("real(csin(+Inf + i NaN)) = NaN plus maybe invalid exception",
2857 __real__ result
, INVALID_EXCEPTION
);
2858 check_isnan ("imag(csin(+Inf + i NaN)) = NaN plus maybe invalid exception",
2860 result
= FUNC(csin
) (BUILD_COMPLEX (minus_infty
, nan_value
));
2861 check_isnan_maybe_exc ("real(csin(-Inf + i NaN)) = NaN plus maybe invalid exception",
2862 __real__ result
, INVALID_EXCEPTION
);
2863 check_isnan ("imag(csin(-Inf + i NaN)) = NaN plus maybe invalid exception",
2866 result
= FUNC(csin
) (BUILD_COMPLEX (nan_value
, nan_value
));
2867 check_isnan ("real(csin(NaN + i NaN)) = NaN", __real__ result
);
2868 check_isnan ("imag(csin(NaN + i NaN)) = NaN", __imag__ result
);
2870 result
= FUNC(csin
) (BUILD_COMPLEX (0.7, 1.2));
2871 check_eps ("real(csin(0.7 + i 1.2)) = 1.166456341...", __real__ result
,
2872 1.1664563419657581376L, CHOOSE(2e-16L, 0, 0));
2873 check_eps ("imag(csin(0.7 + i 1.2)) = 1.154499724...", __imag__ result
,
2874 1.1544997246948547371L, CHOOSE(2e-17L, 0, 0));
2876 result
= FUNC(csin
) (BUILD_COMPLEX (-2, -3));
2877 check ("real(csin(-2 - i 3)) == --9.15449...", __real__ result
,
2878 -9.1544991469114295734L);
2879 check ("imag(csin(-2 - i 3)) == -4.16890...", __imag__ result
,
2880 4.1689069599665643507L);
2887 __complex__ MATHTYPE result
;
2889 result
= FUNC(csinh
) (BUILD_COMPLEX (0.0, 0.0));
2890 check ("real(csinh(0 + 0i)) = 0", __real__ result
, 0);
2891 check ("imag(csinh(0 + 0i)) = 0", __imag__ result
, 0);
2892 result
= FUNC(csinh
) (BUILD_COMPLEX (minus_zero
, 0.0));
2893 check ("real(csinh(-0 + 0i)) = -0", __real__ result
, minus_zero
);
2894 check ("imag(csinh(-0 + 0i)) = 0", __imag__ result
, 0);
2895 result
= FUNC(csinh
) (BUILD_COMPLEX (0.0, minus_zero
));
2896 check ("real(csinh(0 - 0i)) = 0", __real__ result
, 0);
2897 check ("imag(csinh(0 - 0i)) = -0", __imag__ result
, minus_zero
);
2898 result
= FUNC(csinh
) (BUILD_COMPLEX (minus_zero
, minus_zero
));
2899 check ("real(csinh(-0 - 0i)) = -0", __real__ result
, minus_zero
);
2900 check ("imag(csinh(-0 - 0i)) = -0", __imag__ result
, minus_zero
);
2902 result
= FUNC(csinh
) (BUILD_COMPLEX (0.0, plus_infty
));
2903 check_exc ("real(csinh(0 + i Inf)) = +-0 plus invalid exception",
2904 FUNC(fabs
) (__real__ result
), 0, INVALID_EXCEPTION
);
2905 check_isnan ("imag(csinh(0 + i Inf)) = NaN plus invalid exception",
2907 result
= FUNC(csinh
) (BUILD_COMPLEX (minus_zero
, plus_infty
));
2908 check_exc ("real(csinh(-0 + i Inf)) = +-0 plus invalid exception",
2909 FUNC(fabs
) (__real__ result
), 0, INVALID_EXCEPTION
);
2910 check_isnan ("imag(csinh(-0 + i Inf)) = NaN plus invalid exception",
2912 result
= FUNC(csinh
) (BUILD_COMPLEX (0.0, minus_infty
));
2913 check_exc ("real(csinh(0 - i Inf)) = +-0 plus invalid exception",
2914 FUNC(fabs
) (__real__ result
), 0, INVALID_EXCEPTION
);
2915 check_isnan ("imag(csinh(0 - i Inf)) = NaN plus invalid exception",
2917 result
= FUNC(csinh
) (BUILD_COMPLEX (minus_zero
, minus_infty
));
2918 check_exc ("real(csinh(-0 - i Inf)) = +-0 plus invalid exception",
2919 FUNC(fabs
) (__real__ result
), 0, INVALID_EXCEPTION
);
2920 check_isnan ("imag(csinh(-0 - i Inf)) = NaN plus invalid exception",
2923 result
= FUNC(csinh
) (BUILD_COMPLEX (plus_infty
, 0.0));
2924 check_isinfp ("real(csinh(+Inf + 0i)) = +Inf", __real__ result
);
2925 check ("imag(csinh(+Inf + 0i)) = 0", __imag__ result
, 0);
2926 result
= FUNC(csinh
) (BUILD_COMPLEX (minus_infty
, 0.0));
2927 check_isinfn ("real(csinh(-Inf + 0i)) = -Inf", __real__ result
);
2928 check ("imag(csinh(-Inf + 0i)) = 0", __imag__ result
, 0);
2929 result
= FUNC(csinh
) (BUILD_COMPLEX (plus_infty
, minus_zero
));
2930 check_isinfp ("real(csinh(+Inf - 0i)) = +Inf", __real__ result
);
2931 check ("imag(csinh(+Inf - 0i)) = -0", __imag__ result
, minus_zero
);
2932 result
= FUNC(csinh
) (BUILD_COMPLEX (minus_infty
, minus_zero
));
2933 check_isinfn ("real(csinh(-Inf - 0i)) = -Inf", __real__ result
);
2934 check ("imag(csinh(-Inf - 0i)) = -0", __imag__ result
, minus_zero
);
2936 result
= FUNC(csinh
) (BUILD_COMPLEX (plus_infty
, plus_infty
));
2937 check_isinfp_exc ("real(csinh(+Inf + i Inf)) = +-Inf plus invalid exception",
2938 FUNC(fabs
) (__real__ result
), INVALID_EXCEPTION
);
2939 check_isnan ("imag(csinh(+Inf + i Inf)) = NaN plus invalid exception",
2941 result
= FUNC(csinh
) (BUILD_COMPLEX (minus_infty
, plus_infty
));
2942 check_isinfp_exc ("real(csinh(-Inf + i Inf)) = +-Inf plus invalid exception",
2943 FUNC(fabs
) (__real__ result
), INVALID_EXCEPTION
);
2944 check_isnan ("imag(csinh(-Inf + i Inf)) = NaN plus invalid exception",
2946 result
= FUNC(csinh
) (BUILD_COMPLEX (plus_infty
, minus_infty
));
2947 check_isinfp_exc ("real(csinh(Inf - i Inf)) = +-Inf plus invalid exception",
2948 FUNC(fabs
) (__real__ result
), INVALID_EXCEPTION
);
2949 check_isnan ("imag(csinh(Inf - i Inf)) = NaN plus invalid exception",
2951 result
= FUNC(csinh
) (BUILD_COMPLEX (minus_infty
, minus_infty
));
2952 check_isinfp_exc ("real(csinh(-Inf - i Inf)) = +-Inf plus invalid exception",
2953 FUNC(fabs
) (__real__ result
), INVALID_EXCEPTION
);
2954 check_isnan ("imag(csinh(-Inf - i Inf)) = NaN plus invalid exception",
2957 result
= FUNC(csinh
) (BUILD_COMPLEX (plus_infty
, 4.625));
2958 check_isinfn ("real(csinh(+Inf + i4.625)) = -Inf", __real__ result
);
2959 check_isinfn ("imag(csinh(+Inf + i4.625)) = -Inf", __imag__ result
);
2960 result
= FUNC(csinh
) (BUILD_COMPLEX (minus_infty
, 4.625));
2961 check_isinfp ("real(csinh(-Inf + i4.625)) = +Inf", __real__ result
);
2962 check_isinfn ("imag(csinh(-Inf + i4.625)) = -Inf", __imag__ result
);
2963 result
= FUNC(csinh
) (BUILD_COMPLEX (plus_infty
, -4.625));
2964 check_isinfn ("real(csinh(+Inf - i4.625)) = -Inf", __real__ result
);
2965 check_isinfp ("imag(csinh(+Inf - i4.625)) = +Inf", __imag__ result
);
2966 result
= FUNC(csinh
) (BUILD_COMPLEX (minus_infty
, -4.625));
2967 check_isinfp ("real(csinh(-Inf - i4.625)) = +Inf", __real__ result
);
2968 check_isinfp ("imag(csinh(-Inf - i4.625)) = +Inf", __imag__ result
);
2970 result
= FUNC(csinh
) (BUILD_COMPLEX (6.75, plus_infty
));
2971 check_isnan_exc ("real(csinh(6.75 + i Inf)) = NaN plus invalid exception",
2972 __real__ result
, INVALID_EXCEPTION
);
2973 check_isnan ("imag(csinh(6.75 + i Inf)) = NaN plus invalid exception",
2975 result
= FUNC(csinh
) (BUILD_COMPLEX (-6.75, plus_infty
));
2976 check_isnan_exc ("real(csinh(-6.75 + i Inf)) = NaN plus invalid exception",
2977 __real__ result
, INVALID_EXCEPTION
);
2978 check_isnan ("imag(csinh(-6.75 + i Inf)) = NaN plus invalid exception",
2980 result
= FUNC(csinh
) (BUILD_COMPLEX (6.75, minus_infty
));
2981 check_isnan_exc ("real(csinh(6.75 - i Inf)) = NaN plus invalid exception",
2982 __real__ result
, INVALID_EXCEPTION
);
2983 check_isnan ("imag(csinh(6.75 - i Inf)) = NaN plus invalid exception",
2985 result
= FUNC(csinh
) (BUILD_COMPLEX (-6.75, minus_infty
));
2986 check_isnan_exc ("real(csinh(-6.75 - i Inf)) = NaN plus invalid exception",
2987 __real__ result
, INVALID_EXCEPTION
);
2988 check_isnan ("imag(csinh(-6.75 - i Inf)) = NaN plus invalid exception",
2991 result
= FUNC(csinh
) (BUILD_COMPLEX (0.0, nan_value
));
2992 check ("real(csinh(0 + i NaN)) = +-0", FUNC(fabs
) (__real__ result
), 0);
2993 check_isnan ("imag(csinh(0 + i NaN)) = NaN", __imag__ result
);
2994 result
= FUNC(csinh
) (BUILD_COMPLEX (minus_zero
, nan_value
));
2995 check ("real(csinh(-0 + i NaN)) = +-0", FUNC(fabs
) (__real__ result
), 0);
2996 check_isnan ("imag(csinh(-0 + i NaN)) = NaN", __imag__ result
);
2998 result
= FUNC(csinh
) (BUILD_COMPLEX (plus_infty
, nan_value
));
2999 check_isinfp ("real(csinh(+Inf + i NaN)) = +-Inf",
3000 FUNC(fabs
) (__real__ result
));
3001 check_isnan ("imag(csinh(+Inf + i NaN)) = NaN", __imag__ result
);
3002 result
= FUNC(csinh
) (BUILD_COMPLEX (minus_infty
, nan_value
));
3003 check_isinfp ("real(csinh(-Inf + i NaN)) = +-Inf",
3004 FUNC(fabs
) (__real__ result
));
3005 check_isnan ("imag(csinh(-Inf + i NaN)) = NaN", __imag__ result
);
3007 result
= FUNC(csinh
) (BUILD_COMPLEX (9.0, nan_value
));
3008 check_isnan_maybe_exc ("real(csinh(9.0 + i NaN)) = NaN plus maybe invalid exception",
3009 __real__ result
, INVALID_EXCEPTION
);
3010 check_isnan ("imag(csinh(9.0 + i NaN)) = NaN plus maybe invalid exception",
3012 result
= FUNC(csinh
) (BUILD_COMPLEX (-9.0, nan_value
));
3013 check_isnan_maybe_exc ("real(csinh(-9.0 + i NaN)) = NaN plus maybe invalid exception",
3014 __real__ result
, INVALID_EXCEPTION
);
3015 check_isnan ("imag(csinh(-9.0 + i NaN)) = NaN plus maybe invalid exception",
3018 result
= FUNC(csinh
) (BUILD_COMPLEX (nan_value
, 0.0));
3019 check_isnan ("real(csinh(NaN + i0)) = NaN", __real__ result
);
3020 check ("imag(csinh(NaN + i0)) = 0", __imag__ result
, 0.0);
3021 result
= FUNC(csinh
) (BUILD_COMPLEX (nan_value
, minus_zero
));
3022 check_isnan ("real(csinh(NaN - i0)) = NaN", __real__ result
);
3023 check ("imag(csinh(NaN - i0)) = -0", __imag__ result
, minus_zero
);
3025 result
= FUNC(csinh
) (BUILD_COMPLEX (nan_value
, 10.0));
3026 check_isnan_maybe_exc ("real(csinh(NaN + i10)) = NaN plus maybe invalid exception",
3027 __real__ result
, INVALID_EXCEPTION
);
3028 check_isnan ("imag(csinh(NaN + i10)) = NaN plus maybe invalid exception",
3030 result
= FUNC(csinh
) (BUILD_COMPLEX (nan_value
, -10.0));
3031 check_isnan_maybe_exc ("real(csinh(NaN - i10)) = NaN plus maybe invalid exception",
3032 __real__ result
, INVALID_EXCEPTION
);
3033 check_isnan ("imag(csinh(NaN - i10)) = NaN plus maybe invalid exception",
3036 result
= FUNC(csinh
) (BUILD_COMPLEX (nan_value
, plus_infty
));
3037 check_isnan_maybe_exc ("real(csinh(NaN + i Inf)) = NaN plus maybe invalid exception",
3038 __real__ result
, INVALID_EXCEPTION
);
3039 check_isnan ("imag(csinh(NaN + i Inf)) = NaN plus maybe invalid exception",
3041 result
= FUNC(csinh
) (BUILD_COMPLEX (nan_value
, minus_infty
));
3042 check_isnan_maybe_exc ("real(csinh(NaN - i Inf)) = NaN plus maybe invalid exception",
3043 __real__ result
, INVALID_EXCEPTION
);
3044 check_isnan ("imag(csinh(NaN - i Inf)) = NaN plus maybe invalid exception",
3047 result
= FUNC(csinh
) (BUILD_COMPLEX (nan_value
, nan_value
));
3048 check_isnan ("real(csinh(NaN + i NaN)) = NaN", __real__ result
);
3049 check_isnan ("imag(csinh(NaN + i NaN)) = NaN", __imag__ result
);
3051 result
= FUNC(csinh
) (BUILD_COMPLEX (0.7, 1.2));
3052 check_eps ("real(csinh(0.7 + i 1.2)) = 0.274878686...", __real__ result
,
3053 0.27487868678117583582L, CHOOSE(2e-17L, 6e-17, 3e-8));
3054 check_eps ("imag(csinh(0.7 + i 1.2)) = 1.169866572...", __imag__ result
,
3055 1.1698665727426565139L, CHOOSE(6e-17L, 0, 3e-8));
3057 result
= FUNC(csinh
) (BUILD_COMPLEX (-2, -3));
3058 check_eps ("real(csinh(-2 - i 3)) == -3.59056...", __real__ result
,
3059 3.5905645899857799520L, CHOOSE(0, 5e-16, 0));
3060 check_eps ("imag(csinh(-2 - i 3)) == -0.53092...", __imag__ result
,
3061 -0.5309210862485198052L, CHOOSE(2e-19L, 2e-16, 6e-8));
3068 __complex__ MATHTYPE result
;
3070 result
= FUNC(ccos
) (BUILD_COMPLEX (0.0, 0.0));
3071 check ("real(ccos(0 + 0i)) = 1.0", __real__ result
, 1.0);
3072 check ("imag(ccos(0 + 0i)) = -0", __imag__ result
, minus_zero
);
3073 result
= FUNC(ccos
) (BUILD_COMPLEX (minus_zero
, 0.0));
3074 check ("real(ccos(-0 + 0i)) = 1.0", __real__ result
, 1.0);
3075 check ("imag(ccos(-0 + 0i)) = 0", __imag__ result
, 0.0);
3076 result
= FUNC(ccos
) (BUILD_COMPLEX (0.0, minus_zero
));
3077 check ("real(ccos(0 - 0i)) = 1.0", __real__ result
, 1.0);
3078 check ("imag(ccos(0 - 0i)) = 0", __imag__ result
, 0.0);
3079 result
= FUNC(ccos
) (BUILD_COMPLEX (minus_zero
, minus_zero
));
3080 check ("real(ccos(-0 - 0i)) = 1.0", __real__ result
, 1.0);
3081 check ("imag(ccos(-0 - 0i)) = -0", __imag__ result
, minus_zero
);
3083 result
= FUNC(ccos
) (BUILD_COMPLEX (plus_infty
, 0.0));
3084 check_isnan_exc ("real(ccos(+Inf + i0)) = NaN plus invalid exception",
3085 __real__ result
, INVALID_EXCEPTION
);
3086 check ("imag(ccos(Inf + i0)) = +-0 plus invalid exception",
3087 FUNC(fabs
) (__imag__ result
), 0);
3088 result
= FUNC(ccos
) (BUILD_COMPLEX (plus_infty
, minus_zero
));
3089 check_isnan_exc ("real(ccos(Inf - i0)) = NaN plus invalid exception",
3090 __real__ result
, INVALID_EXCEPTION
);
3091 check ("imag(ccos(Inf - i0)) = +-0 plus invalid exception",
3092 FUNC(fabs
) (__imag__ result
), 0);
3093 result
= FUNC(ccos
) (BUILD_COMPLEX (minus_infty
, 0.0));
3094 check_isnan_exc ("real(ccos(-Inf + i0)) = NaN plus invalid exception",
3095 __real__ result
, INVALID_EXCEPTION
);
3096 check ("imag(ccos(-Inf + i0)) = +-0 plus invalid exception",
3097 FUNC(fabs
) (__imag__ result
), 0);
3098 result
= FUNC(ccos
) (BUILD_COMPLEX (minus_infty
, minus_zero
));
3099 check_isnan_exc ("real(ccos(-Inf - i0)) = NaN plus invalid exception",
3100 __real__ result
, INVALID_EXCEPTION
);
3101 check ("imag(ccos(-Inf - i0)) = +-0 plus invalid exception",
3102 FUNC(fabs
) (__imag__ result
), 0);
3104 result
= FUNC(ccos
) (BUILD_COMPLEX (0.0, plus_infty
));
3105 check_isinfp ("real(ccos(0 + i Inf)) = +Inf", __real__ result
);
3106 check ("imag(ccos(0 + i Inf)) = -0", __imag__ result
, minus_zero
);
3107 result
= FUNC(ccos
) (BUILD_COMPLEX (0.0, minus_infty
));
3108 check_isinfp ("real(ccos(0 - i Inf)) = +Inf", __real__ result
);
3109 check ("imag(ccos(0 - i Inf)) = 0", __imag__ result
, 0);
3110 result
= FUNC(ccos
) (BUILD_COMPLEX (minus_zero
, plus_infty
));
3111 check_isinfp ("real(ccos(-0 + i Inf)) = +Inf", __real__ result
);
3112 check ("imag(ccos(-0 + i Inf)) = 0", __imag__ result
, 0.0);
3113 result
= FUNC(ccos
) (BUILD_COMPLEX (minus_zero
, minus_infty
));
3114 check_isinfp ("real(ccos(-0 - i Inf)) = +Inf", __real__ result
);
3115 check ("imag(ccos(-0 - i Inf)) = -0", __imag__ result
, minus_zero
);
3117 result
= FUNC(ccos
) (BUILD_COMPLEX (plus_infty
, plus_infty
));
3118 check_isinfp_exc ("real(ccos(+Inf + i Inf)) = +Inf plus invalid exception",
3119 __real__ result
, INVALID_EXCEPTION
);
3120 check_isnan ("imag(ccos(+Inf + i Inf)) = NaN plus invalid exception",
3122 result
= FUNC(ccos
) (BUILD_COMPLEX (minus_infty
, plus_infty
));
3123 check_isinfp_exc ("real(ccos(-Inf + i Inf)) = +Inf plus invalid exception",
3124 __real__ result
, INVALID_EXCEPTION
);
3125 check_isnan ("imag(ccos(-Inf + i Inf)) = NaN plus invalid exception",
3127 result
= FUNC(ccos
) (BUILD_COMPLEX (plus_infty
, minus_infty
));
3128 check_isinfp_exc ("real(ccos(Inf - i Inf)) = +Inf plus invalid exception",
3129 __real__ result
, INVALID_EXCEPTION
);
3130 check_isnan ("imag(ccos(Inf - i Inf)) = NaN plus invalid exception",
3132 result
= FUNC(ccos
) (BUILD_COMPLEX (minus_infty
, minus_infty
));
3133 check_isinfp_exc ("real(ccos(-Inf - i Inf)) = +Inf plus invalid exception",
3134 __real__ result
, INVALID_EXCEPTION
);
3135 check_isnan ("imag(ccos(-Inf - i Inf)) = NaN plus invalid exception",
3138 result
= FUNC(ccos
) (BUILD_COMPLEX (4.625, plus_infty
));
3139 check_isinfn ("real(ccos(4.625 + i Inf)) = -Inf", __real__ result
);
3140 check_isinfp ("imag(ccos(4.625 + i Inf)) = +Inf", __imag__ result
);
3141 result
= FUNC(ccos
) (BUILD_COMPLEX (4.625, minus_infty
));
3142 check_isinfn ("real(ccos(4.625 - i Inf)) = -Inf", __real__ result
);
3143 check_isinfn ("imag(ccos(4.625 - i Inf)) = -Inf", __imag__ result
);
3144 result
= FUNC(ccos
) (BUILD_COMPLEX (-4.625, plus_infty
));
3145 check_isinfn ("real(ccos(-4.625 + i Inf)) = -Inf", __real__ result
);
3146 check_isinfn ("imag(ccos(-4.625 + i Inf)) = -Inf", __imag__ result
);
3147 result
= FUNC(ccos
) (BUILD_COMPLEX (-4.625, minus_infty
));
3148 check_isinfn ("real(ccos(-4.625 - i Inf)) = -Inf", __real__ result
);
3149 check_isinfp ("imag(ccos(-4.625 - i Inf)) = +Inf", __imag__ result
);
3151 result
= FUNC(ccos
) (BUILD_COMPLEX (plus_infty
, 6.75));
3152 check_isnan_exc ("real(ccos(+Inf + i6.75)) = NaN plus invalid exception",
3153 __real__ result
, INVALID_EXCEPTION
);
3154 check_isnan ("imag(ccos(+Inf + i6.75)) = NaN plus invalid exception",
3156 result
= FUNC(ccos
) (BUILD_COMPLEX (plus_infty
, -6.75));
3157 check_isnan_exc ("real(ccos(+Inf - i6.75)) = NaN plus invalid exception",
3158 __real__ result
, INVALID_EXCEPTION
);
3159 check_isnan ("imag(ccos(+Inf - i6.75)) = NaN plus invalid exception",
3161 result
= FUNC(ccos
) (BUILD_COMPLEX (minus_infty
, 6.75));
3162 check_isnan_exc ("real(ccos(-Inf + i6.75)) = NaN plus invalid exception",
3163 __real__ result
, INVALID_EXCEPTION
);
3164 check_isnan ("imag(ccos(-Inf + i6.75)) = NaN plus invalid exception",
3166 result
= FUNC(ccos
) (BUILD_COMPLEX (minus_infty
, -6.75));
3167 check_isnan_exc ("real(ccos(-Inf - i6.75)) = NaN plus invalid exception",
3168 __real__ result
, INVALID_EXCEPTION
);
3169 check_isnan ("imag(ccos(-Inf - i6.75)) = NaN plus invalid exception",
3172 result
= FUNC(ccos
) (BUILD_COMPLEX (nan_value
, 0.0));
3173 check_isnan ("real(ccos(NaN + i0)) = NaN", __real__ result
);
3174 check ("imag(ccos(NaN + i0)) = +-0", FUNC(fabs
) (__imag__ result
), 0);
3175 result
= FUNC(ccos
) (BUILD_COMPLEX (nan_value
, minus_zero
));
3176 check_isnan ("real(ccos(NaN - i0)) = NaN", __real__ result
);
3177 check ("imag(ccos(NaN - i0)) = +-0", FUNC(fabs
) (__imag__ result
), 0);
3179 result
= FUNC(ccos
) (BUILD_COMPLEX (nan_value
, plus_infty
));
3180 check_isinfp ("real(ccos(NaN + i Inf)) = +Inf", __real__ result
);
3181 check_isnan ("imag(ccos(NaN + i Inf)) = NaN", __imag__ result
);
3182 result
= FUNC(ccos
) (BUILD_COMPLEX (nan_value
, minus_infty
));
3183 check_isinfp ("real(ccos(NaN - i Inf)) = +Inf", __real__ result
);
3184 check_isnan ("imag(ccos(NaN - i Inf)) = NaN", __imag__ result
);
3186 result
= FUNC(ccos
) (BUILD_COMPLEX (nan_value
, 9.0));
3187 check_isnan_maybe_exc ("real(ccos(NaN + i9.0)) = NaN plus maybe invalid exception",
3188 __real__ result
, INVALID_EXCEPTION
);
3189 check_isnan ("imag(ccos(NaN + i9.0)) = NaN plus maybe invalid exception",
3191 result
= FUNC(ccos
) (BUILD_COMPLEX (nan_value
, -9.0));
3192 check_isnan_maybe_exc ("real(ccos(NaN - i9.0)) = NaN plus maybe invalid exception",
3193 __real__ result
, INVALID_EXCEPTION
);
3194 check_isnan ("imag(ccos(NaN - i9.0)) = NaN plus maybe invalid exception",
3197 result
= FUNC(ccos
) (BUILD_COMPLEX (0.0, nan_value
));
3198 check_isnan ("real(ccos(0 + i NaN)) = NaN", __real__ result
);
3199 check ("imag(ccos(0 + i NaN)) = +-0", FUNC(fabs
) (__imag__ result
), 0.0);
3200 result
= FUNC(ccos
) (BUILD_COMPLEX (minus_zero
, nan_value
));
3201 check_isnan ("real(ccos(-0 + i NaN)) = NaN", __real__ result
);
3202 check ("imag(ccos(-0 + i NaN)) = +-0", FUNC(fabs
) (__imag__ result
), 0.0);
3204 result
= FUNC(ccos
) (BUILD_COMPLEX (10.0, nan_value
));
3205 check_isnan_maybe_exc ("real(ccos(10 + i NaN)) = NaN plus maybe invalid exception",
3206 __real__ result
, INVALID_EXCEPTION
);
3207 check_isnan ("imag(ccos(10 + i NaN)) = NaN plus maybe invalid exception",
3209 result
= FUNC(ccos
) (BUILD_COMPLEX (-10.0, nan_value
));
3210 check_isnan_maybe_exc ("real(ccos(-10 + i NaN)) = NaN plus maybe invalid exception",
3211 __real__ result
, INVALID_EXCEPTION
);
3212 check_isnan ("imag(ccos(-10 + i NaN)) = NaN plus maybe invalid exception",
3215 result
= FUNC(ccos
) (BUILD_COMPLEX (plus_infty
, nan_value
));
3216 check_isnan_maybe_exc ("real(ccos(+Inf + i NaN)) = NaN plus maybe invalid exception",
3217 __real__ result
, INVALID_EXCEPTION
);
3218 check_isnan ("imag(ccos(+Inf + i NaN)) = NaN plus maybe invalid exception",
3220 result
= FUNC(ccos
) (BUILD_COMPLEX (minus_infty
, nan_value
));
3221 check_isnan_maybe_exc ("real(ccos(-Inf + i NaN)) = NaN plus maybe invalid exception",
3222 __real__ result
, INVALID_EXCEPTION
);
3223 check_isnan ("imag(ccos(-Inf + i NaN)) = NaN plus maybe invalid exception",
3226 result
= FUNC(ccos
) (BUILD_COMPLEX (nan_value
, nan_value
));
3227 check_isnan ("real(ccos(NaN + i NaN)) = NaN", __real__ result
);
3228 check_isnan ("imag(ccos(NaN + i NaN)) = NaN", __imag__ result
);
3230 result
= FUNC(ccos
) (BUILD_COMPLEX (0.7, 1.2));
3231 check_eps ("real(ccos(0.7 + i 1.2)) = 1.384865764...", __real__ result
,
3232 1.3848657645312111080L, CHOOSE(6e-19L, 3e-16, 2e-7));
3233 check_eps ("imag(ccos(0.7 + i 1.2)) = -0.972421703...", __imag__ result
,
3234 -0.97242170335830028619L, CHOOSE(2e-16L, 2e-16, 0));
3236 result
= FUNC(ccos
) (BUILD_COMPLEX (-2, -3));
3237 check ("real(ccos(-2 - i 3)) == --4.18962...", __real__ result
,
3238 -4.1896256909688072301L);
3239 check_eps ("imag(ccos(-2 - i 3)) == -9.10922...", __imag__ result
,
3240 -9.1092278937553365979L, CHOOSE(9e-19L, 0, 1e-6));
3247 __complex__ MATHTYPE result
;
3249 result
= FUNC(ccosh
) (BUILD_COMPLEX (0.0, 0.0));
3250 check ("real(ccosh(0 + 0i)) = 1.0", __real__ result
, 1.0);
3251 check ("imag(ccosh(0 + 0i)) = 0", __imag__ result
, 0);
3252 result
= FUNC(ccosh
) (BUILD_COMPLEX (minus_zero
, 0.0));
3253 check ("real(ccosh(-0 + 0i)) = 1.0", __real__ result
, 1.0);
3254 check ("imag(ccosh(-0 + 0i)) = -0", __imag__ result
, minus_zero
);
3255 result
= FUNC(ccosh
) (BUILD_COMPLEX (0.0, minus_zero
));
3256 check ("real(ccosh(0 - 0i)) = 1.0", __real__ result
, 1.0);
3257 check ("imag(ccosh(0 - 0i)) = -0", __imag__ result
, minus_zero
);
3258 result
= FUNC(ccosh
) (BUILD_COMPLEX (minus_zero
, minus_zero
));
3259 check ("real(ccosh(-0 - 0i)) = 1.0", __real__ result
, 1.0);
3260 check ("imag(ccosh(-0 - 0i)) = 0", __imag__ result
, 0.0);
3262 result
= FUNC(ccosh
) (BUILD_COMPLEX (0.0, plus_infty
));
3263 check_isnan_exc ("real(ccosh(0 + i Inf)) = NaN plus invalid exception",
3264 __real__ result
, INVALID_EXCEPTION
);
3265 check ("imag(ccosh(0 + i Inf)) = +-0 plus invalid exception",
3266 FUNC(fabs
) (__imag__ result
), 0);
3267 result
= FUNC(ccosh
) (BUILD_COMPLEX (minus_zero
, plus_infty
));
3268 check_isnan_exc ("real(ccosh(-0 + i Inf)) = NaN plus invalid exception",
3269 __real__ result
, INVALID_EXCEPTION
);
3270 check ("imag(ccosh(-0 + i Inf)) = +-0 plus invalid exception",
3271 FUNC(fabs
) (__imag__ result
), 0);
3272 result
= FUNC(ccosh
) (BUILD_COMPLEX (0.0, minus_infty
));
3273 check_isnan_exc ("real(ccosh(0 - i Inf)) = NaN plus invalid exception",
3274 __real__ result
, INVALID_EXCEPTION
);
3275 check ("imag(ccosh(0 - i Inf)) = +-0 plus invalid exception",
3276 FUNC(fabs
) (__imag__ result
), 0);
3277 result
= FUNC(ccosh
) (BUILD_COMPLEX (minus_zero
, minus_infty
));
3278 check_isnan_exc ("real(ccosh(-0 - i Inf)) = NaN plus invalid exception",
3279 __real__ result
, INVALID_EXCEPTION
);
3280 check ("imag(ccosh(-0 - i Inf)) = +-0 plus invalid exception",
3281 FUNC(fabs
) (__imag__ result
), 0);
3283 result
= FUNC(ccosh
) (BUILD_COMPLEX (plus_infty
, 0.0));
3284 check_isinfp ("real(ccosh(+Inf + 0i)) = +Inf", __real__ result
);
3285 check ("imag(ccosh(+Inf + 0i)) = 0", __imag__ result
, 0);
3286 result
= FUNC(ccosh
) (BUILD_COMPLEX (minus_infty
, 0.0));
3287 check_isinfp ("real(ccosh(-Inf + 0i)) = +Inf", __real__ result
);
3288 check ("imag(ccosh(-Inf + 0i)) = -0", __imag__ result
, minus_zero
);
3289 result
= FUNC(ccosh
) (BUILD_COMPLEX (plus_infty
, minus_zero
));
3290 check_isinfp ("real(ccosh(+Inf - 0i)) = +Inf", __real__ result
);
3291 check ("imag(ccosh(+Inf - 0i)) = -0", __imag__ result
, minus_zero
);
3292 result
= FUNC(ccosh
) (BUILD_COMPLEX (minus_infty
, minus_zero
));
3293 check_isinfp ("real(ccosh(-Inf - 0i)) = +Inf", __real__ result
);
3294 check ("imag(ccosh(-Inf - 0i)) = 0", __imag__ result
, 0.0);
3296 result
= FUNC(ccosh
) (BUILD_COMPLEX (plus_infty
, plus_infty
));
3297 check_isinfp_exc ("real(ccosh(+Inf + i Inf)) = +Inf plus invalid exception",
3298 __real__ result
, INVALID_EXCEPTION
);
3299 check_isnan ("imag(ccosh(+Inf + i Inf)) = NaN plus invalid exception",
3301 result
= FUNC(ccosh
) (BUILD_COMPLEX (minus_infty
, plus_infty
));
3302 check_isinfp_exc ("real(ccosh(-Inf + i Inf)) = +Inf plus invalid exception",
3303 __real__ result
, INVALID_EXCEPTION
);
3304 check_isnan ("imag(ccosh(-Inf + i Inf)) = NaN plus invalid exception",
3306 result
= FUNC(ccosh
) (BUILD_COMPLEX (plus_infty
, minus_infty
));
3307 check_isinfp_exc ("real(ccosh(Inf - i Inf)) = +Inf plus invalid exception",
3308 __real__ result
, INVALID_EXCEPTION
);
3309 check_isnan ("imag(ccosh(Inf - i Inf)) = NaN plus invalid exception",
3311 result
= FUNC(ccosh
) (BUILD_COMPLEX (minus_infty
, minus_infty
));
3312 check_isinfp_exc ("real(ccosh(-Inf - i Inf)) = +Inf plus invalid exception",
3313 __real__ result
, INVALID_EXCEPTION
);
3314 check_isnan ("imag(ccosh(-Inf - i Inf)) = NaN plus invalid exception",
3317 result
= FUNC(ccosh
) (BUILD_COMPLEX (plus_infty
, 4.625));
3318 check_isinfn ("real(ccosh(+Inf + i4.625)) = -Inf", __real__ result
);
3319 check_isinfn ("imag(ccosh(+Inf + i4.625)) = -Inf", __imag__ result
);
3320 result
= FUNC(ccosh
) (BUILD_COMPLEX (minus_infty
, 4.625));
3321 check_isinfn ("real(ccosh(-Inf + i4.625)) = -Inf", __real__ result
);
3322 check_isinfp ("imag(ccosh(-Inf + i4.625)) = Inf", __imag__ result
);
3323 result
= FUNC(ccosh
) (BUILD_COMPLEX (plus_infty
, -4.625));
3324 check_isinfn ("real(ccosh(+Inf - i4.625)) = -Inf", __real__ result
);
3325 check_isinfp ("imag(ccosh(+Inf - i4.625)) = +Inf", __imag__ result
);
3326 result
= FUNC(ccosh
) (BUILD_COMPLEX (minus_infty
, -4.625));
3327 check_isinfn ("real(ccosh(-Inf - i4.625)) = -Inf", __real__ result
);
3328 check_isinfn ("imag(ccosh(-Inf - i4.625)) = -Inf", __imag__ result
);
3330 result
= FUNC(ccosh
) (BUILD_COMPLEX (6.75, plus_infty
));
3331 check_isnan_exc ("real(ccosh(6.75 + i Inf)) = NaN plus invalid exception",
3332 __real__ result
, INVALID_EXCEPTION
);
3333 check_isnan ("imag(ccosh(6.75 + i Inf)) = NaN plus invalid exception",
3335 result
= FUNC(ccosh
) (BUILD_COMPLEX (-6.75, plus_infty
));
3336 check_isnan_exc ("real(ccosh(-6.75 + i Inf)) = NaN plus invalid exception",
3337 __real__ result
, INVALID_EXCEPTION
);
3338 check_isnan ("imag(ccosh(-6.75 + i Inf)) = NaN plus invalid exception",
3340 result
= FUNC(ccosh
) (BUILD_COMPLEX (6.75, minus_infty
));
3341 check_isnan_exc ("real(ccosh(6.75 - i Inf)) = NaN plus invalid exception",
3342 __real__ result
, INVALID_EXCEPTION
);
3343 check_isnan ("imag(ccosh(6.75 - i Inf)) = NaN plus invalid exception",
3345 result
= FUNC(ccosh
) (BUILD_COMPLEX (-6.75, minus_infty
));
3346 check_isnan_exc ("real(ccosh(-6.75 - i Inf)) = NaN plus invalid exception",
3347 __real__ result
, INVALID_EXCEPTION
);
3348 check_isnan ("imag(ccosh(-6.75 - i Inf)) = NaN plus invalid exception",
3351 result
= FUNC(ccosh
) (BUILD_COMPLEX (0.0, nan_value
));
3352 check_isnan ("real(ccosh(0 + i NaN)) = NaN", __real__ result
);
3353 check ("imag(ccosh(0 + i NaN)) = +-0", FUNC(fabs
) (__imag__ result
), 0);
3354 result
= FUNC(ccosh
) (BUILD_COMPLEX (minus_zero
, nan_value
));
3355 check_isnan ("real(ccosh(-0 + i NaN)) = NaN", __real__ result
);
3356 check ("imag(ccosh(-0 + i NaN)) = +-0", FUNC(fabs
) (__imag__ result
), 0);
3358 result
= FUNC(ccosh
) (BUILD_COMPLEX (plus_infty
, nan_value
));
3359 check_isinfp ("real(ccosh(+Inf + i NaN)) = +Inf", __real__ result
);
3360 check_isnan ("imag(ccosh(+Inf + i NaN)) = NaN", __imag__ result
);
3361 result
= FUNC(ccosh
) (BUILD_COMPLEX (minus_infty
, nan_value
));
3362 check_isinfp ("real(ccosh(-Inf + i NaN)) = +Inf", __real__ result
);
3363 check_isnan ("imag(ccosh(-Inf + i NaN)) = NaN", __imag__ result
);
3365 result
= FUNC(ccosh
) (BUILD_COMPLEX (9.0, nan_value
));
3366 check_isnan_maybe_exc ("real(ccosh(9.0 + i NaN)) = NaN plus maybe invalid exception",
3367 __real__ result
, INVALID_EXCEPTION
);
3368 check_isnan ("imag(ccosh(9.0 + i NaN)) = NaN plus maybe invalid exception",
3370 result
= FUNC(ccosh
) (BUILD_COMPLEX (-9.0, nan_value
));
3371 check_isnan_maybe_exc ("real(ccosh(-9.0 + i NaN)) = NaN plus maybe invalid exception",
3372 __real__ result
, INVALID_EXCEPTION
);
3373 check_isnan ("imag(ccosh(-9.0 + i NaN)) = NaN plus maybe invalid exception",
3376 result
= FUNC(ccosh
) (BUILD_COMPLEX (nan_value
, 0.0));
3377 check_isnan ("real(ccosh(NaN + i0)) = NaN", __real__ result
);
3378 check ("imag(ccosh(NaN + i0)) = +-0", FUNC(fabs
) (__imag__ result
), 0.0);
3379 result
= FUNC(ccosh
) (BUILD_COMPLEX (nan_value
, minus_zero
));
3380 check_isnan ("real(ccosh(NaN - i0)) = NaN", __real__ result
);
3381 check ("imag(ccosh(NaN - i0)) = +-0", FUNC(fabs
) (__imag__ result
), 0.0);
3383 result
= FUNC(ccosh
) (BUILD_COMPLEX (nan_value
, 10.0));
3384 check_isnan_maybe_exc ("real(ccosh(NaN + i10)) = NaN plus maybe invalid exception",
3385 __real__ result
, INVALID_EXCEPTION
);
3386 check_isnan ("imag(ccosh(NaN + i10)) = NaN plus maybe invalid exception",
3388 result
= FUNC(ccosh
) (BUILD_COMPLEX (nan_value
, -10.0));
3389 check_isnan_maybe_exc ("real(ccosh(NaN - i10)) = NaN plus maybe invalid exception",
3390 __real__ result
, INVALID_EXCEPTION
);
3391 check_isnan ("imag(ccosh(NaN - i10)) = NaN plus maybe invalid exception",
3394 result
= FUNC(ccosh
) (BUILD_COMPLEX (nan_value
, plus_infty
));
3395 check_isnan_maybe_exc ("real(ccosh(NaN + i Inf)) = NaN plus maybe invalid exception",
3396 __real__ result
, INVALID_EXCEPTION
);
3397 check_isnan ("imag(ccosh(NaN + i Inf)) = NaN plus maybe invalid exception",
3399 result
= FUNC(ccosh
) (BUILD_COMPLEX (nan_value
, minus_infty
));
3400 check_isnan_maybe_exc ("real(ccosh(NaN - i Inf)) = NaN plus maybe invalid exception",
3401 __real__ result
, INVALID_EXCEPTION
);
3402 check_isnan ("imag(ccosh(NaN - i Inf)) = NaN plus maybe invalid exception",
3405 result
= FUNC(ccosh
) (BUILD_COMPLEX (nan_value
, nan_value
));
3406 check_isnan ("real(ccosh(NaN + i NaN)) = NaN", __real__ result
);
3407 check_isnan ("imag(ccosh(NaN + i NaN)) = NaN", __imag__ result
);
3409 result
= FUNC(ccosh
) (BUILD_COMPLEX (0.7, 1.2));
3410 check_eps ("real(ccosh(0.7 + i 1.2)) == 0.45482...", __real__ result
,
3411 0.4548202223691477654L, CHOOSE(4e-17L, 6e-17, 3e-8));
3412 check_eps ("imag(ccosh(0.7 + i 1.2)) == 0.70702...", __imag__ result
,
3413 0.7070296600921537682L, CHOOSE(7e-17L, 0, 0));
3415 result
= FUNC(ccosh
) (BUILD_COMPLEX (-2, -3));
3416 check ("real(ccosh(-2 - i 3)) == --3.72454...", __real__ result
,
3417 -3.7245455049153225654L);
3418 check_eps ("imag(ccosh(-2 - i 3)) == -0.51182...", __imag__ result
,
3419 0.5118225699873846088L, CHOOSE(6e-20, 2e-16, 6e-8));
3426 __complex__ MATHTYPE result
;
3428 result
= FUNC(cacos
) (BUILD_COMPLEX (0, 0));
3429 check ("real(cacos(0 + i0)) = pi/2", __real__ result
, M_PI_2
);
3430 check ("imag(cacos(0 + i0)) = -0", __imag__ result
, minus_zero
);
3431 result
= FUNC(cacos
) (BUILD_COMPLEX (minus_zero
, 0));
3432 check ("real(cacos(-0 + i0)) = pi/2", __real__ result
, M_PI_2
);
3433 check ("imag(cacos(-0 + i0)) = -0", __imag__ result
, minus_zero
);
3434 result
= FUNC(cacos
) (BUILD_COMPLEX (0, minus_zero
));
3435 check ("real(cacos(0 - i0)) = pi/2", __real__ result
, M_PI_2
);
3436 check ("imag(cacos(0 - i0)) = 0", __imag__ result
, 0);
3437 result
= FUNC(cacos
) (BUILD_COMPLEX (minus_zero
, minus_zero
));
3438 check ("real(cacos(-0 - i0)) = pi/2", __real__ result
, M_PI_2
);
3439 check ("imag(cacos(-0 - i0)) = 0", __imag__ result
, 0);
3441 result
= FUNC(cacos
) (BUILD_COMPLEX (minus_infty
, plus_infty
));
3442 check ("real(cacos(-Inf + i Inf)) = 3*pi/4", __real__ result
, M_PI
- M_PI_4
);
3443 check_isinfn ("imag(cacos(-Inf + i Inf)) = -Inf", __imag__ result
);
3444 result
= FUNC(cacos
) (BUILD_COMPLEX (minus_infty
, minus_infty
));
3445 check ("real(cacos(-Inf - i Inf)) = 3*pi/4", __real__ result
, M_PI
- M_PI_4
);
3446 check_isinfp ("imag(cacos(-Inf - i Inf)) = +Inf", __imag__ result
);
3448 result
= FUNC(cacos
) (BUILD_COMPLEX (plus_infty
, plus_infty
));
3449 check ("real(cacos(+Inf + i Inf)) = pi/4", __real__ result
, M_PI_4
);
3450 check_isinfn ("imag(cacos(+Inf + i Inf)) = -Inf", __imag__ result
);
3451 result
= FUNC(cacos
) (BUILD_COMPLEX (plus_infty
, minus_infty
));
3452 check ("real(cacos(+Inf - i Inf)) = pi/4", __real__ result
, M_PI_4
);
3453 check_isinfp ("imag(cacos(+Inf - i Inf)) = +Inf", __imag__ result
);
3455 result
= FUNC(cacos
) (BUILD_COMPLEX (-10.0, plus_infty
));
3456 check ("real(cacos(-10.0 + i Inf)) = pi/2", __real__ result
, M_PI_2
);
3457 check_isinfn ("imag(cacos(-10.0 + i Inf)) = -Inf", __imag__ result
);
3458 result
= FUNC(cacos
) (BUILD_COMPLEX (-10.0, minus_infty
));
3459 check ("real(cacos(-10.0 - i Inf)) = pi/2", __real__ result
, M_PI_2
);
3460 check_isinfp ("imag(cacos(-10.0 - i Inf)) = +Inf", __imag__ result
);
3461 result
= FUNC(cacos
) (BUILD_COMPLEX (0, plus_infty
));
3462 check ("real(cacos(0 + i Inf)) = pi/2", __real__ result
, M_PI_2
);
3463 check_isinfn ("imag(cacos(0 + i Inf)) = -Inf", __imag__ result
);
3464 result
= FUNC(cacos
) (BUILD_COMPLEX (0, minus_infty
));
3465 check ("real(cacos(0 - i Inf)) = pi/2", __real__ result
, M_PI_2
);
3466 check_isinfp ("imag(cacos(0 - i Inf)) = +Inf", __imag__ result
);
3467 result
= FUNC(cacos
) (BUILD_COMPLEX (0.1, plus_infty
));
3468 check ("real(cacos(0.1 + i Inf)) = pi/2", __real__ result
, M_PI_2
);
3469 check_isinfn ("imag(cacos(0.1 + i Inf)) = -Inf", __imag__ result
);
3470 result
= FUNC(cacos
) (BUILD_COMPLEX (0.1, minus_infty
));
3471 check ("real(cacos(0.1 - i Inf)) = pi/2", __real__ result
, M_PI_2
);
3472 check_isinfp ("imag(cacos(0.1 - i Inf)) = +Inf", __imag__ result
);
3474 result
= FUNC(cacos
) (BUILD_COMPLEX (minus_infty
, 0));
3475 check ("real(cacos(-Inf + i0)) = pi", __real__ result
, M_PI
);
3476 check_isinfn ("imag(cacos(-Inf + i0)) = -Inf", __imag__ result
);
3477 result
= FUNC(cacos
) (BUILD_COMPLEX (minus_infty
, minus_zero
));
3478 check ("real(cacos(-Inf - i0)) = pi", __real__ result
, M_PI
);
3479 check_isinfp ("imag(cacos(-Inf - i0)) = +Inf", __imag__ result
);
3480 result
= FUNC(cacos
) (BUILD_COMPLEX (minus_infty
, 100));
3481 check ("real(cacos(-Inf + i100)) = pi", __real__ result
, M_PI
);
3482 check_isinfn ("imag(cacos(-Inf + i100)) = -Inf", __imag__ result
);
3483 result
= FUNC(cacos
) (BUILD_COMPLEX (minus_infty
, -100));
3484 check ("real(cacos(-Inf - i100)) = pi", __real__ result
, M_PI
);
3485 check_isinfp ("imag(cacos(-Inf - i100)) = +Inf", __imag__ result
);
3487 result
= FUNC(cacos
) (BUILD_COMPLEX (plus_infty
, 0));
3488 check ("real(cacos(+Inf + i0)) = 0", __real__ result
, 0);
3489 check_isinfn ("imag(cacos(+Inf + i0)) = -Inf", __imag__ result
);
3490 result
= FUNC(cacos
) (BUILD_COMPLEX (plus_infty
, minus_zero
));
3491 check ("real(cacos(+Inf - i0)) = 0", __real__ result
, 0);
3492 check_isinfp ("imag(cacos(+Inf - i0)) = +Inf", __imag__ result
);
3493 result
= FUNC(cacos
) (BUILD_COMPLEX (plus_infty
, 0.5));
3494 check ("real(cacos(+Inf + i0.5)) = 0", __real__ result
, 0);
3495 check_isinfn ("imag(cacos(+Inf + i0.5)) = -Inf", __imag__ result
);
3496 result
= FUNC(cacos
) (BUILD_COMPLEX (plus_infty
, -0.5));
3497 check ("real(cacos(+Inf - i0.5)) = 0", __real__ result
, 0);
3498 check_isinfp ("imag(cacos(+Inf - i0.5)) = +Inf", __imag__ result
);
3500 result
= FUNC(cacos
) (BUILD_COMPLEX (plus_infty
, nan_value
));
3501 check_isnan ("real(cacos(+Inf + i NaN)) = NaN", __real__ result
);
3502 check_isinfp ("imag(cacos(+Inf + i NaN)) = +-Inf",
3503 FUNC(fabs
) (__imag__ result
));
3504 result
= FUNC(cacos
) (BUILD_COMPLEX (minus_infty
, nan_value
));
3505 check_isnan ("real(cacos(-Inf + i NaN)) = NaN", __real__ result
);
3506 check_isinfp ("imag(cacos(-Inf + i NaN)) = +-Inf",
3507 FUNC(fabs
) (__imag__ result
));
3509 result
= FUNC(cacos
) (BUILD_COMPLEX (0, nan_value
));
3510 check ("real(cacos(0 + i NaN)) = pi/2", __real__ result
, M_PI_2
);
3511 check_isnan ("imag(cacos(0 + i NaN)) = NaN", __imag__ result
);
3512 result
= FUNC(cacos
) (BUILD_COMPLEX (minus_zero
, nan_value
));
3513 check ("real(cacos(-0 + i NaN)) = pi/2", __real__ result
, M_PI_2
);
3514 check_isnan ("imag(cacos(-0 + i NaN)) = NaN", __imag__ result
);
3516 result
= FUNC(cacos
) (BUILD_COMPLEX (nan_value
, plus_infty
));
3517 check_isnan ("real(cacos(NaN + i Inf)) = NaN", __real__ result
);
3518 check_isinfn ("imag(cacos(NaN + i Inf)) = -Inf", __imag__ result
);
3519 result
= FUNC(cacos
) (BUILD_COMPLEX (nan_value
, minus_infty
));
3520 check_isnan ("real(cacos(NaN - i Inf)) = NaN", __real__ result
);
3521 check_isinfp ("imag(cacos(NaN - i Inf)) = +Inf", __imag__ result
);
3523 result
= FUNC(cacos
) (BUILD_COMPLEX (10.5, nan_value
));
3524 check_isnan_maybe_exc ("real(cacos(10.5 + i NaN)) = NaN plus maybe invalid exception",
3525 __real__ result
, INVALID_EXCEPTION
);
3526 check_isnan ("imag(cacos(10.5 + i NaN)) = NaN plus maybe invalid exception",
3528 result
= FUNC(cacos
) (BUILD_COMPLEX (-10.5, nan_value
));
3529 check_isnan_maybe_exc ("real(cacos(-10.5 + i NaN)) = NaN plus maybe invalid exception",
3530 __real__ result
, INVALID_EXCEPTION
);
3531 check_isnan ("imag(cacos(-10.5 + i NaN)) = NaN plus maybe invalid exception",
3534 result
= FUNC(cacos
) (BUILD_COMPLEX (nan_value
, 0.75));
3535 check_isnan_maybe_exc ("real(cacos(NaN + i0.75)) = NaN plus maybe invalid exception",
3536 __real__ result
, INVALID_EXCEPTION
);
3537 check_isnan ("imag(cacos(NaN + i0.75)) = NaN plus maybe invalid exception",
3539 result
= FUNC(cacos
) (BUILD_COMPLEX (-10.5, nan_value
));
3540 check_isnan_maybe_exc ("real(cacos(NaN - i0.75)) = NaN plus maybe invalid exception",
3541 __real__ result
, INVALID_EXCEPTION
);
3542 check_isnan ("imag(cacos(NaN - i0.75)) = NaN plus maybe invalid exception",
3545 result
= FUNC(cacos
) (BUILD_COMPLEX (nan_value
, nan_value
));
3546 check_isnan ("real(cacos(NaN + i NaN)) = NaN", __real__ result
);
3547 check_isnan ("imag(cacos(NaN + i NaN)) = NaN", __imag__ result
);
3549 result
= FUNC(cacos
) (BUILD_COMPLEX (0.7, 1.2));
3550 check_eps ("real(cacos(0.7 + i 1.2)) == 1.13518...", __real__ result
,
3551 1.1351827477151551089L, CHOOSE(2e-17L, 3e-16, 2e-7));
3552 check_eps ("imag(cacos(0.7 + i 1.2)) == -1.09276...", __imag__ result
,
3553 -1.0927647857577371459L, CHOOSE(4e-17L, 0, 3e-7));
3555 result
= FUNC(cacos
) (BUILD_COMPLEX (-2, -3));
3556 check ("real(cacos(-2 - i 3)) == -2.14144...", __real__ result
,
3557 2.1414491111159960199L);
3558 check_eps ("imag(cacos(-2 - i 3)) == -1.98338...", __imag__ result
,
3559 1.9833870299165354323L, CHOOSE(2e-19L, 0, 0));
3566 __complex__ MATHTYPE result
;
3568 result
= FUNC(cacosh
) (BUILD_COMPLEX (0, 0));
3569 check ("real(cacosh(0 + i0)) = 0", __real__ result
, 0);
3570 check ("imag(cacosh(0 + i0)) = pi/2", __imag__ result
, M_PI_2
);
3571 result
= FUNC(cacosh
) (BUILD_COMPLEX (minus_zero
, 0));
3572 check ("real(cacosh(-0 + i0)) = 0", __real__ result
, 0);
3573 check ("imag(cacosh(-0 + i0)) = pi/2", __imag__ result
, M_PI_2
);
3574 result
= FUNC(cacosh
) (BUILD_COMPLEX (0, minus_zero
));
3575 check ("real(cacosh(0 - i0)) = 0", __real__ result
, 0);
3576 check ("imag(cacosh(0 - i0)) = -pi/2", __imag__ result
, -M_PI_2
);
3577 result
= FUNC(cacosh
) (BUILD_COMPLEX (minus_zero
, minus_zero
));
3578 check ("real(cacosh(-0 - i0)) = 0", __real__ result
, 0);
3579 check ("imag(cacosh(-0 - i0)) = -pi/2", __imag__ result
, -M_PI_2
);
3581 result
= FUNC(cacosh
) (BUILD_COMPLEX (minus_infty
, plus_infty
));
3582 check_isinfp ("real(cacosh(-Inf + i Inf)) = +Inf", __real__ result
);
3583 check ("imag(cacosh(-Inf + i Inf)) = 3*pi/4", __imag__ result
,
3585 result
= FUNC(cacosh
) (BUILD_COMPLEX (minus_infty
, minus_infty
));
3586 check_isinfp ("real(cacosh(-Inf - i Inf)) = +Inf", __real__ result
);
3587 check ("imag(cacosh(-Inf - i Inf)) = -3*pi/4", __imag__ result
,
3590 result
= FUNC(cacosh
) (BUILD_COMPLEX (plus_infty
, plus_infty
));
3591 check_isinfp ("real(cacosh(+Inf + i Inf)) = +Inf", __real__ result
);
3592 check ("imag(cacosh(+Inf + i Inf)) = pi/4", __imag__ result
, M_PI_4
);
3593 result
= FUNC(cacosh
) (BUILD_COMPLEX (plus_infty
, minus_infty
));
3594 check_isinfp ("real(cacosh(+Inf - i Inf)) = +Inf", __real__ result
);
3595 check ("imag(cacosh(+Inf - i Inf)) = -pi/4", __imag__ result
, -M_PI_4
);
3597 result
= FUNC(cacosh
) (BUILD_COMPLEX (-10.0, plus_infty
));
3598 check_isinfp ("real(cacosh(-10.0 + i Inf)) = +Inf", __real__ result
);
3599 check ("imag(cacosh(-10.0 + i Inf)) = pi/2", __imag__ result
, M_PI_2
);
3600 result
= FUNC(cacosh
) (BUILD_COMPLEX (-10.0, minus_infty
));
3601 check_isinfp ("real(cacosh(-10.0 - i Inf)) = +Inf", __real__ result
);
3602 check ("imag(cacosh(-10.0 - i Inf)) = -pi/2", __imag__ result
, -M_PI_2
);
3603 result
= FUNC(cacosh
) (BUILD_COMPLEX (0, plus_infty
));
3604 check_isinfp ("real(cacosh(0 + i Inf)) = +Inf", __real__ result
);
3605 check ("imag(cacosh(0 + i Inf)) = pi/2", __imag__ result
, M_PI_2
);
3606 result
= FUNC(cacosh
) (BUILD_COMPLEX (0, minus_infty
));
3607 check_isinfp ("real(cacosh(0 - i Inf)) = +Inf", __real__ result
);
3608 check ("imag(cacosh(0 - i Inf)) = -pi/2", __imag__ result
, -M_PI_2
);
3609 result
= FUNC(cacosh
) (BUILD_COMPLEX (0.1, plus_infty
));
3610 check_isinfp ("real(cacosh(0.1 + i Inf)) = +Inf", __real__ result
);
3611 check ("imag(cacosh(0.1 + i Inf)) = pi/2", __imag__ result
, M_PI_2
);
3612 result
= FUNC(cacosh
) (BUILD_COMPLEX (0.1, minus_infty
));
3613 check_isinfp ("real(cacosh(0.1 - i Inf)) = +Inf", __real__ result
);
3614 check ("imag(cacosh(0.1 - i Inf)) = -pi/2", __imag__ result
, -M_PI_2
);
3616 result
= FUNC(cacosh
) (BUILD_COMPLEX (minus_infty
, 0));
3617 check_isinfp ("real(cacosh(-Inf + i0)) = +Inf", __real__ result
);
3618 check ("imag(cacosh(-Inf + i0)) = pi", __imag__ result
, M_PI
);
3619 result
= FUNC(cacosh
) (BUILD_COMPLEX (minus_infty
, minus_zero
));
3620 check_isinfp ("real(cacosh(-Inf - i0)) = +Inf", __real__ result
);
3621 check ("imag(cacosh(-Inf - i0)) = -pi", __imag__ result
, -M_PI
);
3622 result
= FUNC(cacosh
) (BUILD_COMPLEX (minus_infty
, 100));
3623 check_isinfp ("real(cacosh(-Inf + i100)) = +Inf", __real__ result
);
3624 check ("imag(cacosh(-Inf + i100)) = pi", __imag__ result
, M_PI
);
3625 result
= FUNC(cacosh
) (BUILD_COMPLEX (minus_infty
, -100));
3626 check_isinfp ("real(cacosh(-Inf - i100)) = +Inf", __real__ result
);
3627 check ("imag(cacosh(-Inf - i100)) = -pi", __imag__ result
, -M_PI
);
3629 result
= FUNC(cacosh
) (BUILD_COMPLEX (plus_infty
, 0));
3630 check_isinfp ("real(cacosh(+Inf + i0)) = +Inf", __real__ result
);
3631 check ("imag(cacosh(+Inf + i0)) = 0", __imag__ result
, 0);
3632 result
= FUNC(cacosh
) (BUILD_COMPLEX (plus_infty
, minus_zero
));
3633 check_isinfp ("real(cacosh(+Inf - i0)) = +Inf", __real__ result
);
3634 check ("imag(cacosh(+Inf - i0)) = -0", __imag__ result
, minus_zero
);
3635 result
= FUNC(cacosh
) (BUILD_COMPLEX (plus_infty
, 0.5));
3636 check_isinfp ("real(cacosh(+Inf + i0.5)) = +Inf", __real__ result
);
3637 check ("imag(cacosh(+Inf + i0.5)) = 0", __imag__ result
, 0);
3638 result
= FUNC(cacosh
) (BUILD_COMPLEX (plus_infty
, -0.5));
3639 check_isinfp ("real(cacosh(+Inf - i0.5)) = +Inf", __real__ result
);
3640 check ("imag(cacosh(+Inf - i0.5)) = -0", __imag__ result
, minus_zero
);
3642 result
= FUNC(cacosh
) (BUILD_COMPLEX (plus_infty
, nan_value
));
3643 check_isinfp ("real(cacosh(+Inf + i NaN)) = +Inf", __real__ result
);
3644 check_isnan ("imag(cacosh(+Inf + i NaN)) = NaN", __imag__ result
);
3645 result
= FUNC(cacosh
) (BUILD_COMPLEX (minus_infty
, nan_value
));
3646 check_isinfp ("real(cacosh(-Inf + i NaN)) = +Inf", __real__ result
);
3647 check_isnan ("imag(cacosh(-Inf + i NaN)) = NaN", __imag__ result
);
3649 result
= FUNC(cacosh
) (BUILD_COMPLEX (0, nan_value
));
3650 check_isnan ("real(cacosh(0 + i NaN)) = NaN", __real__ result
);
3651 check_isnan ("imag(cacosh(0 + i NaN)) = NaN", __imag__ result
);
3652 result
= FUNC(cacosh
) (BUILD_COMPLEX (minus_zero
, nan_value
));
3653 check_isnan ("real(cacosh(-0 + i NaN)) = NaN", __real__ result
);
3654 check_isnan ("imag(cacosh(-0 + i NaN)) = NaN", __imag__ result
);
3656 result
= FUNC(cacosh
) (BUILD_COMPLEX (nan_value
, plus_infty
));
3657 check_isinfp ("real(cacosh(NaN + i Inf)) = +Inf", __real__ result
);
3658 check_isnan ("imag(cacosh(NaN + i Inf)) = NaN", __imag__ result
);
3659 result
= FUNC(cacosh
) (BUILD_COMPLEX (nan_value
, minus_infty
));
3660 check_isinfp ("real(cacosh(NaN - i Inf)) = +Inf", __real__ result
);
3661 check_isnan ("imag(cacosh(NaN - i Inf)) = NaN", __imag__ result
);
3663 result
= FUNC(cacosh
) (BUILD_COMPLEX (10.5, nan_value
));
3664 check_isnan_maybe_exc ("real(cacosh(10.5 + i NaN)) = NaN plus maybe invalid exception",
3665 __real__ result
, INVALID_EXCEPTION
);
3666 check_isnan ("imag(cacosh(10.5 + i NaN)) = NaN plus maybe invalid exception",
3668 result
= FUNC(cacosh
) (BUILD_COMPLEX (-10.5, nan_value
));
3669 check_isnan_maybe_exc ("real(cacosh(-10.5 + i NaN)) = NaN plus maybe invalid exception",
3670 __real__ result
, INVALID_EXCEPTION
);
3671 check_isnan ("imag(cacosh(-10.5 + i NaN)) = NaN plus maybe invalid exception",
3674 result
= FUNC(cacosh
) (BUILD_COMPLEX (nan_value
, 0.75));
3675 check_isnan_maybe_exc ("real(cacosh(NaN + i0.75)) = NaN plus maybe invalid exception",
3676 __real__ result
, INVALID_EXCEPTION
);
3677 check_isnan ("imag(cacosh(NaN + i0.75)) = NaN plus maybe invalid exception",
3679 result
= FUNC(cacosh
) (BUILD_COMPLEX (-10.5, nan_value
));
3680 check_isnan_maybe_exc ("real(cacosh(NaN - i0.75)) = NaN plus maybe invalid exception",
3681 __real__ result
, INVALID_EXCEPTION
);
3682 check_isnan ("imag(cacosh(NaN - i0.75)) = NaN plus maybe invalid exception",
3685 result
= FUNC(cacosh
) (BUILD_COMPLEX (nan_value
, nan_value
));
3686 check_isnan ("real(cacosh(NaN + i NaN)) = NaN", __real__ result
);
3687 check_isnan ("imag(cacosh(NaN + i NaN)) = NaN", __imag__ result
);
3689 result
= FUNC(cacosh
) (BUILD_COMPLEX (0.7, 1.2));
3690 check_eps ("real(cacosh(0.7 + i 1.2)) == 1.09276...", __real__ result
,
3691 1.0927647857577371459L, CHOOSE(4e-17L, 3e-16, 0));
3692 check_eps ("imag(cacosh(0.7 + i 1.2)) == 1.13518...", __imag__ result
,
3693 1.1351827477151551089L, CHOOSE(2e-17L, 0, 0));
3695 result
= FUNC(cacosh
) (BUILD_COMPLEX (-2, -3));
3696 check_eps ("real(cacosh(-2 - i 3)) == -1.98338...", __real__ result
,
3697 -1.9833870299165354323L, CHOOSE (6e-19, 3e-16, 9e-7));
3698 check_eps ("imag(cacosh(-2 - i 3)) == 2.14144...", __imag__ result
,
3699 2.1414491111159960199L, CHOOSE (3e-19, 5e-16, 0));
3706 __complex__ MATHTYPE result
;
3708 result
= FUNC(casin
) (BUILD_COMPLEX (0, 0));
3709 check ("real(casin(0 + i0)) = 0", __real__ result
, 0);
3710 check ("imag(casin(0 + i0)) = 0", __imag__ result
, 0);
3711 result
= FUNC(casin
) (BUILD_COMPLEX (minus_zero
, 0));
3712 check ("real(casin(-0 + i0)) = -0", __real__ result
, minus_zero
);
3713 check ("imag(casin(-0 + i0)) = 0", __imag__ result
, 0);
3714 result
= FUNC(casin
) (BUILD_COMPLEX (0, minus_zero
));
3715 check ("real(casin(0 - i0)) = 0", __real__ result
, 0);
3716 check ("imag(casin(0 - i0)) = -0", __imag__ result
, minus_zero
);
3717 result
= FUNC(casin
) (BUILD_COMPLEX (minus_zero
, minus_zero
));
3718 check ("real(casin(-0 - i0)) = -0", __real__ result
, minus_zero
);
3719 check ("imag(casin(-0 - i0)) = -0", __imag__ result
, minus_zero
);
3721 result
= FUNC(casin
) (BUILD_COMPLEX (plus_infty
, plus_infty
));
3722 check ("real(casin(+Inf + i Inf)) = pi/4", __real__ result
, M_PI_4
);
3723 check_isinfp ("imag(casin(+Inf + i Inf)) = +Inf", __imag__ result
);
3724 result
= FUNC(casin
) (BUILD_COMPLEX (plus_infty
, minus_infty
));
3725 check ("real(casin(+Inf - i Inf)) = pi/4", __real__ result
, M_PI_4
);
3726 check_isinfn ("imag(casin(+Inf - i Inf)) = -Inf", __imag__ result
);
3727 result
= FUNC(casin
) (BUILD_COMPLEX (minus_infty
, plus_infty
));
3728 check ("real(casin(-Inf + i Inf)) = -pi/4", __real__ result
, -M_PI_4
);
3729 check_isinfp ("imag(casin(-Inf + i Inf)) = +Inf", __imag__ result
);
3730 result
= FUNC(casin
) (BUILD_COMPLEX (minus_infty
, minus_infty
));
3731 check ("real(casin(-Inf - i Inf)) = -pi/4", __real__ result
, -M_PI_4
);
3732 check_isinfn ("imag(casin(-Inf - i Inf)) = -Inf", __imag__ result
);
3734 result
= FUNC(casin
) (BUILD_COMPLEX (-10.0, plus_infty
));
3735 check ("real(casin(-10.0 + i Inf)) = -0", __real__ result
, minus_zero
);
3736 check_isinfp ("imag(casin(-10.0 + i Inf)) = +Inf", __imag__ result
);
3737 result
= FUNC(casin
) (BUILD_COMPLEX (-10.0, minus_infty
));
3738 check ("real(casin(-10.0 - i Inf)) = -0", __real__ result
, minus_zero
);
3739 check_isinfn ("imag(casin(-10.0 - i Inf)) = -Inf", __imag__ result
);
3740 result
= FUNC(casin
) (BUILD_COMPLEX (0, plus_infty
));
3741 check ("real(casin(0 + i Inf)) = 0", __real__ result
, 0.0);
3742 check_isinfp ("imag(casin(0 + i Inf)) = +Inf", __imag__ result
);
3743 result
= FUNC(casin
) (BUILD_COMPLEX (0, minus_infty
));
3744 check ("real(casin(0 - i Inf)) = 0", __real__ result
, 0.0);
3745 check_isinfn ("imag(casin(0 - i Inf)) = -Inf", __imag__ result
);
3746 result
= FUNC(casin
) (BUILD_COMPLEX (minus_zero
, plus_infty
));
3747 check ("real(casin(-0 + i Inf)) = -0", __real__ result
, minus_zero
);
3748 check_isinfp ("imag(casin(-0 + i Inf)) = +Inf", __imag__ result
);
3749 result
= FUNC(casin
) (BUILD_COMPLEX (minus_zero
, minus_infty
));
3750 check ("real(casin(-0 - i Inf)) = -0", __real__ result
, minus_zero
);
3751 check_isinfn ("imag(casin(-0 - i Inf)) = -Inf", __imag__ result
);
3752 result
= FUNC(casin
) (BUILD_COMPLEX (0.1, plus_infty
));
3753 check ("real(casin(0.1 + i Inf)) = 0", __real__ result
, 0);
3754 check_isinfp ("imag(casin(0.1 + i Inf)) = +Inf", __imag__ result
);
3755 result
= FUNC(casin
) (BUILD_COMPLEX (0.1, minus_infty
));
3756 check ("real(casin(0.1 - i Inf)) = 0", __real__ result
, 0);
3757 check_isinfn ("imag(casin(0.1 - i Inf)) = -Inf", __imag__ result
);
3759 result
= FUNC(casin
) (BUILD_COMPLEX (minus_infty
, 0));
3760 check ("real(casin(-Inf + i0)) = -pi/2", __real__ result
, -M_PI_2
);
3761 check_isinfp ("imag(casin(-Inf + i0)) = +Inf", __imag__ result
);
3762 result
= FUNC(casin
) (BUILD_COMPLEX (minus_infty
, minus_zero
));
3763 check ("real(casin(-Inf - i0)) = -pi/2", __real__ result
, -M_PI_2
);
3764 check_isinfn ("imag(casin(-Inf - i0)) = -Inf", __imag__ result
);
3765 result
= FUNC(casin
) (BUILD_COMPLEX (minus_infty
, 100));
3766 check ("real(casin(-Inf + i100)) = -pi/2", __real__ result
, -M_PI_2
);
3767 check_isinfp ("imag(casin(-Inf + i100)) = +Inf", __imag__ result
);
3768 result
= FUNC(casin
) (BUILD_COMPLEX (minus_infty
, -100));
3769 check ("real(casin(-Inf - i100)) = -pi/2", __real__ result
, -M_PI_2
);
3770 check_isinfn ("imag(casin(-Inf - i100)) = -Inf", __imag__ result
);
3772 result
= FUNC(casin
) (BUILD_COMPLEX (plus_infty
, 0));
3773 check ("real(casin(+Inf + i0)) = pi/2", __real__ result
, M_PI_2
);
3774 check_isinfp ("imag(casin(+Inf + i0)) = +Inf", __imag__ result
);
3775 result
= FUNC(casin
) (BUILD_COMPLEX (plus_infty
, minus_zero
));
3776 check ("real(casin(+Inf - i0)) = pi/2", __real__ result
, M_PI_2
);
3777 check_isinfn ("imag(casin(+Inf - i0)) = -Inf", __imag__ result
);
3778 result
= FUNC(casin
) (BUILD_COMPLEX (plus_infty
, 0.5));
3779 check ("real(casin(+Inf + i0.5)) = pi/2", __real__ result
, M_PI_2
);
3780 check_isinfp ("imag(casin(+Inf + i0.5)) = +Inf", __imag__ result
);
3781 result
= FUNC(casin
) (BUILD_COMPLEX (plus_infty
, -0.5));
3782 check ("real(casin(+Inf - i0.5)) = pi/2", __real__ result
, M_PI_2
);
3783 check_isinfn ("imag(casin(+Inf - i0.5)) = -Inf", __imag__ result
);
3785 result
= FUNC(casin
) (BUILD_COMPLEX (nan_value
, plus_infty
));
3786 check_isnan ("real(casin(NaN + i Inf)) = NaN", __real__ result
);
3787 check_isinfp ("imag(casin(NaN + i Inf)) = +Inf", __imag__ result
);
3788 result
= FUNC(casin
) (BUILD_COMPLEX (nan_value
, minus_infty
));
3789 check_isnan ("real(casin(NaN - i Inf)) = NaN", __real__ result
);
3790 check_isinfn ("imag(casin(NaN - i Inf)) = -Inf", __imag__ result
);
3792 result
= FUNC(casin
) (BUILD_COMPLEX (0.0, nan_value
));
3793 check ("real(casin(0 + i NaN)) = 0", __real__ result
, 0.0);
3794 check_isnan ("imag(casin(0 + i NaN)) = NaN", __imag__ result
);
3795 result
= FUNC(casin
) (BUILD_COMPLEX (minus_zero
, nan_value
));
3796 check ("real(casin(-0 + i NaN)) = -0", __real__ result
, minus_zero
);
3797 check_isnan ("imag(casin(-0 + i NaN)) = NaN", __imag__ result
);
3799 result
= FUNC(casin
) (BUILD_COMPLEX (plus_infty
, nan_value
));
3800 check_isnan ("real(casin(+Inf + i NaN)) = NaN", __real__ result
);
3801 check_isinfp ("imag(casin(+Inf + i NaN)) = +-Inf",
3802 FUNC(fabs
) (__imag__ result
));
3803 result
= FUNC(casin
) (BUILD_COMPLEX (minus_infty
, nan_value
));
3804 check_isnan ("real(casin(-Inf + i NaN)) = NaN", __real__ result
);
3805 check_isinfp ("imag(casin(-Inf + NaN)) = +-Inf",
3806 FUNC(fabs
) (__imag__ result
));
3808 result
= FUNC(casin
) (BUILD_COMPLEX (nan_value
, 10.5));
3809 check_isnan_maybe_exc ("real(casin(NaN + i10.5)) = NaN plus maybe invalid exception",
3810 __real__ result
, INVALID_EXCEPTION
);
3811 check_isnan ("imag(casin(NaN + i10.5)) = NaN plus maybe invalid exception",
3813 result
= FUNC(casin
) (BUILD_COMPLEX (nan_value
, -10.5));
3814 check_isnan_maybe_exc ("real(casin(NaN - i10.5)) = NaN plus maybe invalid exception",
3815 __real__ result
, INVALID_EXCEPTION
);
3816 check_isnan ("imag(casin(NaN - i10.5)) = NaN plus maybe invalid exception",
3819 result
= FUNC(casin
) (BUILD_COMPLEX (0.75, nan_value
));
3820 check_isnan_maybe_exc ("real(casin(0.75 + i NaN)) = NaN plus maybe invalid exception",
3821 __real__ result
, INVALID_EXCEPTION
);
3822 check_isnan ("imag(casin(0.75 + i NaN)) = NaN plus maybe invalid exception",
3824 result
= FUNC(casin
) (BUILD_COMPLEX (-0.75, nan_value
));
3825 check_isnan_maybe_exc ("real(casin(-0.75 + i NaN)) = NaN plus maybe invalid exception",
3826 __real__ result
, INVALID_EXCEPTION
);
3827 check_isnan ("imag(casin(-0.75 + i NaN)) = NaN plus maybe invalid exception",
3830 result
= FUNC(casin
) (BUILD_COMPLEX (nan_value
, nan_value
));
3831 check_isnan ("real(casin(NaN + i NaN)) = NaN", __real__ result
);
3832 check_isnan ("imag(casin(NaN + i NaN)) = NaN", __imag__ result
);
3834 result
= FUNC(casin
) (BUILD_COMPLEX (0.7, 1.2));
3835 check_eps ("real(casin(0.7 + i 1.2)) == 0.43561...", __real__ result
,
3836 0.4356135790797415103L, CHOOSE(2e-17L, 2e-16, 2e-7));
3837 check_eps ("imag(casin(0.7 + i 1.2)) == 1.09276...", __imag__ result
,
3838 1.0927647857577371459L, CHOOSE(4e-17L, 0, 3e-7));
3840 result
= FUNC(casin
) (BUILD_COMPLEX (-2, -3));
3841 check ("real(casin(-2 - i 3)) == --0.57065...", __real__ result
,
3842 -0.5706527843210994007L);
3843 check_eps ("imag(casin(-2 - i 3)) == -1.98338...", __imag__ result
,
3844 -1.9833870299165354323L, CHOOSE(2e-19L, 0, 0));
3851 __complex__ MATHTYPE result
;
3853 result
= FUNC(casinh
) (BUILD_COMPLEX (0, 0));
3854 check ("real(casinh(0 + i0)) = 0", __real__ result
, 0);
3855 check ("imag(casinh(0 + i0)) = 0", __imag__ result
, 0);
3856 result
= FUNC(casinh
) (BUILD_COMPLEX (minus_zero
, 0));
3857 check ("real(casinh(-0 + i0)) = -0", __real__ result
, minus_zero
);
3858 check ("imag(casinh(-0 + i0)) = 0", __imag__ result
, 0);
3859 result
= FUNC(casinh
) (BUILD_COMPLEX (0, minus_zero
));
3860 check ("real(casinh(0 - i0)) = 0", __real__ result
, 0);
3861 check ("imag(casinh(0 - i0)) = -0", __imag__ result
, minus_zero
);
3862 result
= FUNC(casinh
) (BUILD_COMPLEX (minus_zero
, minus_zero
));
3863 check ("real(casinh(-0 - i0)) = -0", __real__ result
, minus_zero
);
3864 check ("imag(casinh(-0 - i0)) = -0", __imag__ result
, minus_zero
);
3866 result
= FUNC(casinh
) (BUILD_COMPLEX (plus_infty
, plus_infty
));
3867 check_isinfp ("real(casinh(+Inf + i Inf)) = +Inf", __real__ result
);
3868 check ("imag(casinh(+Inf + i Inf)) = pi/4", __imag__ result
, M_PI_4
);
3869 result
= FUNC(casinh
) (BUILD_COMPLEX (plus_infty
, minus_infty
));
3870 check_isinfp ("real(casinh(+Inf - i Inf)) = +Inf", __real__ result
);
3871 check ("imag(casinh(+Inf - i Inf)) = -pi/4", __imag__ result
, -M_PI_4
);
3872 result
= FUNC(casinh
) (BUILD_COMPLEX (minus_infty
, plus_infty
));
3873 check_isinfn ("real(casinh(-Inf + i Inf)) = -Inf", __real__ result
);
3874 check ("imag(casinh(-Inf + i Inf)) = pi/4", __imag__ result
, M_PI_4
);
3875 result
= FUNC(casinh
) (BUILD_COMPLEX (minus_infty
, minus_infty
));
3876 check_isinfn ("real(casinh(-Inf - i Inf)) = -Inf", __real__ result
);
3877 check ("imag(casinh(-Inf - i Inf)) = -pi/4", __imag__ result
, -M_PI_4
);
3879 result
= FUNC(casinh
) (BUILD_COMPLEX (-10.0, plus_infty
));
3880 check_isinfn ("real(casinh(-10.0 + i Inf)) = -Inf", __real__ result
);
3881 check ("imag(casinh(-10.0 + i Inf)) = pi/2", __imag__ result
, M_PI_2
);
3882 result
= FUNC(casinh
) (BUILD_COMPLEX (-10.0, minus_infty
));
3883 check_isinfn ("real(casinh(-10.0 - i Inf)) = -Inf", __real__ result
);
3884 check ("imag(casinh(-10.0 - i Inf)) = -pi/2", __imag__ result
, -M_PI_2
);
3885 result
= FUNC(casinh
) (BUILD_COMPLEX (0, plus_infty
));
3886 check_isinfp ("real(casinh(0 + i Inf)) = +Inf", __real__ result
);
3887 check ("imag(casinh(0 + i Inf)) = pi/2", __imag__ result
, M_PI_2
);
3888 result
= FUNC(casinh
) (BUILD_COMPLEX (0, minus_infty
));
3889 check_isinfp ("real(casinh(0 - i Inf)) = +Inf", __real__ result
);
3890 check ("imag(casinh(0 - i Inf)) = -pi/2", __imag__ result
, -M_PI_2
);
3891 result
= FUNC(casinh
) (BUILD_COMPLEX (minus_zero
, plus_infty
));
3892 check_isinfn ("real(casinh(-0 + i Inf)) = -Inf", __real__ result
);
3893 check ("imag(casinh(-0 + i Inf)) = pi/2", __imag__ result
, M_PI_2
);
3894 result
= FUNC(casinh
) (BUILD_COMPLEX (minus_zero
, minus_infty
));
3895 check_isinfn ("real(casinh(-0 - i Inf)) = -Inf", __real__ result
);
3896 check ("imag(casinh(-0 - i Inf)) = -pi/2", __imag__ result
, -M_PI_2
);
3897 result
= FUNC(casinh
) (BUILD_COMPLEX (0.1, plus_infty
));
3898 check_isinfp ("real(casinh(0.1 + i Inf)) = +Inf", __real__ result
);
3899 check ("imag(casinh(0.1 + i Inf)) = pi/2", __imag__ result
, M_PI_2
);
3900 result
= FUNC(casinh
) (BUILD_COMPLEX (0.1, minus_infty
));
3901 check_isinfp ("real(casinh(0.1 - i Inf)) = +Inf", __real__ result
);
3902 check ("imag(casinh(0.1 - i Inf)) = -pi/2", __imag__ result
, -M_PI_2
);
3904 result
= FUNC(casinh
) (BUILD_COMPLEX (minus_infty
, 0));
3905 check_isinfn ("real(casinh(-Inf + i0)) = -Inf", __real__ result
);
3906 check ("imag(casinh(-Inf + i0)) = 0", __imag__ result
, 0);
3907 result
= FUNC(casinh
) (BUILD_COMPLEX (minus_infty
, minus_zero
));
3908 check_isinfn ("real(casinh(-Inf - i0)) = -Inf", __real__ result
);
3909 check ("imag(casinh(-Inf - i0)) = -0", __imag__ result
, minus_zero
);
3910 result
= FUNC(casinh
) (BUILD_COMPLEX (minus_infty
, 100));
3911 check_isinfn ("real(casinh(-Inf + i100)) = -Inf", __real__ result
);
3912 check ("imag(casinh(-Inf + i100)) = 0", __imag__ result
, 0);
3913 result
= FUNC(casinh
) (BUILD_COMPLEX (minus_infty
, -100));
3914 check_isinfn ("real(casinh(-Inf - i100)) = -Inf", __real__ result
);
3915 check ("imag(casinh(-Inf - i100)) = -0", __imag__ result
, minus_zero
);
3917 result
= FUNC(casinh
) (BUILD_COMPLEX (plus_infty
, 0));
3918 check_isinfp ("real(casinh(+Inf + i0)) = +Inf", __real__ result
);
3919 check ("imag(casinh(+Inf + i0)) = 0", __imag__ result
, 0);
3920 result
= FUNC(casinh
) (BUILD_COMPLEX (plus_infty
, minus_zero
));
3921 check_isinfp ("real(casinh(+Inf - i0)) = +Inf", __real__ result
);
3922 check ("imag(casinh(+Inf - i0)) = -0", __imag__ result
, minus_zero
);
3923 result
= FUNC(casinh
) (BUILD_COMPLEX (plus_infty
, 0.5));
3924 check_isinfp ("real(casinh(+Inf + i0.5)) = +Inf", __real__ result
);
3925 check ("imag(casinh(+Inf + i0.5)) = 0", __imag__ result
, 0);
3926 result
= FUNC(casinh
) (BUILD_COMPLEX (plus_infty
, -0.5));
3927 check_isinfp ("real(casinh(+Inf - i0.5)) = +Inf", __real__ result
);
3928 check ("imag(casinh(+Inf - i0.5)) = -0", __imag__ result
, minus_zero
);
3930 result
= FUNC(casinh
) (BUILD_COMPLEX (plus_infty
, nan_value
));
3931 check_isinfp ("real(casinh(+Inf + i NaN)) = +Inf", __real__ result
);
3932 check_isnan ("imag(casinh(+Inf + i NaN)) = NaN", __imag__ result
);
3933 result
= FUNC(casinh
) (BUILD_COMPLEX (minus_infty
, nan_value
));
3934 check_isinfn ("real(casinh(-Inf + i NaN)) = -Inf", __real__ result
);
3935 check_isnan ("imag(casinh(-Inf + i NaN)) = NaN", __imag__ result
);
3937 result
= FUNC(casinh
) (BUILD_COMPLEX (nan_value
, 0));
3938 check_isnan ("real(casinh(NaN + i0)) = NaN", __real__ result
);
3939 check ("imag(casinh(NaN + i0)) = 0", __imag__ result
, 0);
3940 result
= FUNC(casinh
) (BUILD_COMPLEX (nan_value
, minus_zero
));
3941 check_isnan ("real(casinh(NaN - i0)) = NaN", __real__ result
);
3942 check ("imag(casinh(NaN - i0)) = -0", __imag__ result
, minus_zero
);
3944 result
= FUNC(casinh
) (BUILD_COMPLEX (nan_value
, plus_infty
));
3945 check_isinfp ("real(casinh(NaN + i Inf)) = +-Inf",
3946 FUNC(fabs
) (__real__ result
));
3947 check_isnan ("imag(casinh(NaN + i Inf)) = NaN", __imag__ result
);
3948 result
= FUNC(casinh
) (BUILD_COMPLEX (nan_value
, minus_infty
));
3949 check_isinfp ("real(casinh(NaN - i Inf)) = +-Inf",
3950 FUNC(fabs
) (__real__ result
));
3951 check_isnan ("imag(casinh(NaN - i Inf)) = NaN", __imag__ result
);
3953 result
= FUNC(casinh
) (BUILD_COMPLEX (10.5, nan_value
));
3954 check_isnan_maybe_exc ("real(casinh(10.5 + i NaN)) = NaN plus maybe invalid exception",
3955 __real__ result
, INVALID_EXCEPTION
);
3956 check_isnan ("imag(casinh(10.5 + i NaN)) = NaN plus maybe invalid exception",
3958 result
= FUNC(casinh
) (BUILD_COMPLEX (-10.5, nan_value
));
3959 check_isnan_maybe_exc ("real(casinh(-10.5 + i NaN)) = NaN plus maybe invalid exception",
3960 __real__ result
, INVALID_EXCEPTION
);
3961 check_isnan ("imag(casinh(-10.5 + i NaN)) = NaN plus maybe invalid exception",
3964 result
= FUNC(casinh
) (BUILD_COMPLEX (nan_value
, 0.75));
3965 check_isnan_maybe_exc ("real(casinh(NaN + i0.75)) = NaN plus maybe invalid exception",
3966 __real__ result
, INVALID_EXCEPTION
);
3967 check_isnan ("imag(casinh(NaN + i0.75)) = NaN plus maybe invalid exception",
3969 result
= FUNC(casinh
) (BUILD_COMPLEX (-0.75, nan_value
));
3970 check_isnan_maybe_exc ("real(casinh(NaN - i0.75)) = NaN plus maybe invalid exception",
3971 __real__ result
, INVALID_EXCEPTION
);
3972 check_isnan ("imag(casinh(NaN - i0.75)) = NaN plus maybe invalid exception",
3975 result
= FUNC(casinh
) (BUILD_COMPLEX (nan_value
, nan_value
));
3976 check_isnan ("real(casinh(NaN + i NaN)) = NaN", __real__ result
);
3977 check_isnan ("imag(casinh(NaN + i NaN)) = NaN", __imag__ result
);
3979 result
= FUNC(casinh
) (BUILD_COMPLEX (0.7, 1.2));
3980 check_eps ("real(casinh(0.7 + i 1.2)) == 0.97865...", __real__ result
,
3981 0.9786545955936738768L, CHOOSE(5e-17L, 2e-16, 0));
3982 check_eps ("imag(casinh(0.7 + i 1.2)) == 0.91135...", __imag__ result
,
3983 0.9113541895315601156L, CHOOSE(7e-19L, 0, 6e-8));
3985 result
= FUNC(casinh
) (BUILD_COMPLEX (-2, -3));
3986 check_eps ("real(casinh(-2 - i 3)) == --1.96863...", __real__ result
,
3987 -1.9686379257930962917L, CHOOSE(7e-19L, 2e-15, 2e-7));
3988 check_eps ("imag(casinh(-2 - i 3)) == -0.96465...", __imag__ result
,
3989 -0.9646585044076027920L, CHOOSE(4e-19L, 2e-15, 4e-7));
3996 __complex__ MATHTYPE result
;
3998 result
= FUNC(catan
) (BUILD_COMPLEX (0, 0));
3999 check ("real(catan(0 + i0)) = 0", __real__ result
, 0);
4000 check ("imag(catan(0 + i0)) = 0", __imag__ result
, 0);
4001 result
= FUNC(catan
) (BUILD_COMPLEX (minus_zero
, 0));
4002 check ("real(catan(-0 + i0)) = -0", __real__ result
, minus_zero
);
4003 check ("imag(catan(-0 + i0)) = 0", __imag__ result
, 0);
4004 result
= FUNC(catan
) (BUILD_COMPLEX (0, minus_zero
));
4005 check ("real(catan(0 - i0)) = 0", __real__ result
, 0);
4006 check ("imag(catan(0 - i0)) = -0", __imag__ result
, minus_zero
);
4007 result
= FUNC(catan
) (BUILD_COMPLEX (minus_zero
, minus_zero
));
4008 check ("real(catan(-0 - i0)) = -0", __real__ result
, minus_zero
);
4009 check ("imag(catan(-0 - i0)) = -0", __imag__ result
, minus_zero
);
4011 result
= FUNC(catan
) (BUILD_COMPLEX (plus_infty
, plus_infty
));
4012 check ("real(catan(+Inf + i Inf)) = pi/2", __real__ result
, M_PI_2
);
4013 check ("imag(catan(+Inf + i Inf)) = 0", __imag__ result
, 0);
4014 result
= FUNC(catan
) (BUILD_COMPLEX (plus_infty
, minus_infty
));
4015 check ("real(catan(+Inf - i Inf)) = pi/2", __real__ result
, M_PI_2
);
4016 check ("imag(catan(+Inf - i Inf)) = -0", __imag__ result
, minus_zero
);
4017 result
= FUNC(catan
) (BUILD_COMPLEX (minus_infty
, plus_infty
));
4018 check ("real(catan(-Inf + i Inf)) = -pi/2", __real__ result
, -M_PI_2
);
4019 check ("imag(catan(-Inf + i Inf)) = 0", __imag__ result
, 0.0);
4020 result
= FUNC(catan
) (BUILD_COMPLEX (minus_infty
, minus_infty
));
4021 check ("real(catan(-Inf - i Inf)) = -pi/2", __real__ result
, -M_PI_2
);
4022 check ("imag(catan(-Inf - i Inf)) = -0", __imag__ result
, minus_zero
);
4024 result
= FUNC(catan
) (BUILD_COMPLEX (plus_infty
, -10.0));
4025 check ("real(catan(+Inf - i10.0)) = pi/2", __real__ result
, M_PI_2
);
4026 check ("imag(catan(+Inf - i10.0)) = -0", __imag__ result
, minus_zero
);
4027 result
= FUNC(catan
) (BUILD_COMPLEX (minus_infty
, -10.0));
4028 check ("real(catan(-Inf - i10.0)) = -pi/2", __real__ result
, -M_PI_2
);
4029 check ("imag(catan(-Inf - i10.0)) = -0", __imag__ result
, minus_zero
);
4030 result
= FUNC(catan
) (BUILD_COMPLEX (plus_infty
, minus_zero
));
4031 check ("real(catan(Inf - i0)) = pi/2", __real__ result
, M_PI_2
);
4032 check ("imag(catan(Inf - i0)) = -0", __imag__ result
, minus_zero
);
4033 result
= FUNC(catan
) (BUILD_COMPLEX (minus_infty
, minus_zero
));
4034 check ("real(catan(-Inf - i0)) = -pi/2", __real__ result
, -M_PI_2
);
4035 check ("imag(catan(-Inf - i0)) = -0", __imag__ result
, minus_zero
);
4036 result
= FUNC(catan
) (BUILD_COMPLEX (plus_infty
, 0.0));
4037 check ("real(catan(Inf + i0)) = pi/2", __real__ result
, M_PI_2
);
4038 check ("imag(catan(Inf + i0)) = 0", __imag__ result
, 0.0);
4039 result
= FUNC(catan
) (BUILD_COMPLEX (minus_infty
, 0.0));
4040 check ("real(catan(-Inf + i0)) = -pi/2", __real__ result
, -M_PI_2
);
4041 check ("imag(catan(-Inf + i0)) = 0", __imag__ result
, 0.0);
4042 result
= FUNC(catan
) (BUILD_COMPLEX (plus_infty
, 0.1));
4043 check ("real(catan(+Inf + i0.1)) = pi/2", __real__ result
, M_PI_2
);
4044 check ("imag(catan(+Inf + i0.1)) = 0", __imag__ result
, 0);
4045 result
= FUNC(catan
) (BUILD_COMPLEX (minus_infty
, 0.1));
4046 check ("real(catan(-Inf + i0.1)) = -pi/2", __real__ result
, -M_PI_2
);
4047 check ("imag(catan(-Inf + i0.1)) = 0", __imag__ result
, 0);
4049 result
= FUNC(catan
) (BUILD_COMPLEX (0.0, minus_infty
));
4050 check ("real(catan(0 - i Inf)) = pi/2", __real__ result
, M_PI_2
);
4051 check ("imag(catan(0 - i Inf)) = -0", __imag__ result
, minus_zero
);
4052 result
= FUNC(catan
) (BUILD_COMPLEX (minus_zero
, minus_infty
));
4053 check ("real(catan(-0 - i Inf)) = -pi/2", __real__ result
, -M_PI_2
);
4054 check ("imag(catan(-0 - i Inf)) = -0", __imag__ result
, minus_zero
);
4055 result
= FUNC(catan
) (BUILD_COMPLEX (100.0, minus_infty
));
4056 check ("real(catan(100 - i Inf)) = pi/2", __real__ result
, M_PI_2
);
4057 check ("imag(catan(100 - i Inf)) = -0", __imag__ result
, minus_zero
);
4058 result
= FUNC(catan
) (BUILD_COMPLEX (-100.0, minus_infty
));
4059 check ("real(catan(-100 - i Inf)) = -pi/2", __real__ result
, -M_PI_2
);
4060 check ("imag(catan(-100 - i Inf)) = -0", __imag__ result
, minus_zero
);
4062 result
= FUNC(catan
) (BUILD_COMPLEX (0.0, plus_infty
));
4063 check ("real(catan(0 + i Inf)) = pi/2", __real__ result
, M_PI_2
);
4064 check ("imag(catan(0 + i Inf)) = 0", __imag__ result
, 0);
4065 result
= FUNC(catan
) (BUILD_COMPLEX (minus_zero
, plus_infty
));
4066 check ("real(catan(-0 + i Inf)) = -pi/2", __real__ result
, -M_PI_2
);
4067 check ("imag(catan(-0 + i Inf)) = 0", __imag__ result
, 0);
4068 result
= FUNC(catan
) (BUILD_COMPLEX (0.5, plus_infty
));
4069 check ("real(catan(0.5 + i Inf)) = pi/2", __real__ result
, M_PI_2
);
4070 check ("imag(catan(0.5 + i Inf)) = 0", __imag__ result
, 0);
4071 result
= FUNC(catan
) (BUILD_COMPLEX (-0.5, plus_infty
));
4072 check ("real(catan(-0.5 + i Inf)) = -pi/2", __real__ result
, -M_PI_2
);
4073 check ("imag(catan(-0.5 + i Inf)) = 0", __imag__ result
, 0);
4075 result
= FUNC(catan
) (BUILD_COMPLEX (nan_value
, 0.0));
4076 check_isnan ("real(catan(NaN + i0)) = NaN", __real__ result
);
4077 check ("imag(catan(NaN + i0)) = 0", __imag__ result
, 0.0);
4078 result
= FUNC(catan
) (BUILD_COMPLEX (nan_value
, minus_zero
));
4079 check_isnan ("real(catan(NaN - i0)) = NaN", __real__ result
);
4080 check ("imag(catan(NaN - i0)) = -0", __imag__ result
, minus_zero
);
4082 result
= FUNC(catan
) (BUILD_COMPLEX (nan_value
, plus_infty
));
4083 check_isnan ("real(catan(NaN + i Inf)) = NaN", __real__ result
);
4084 check ("imag(catan(NaN + i Inf)) = 0", __imag__ result
, 0);
4085 result
= FUNC(catan
) (BUILD_COMPLEX (nan_value
, minus_infty
));
4086 check_isnan ("real(catan(NaN - i Inf)) = NaN", __real__ result
);
4087 check ("imag(catan(NaN - i Inf)) = -0", __imag__ result
, minus_zero
);
4089 result
= FUNC(catan
) (BUILD_COMPLEX (0.0, nan_value
));
4090 check_isnan ("real(catan(0 + i NaN)) = NaN", __real__ result
);
4091 check_isnan ("imag(catan(0 + i NaN)) = NaN", __imag__ result
);
4092 result
= FUNC(catan
) (BUILD_COMPLEX (minus_zero
, nan_value
));
4093 check_isnan ("real(catan(-0 + i NaN)) = NaN", __real__ result
);
4094 check_isnan ("imag(catan(-0 + i NaN)) = NaN", __imag__ result
);
4096 result
= FUNC(catan
) (BUILD_COMPLEX (plus_infty
, nan_value
));
4097 check ("real(catan(+Inf + i NaN)) = pi/2", __real__ result
, M_PI_2
);
4098 check ("imag(catan(+Inf + i NaN)) = +-0", FUNC(fabs
) (__imag__ result
), 0);
4099 result
= FUNC(catan
) (BUILD_COMPLEX (minus_infty
, nan_value
));
4100 check ("real(catan(-Inf + i NaN)) = -pi/2", __real__ result
, -M_PI_2
);
4101 check ("imag(catan(-Inf + i NaN)) = +-0", FUNC(fabs
) (__imag__ result
), 0);
4103 result
= FUNC(catan
) (BUILD_COMPLEX (nan_value
, 10.5));
4104 check_isnan_maybe_exc ("real(catan(NaN + i10.5)) = NaN plus maybe invalid exception",
4105 __real__ result
, INVALID_EXCEPTION
);
4106 check_isnan ("imag(catan(NaN + i10.5)) = NaN plus maybe invalid exception",
4108 result
= FUNC(catan
) (BUILD_COMPLEX (nan_value
, -10.5));
4109 check_isnan_maybe_exc ("real(catan(NaN - i10.5)) = NaN plus maybe invalid exception",
4110 __real__ result
, INVALID_EXCEPTION
);
4111 check_isnan ("imag(catan(NaN - i10.5)) = NaN plus maybe invalid exception",
4114 result
= FUNC(catan
) (BUILD_COMPLEX (0.75, nan_value
));
4115 check_isnan_maybe_exc ("real(catan(0.75 + i NaN)) = NaN plus maybe invalid exception",
4116 __real__ result
, INVALID_EXCEPTION
);
4117 check_isnan ("imag(catan(0.75 + i NaN)) = NaN plus maybe invalid exception",
4119 result
= FUNC(catan
) (BUILD_COMPLEX (-0.75, nan_value
));
4120 check_isnan_maybe_exc ("real(catan(-0.75 + i NaN)) = NaN plus maybe invalid exception",
4121 __real__ result
, INVALID_EXCEPTION
);
4122 check_isnan ("imag(catan(-0.75 + i NaN)) = NaN plus maybe invalid exception",
4125 result
= FUNC(catan
) (BUILD_COMPLEX (nan_value
, nan_value
));
4126 check_isnan ("real(catan(NaN + i NaN)) = NaN", __real__ result
);
4127 check_isnan ("imag(catan(NaN + i NaN)) = NaN", __imag__ result
);
4129 result
= FUNC(catan
) (BUILD_COMPLEX (0.7, 1.2));
4130 check_eps ("real(catan(0.7 + i 1.2)) == 1.07857...", __real__ result
,
4131 1.0785743834118921877L, CHOOSE (3e-17, 0, 0));
4132 check_eps ("imag(catan(0.7 + i 1.2)) == 0.57705...", __imag__ result
,
4133 0.5770573776534306764L, CHOOSE(3e-17L, 0, 6e-8));
4135 result
= FUNC(catan
) (BUILD_COMPLEX (-2, -3));
4136 check ("real(catan(-2 - i 3)) == -1.40992...", __real__ result
,
4137 -1.4099210495965755225L);
4138 check_eps ("imag(catan(-2 - i 3)) == -0.22907...", __imag__ result
,
4139 -0.2290726829685387662L, CHOOSE(1e-19L, 3e-17, 2e-8));
4146 __complex__ MATHTYPE result
;
4148 result
= FUNC(catanh
) (BUILD_COMPLEX (0, 0));
4149 check ("real(catanh(0 + i0)) = 0", __real__ result
, 0);
4150 check ("imag(catanh(0 + i0)) = 0", __imag__ result
, 0);
4151 result
= FUNC(catanh
) (BUILD_COMPLEX (minus_zero
, 0));
4152 check ("real(catanh(-0 + i0)) = -0", __real__ result
, minus_zero
);
4153 check ("imag(catanh(-0 + i0)) = 0", __imag__ result
, 0);
4154 result
= FUNC(catanh
) (BUILD_COMPLEX (0, minus_zero
));
4155 check ("real(catanh(0 - i0)) = 0", __real__ result
, 0);
4156 check ("imag(catanh(0 - i0)) = -0", __imag__ result
, minus_zero
);
4157 result
= FUNC(catanh
) (BUILD_COMPLEX (minus_zero
, minus_zero
));
4158 check ("real(catanh(-0 - i0)) = -0", __real__ result
, minus_zero
);
4159 check ("imag(catanh(-0 - i0)) = -0", __imag__ result
, minus_zero
);
4161 result
= FUNC(catanh
) (BUILD_COMPLEX (plus_infty
, plus_infty
));
4162 check ("real(catanh(+Inf + i Inf)) = 0", __real__ result
, 0);
4163 check ("imag(catanh(+Inf + i Inf)) = pi/2", __imag__ result
, M_PI_2
);
4164 result
= FUNC(catanh
) (BUILD_COMPLEX (plus_infty
, minus_infty
));
4165 check ("real(catanh(+Inf - i Inf)) = 0", __real__ result
, 0);
4166 check ("imag(catanh(+Inf - i Inf)) = -pi/2", __imag__ result
, -M_PI_2
);
4167 result
= FUNC(catanh
) (BUILD_COMPLEX (minus_infty
, plus_infty
));
4168 check ("real(catanh(-Inf + i Inf)) = -0", __real__ result
, minus_zero
);
4169 check ("imag(catanh(-Inf + i Inf)) = pi/2", __imag__ result
, M_PI_2
);
4170 result
= FUNC(catanh
) (BUILD_COMPLEX (minus_infty
, minus_infty
));
4171 check ("real(catanh(-Inf - i Inf)) = -0", __real__ result
, minus_zero
);
4172 check ("imag(catanh(-Inf - i Inf)) = -pi/2", __imag__ result
, -M_PI_2
);
4174 result
= FUNC(catanh
) (BUILD_COMPLEX (-10.0, plus_infty
));
4175 check ("real(catanh(-10.0 + i Inf)) = -0", __real__ result
, minus_zero
);
4176 check ("imag(catanh(-10.0 + i Inf)) = pi/2", __imag__ result
, M_PI_2
);
4177 result
= FUNC(catanh
) (BUILD_COMPLEX (-10.0, minus_infty
));
4178 check ("real(catanh(-10.0 - i Inf)) = -0", __real__ result
, minus_zero
);
4179 check ("imag(catanh(-10.0 - i Inf)) = -pi/2", __imag__ result
, -M_PI_2
);
4180 result
= FUNC(catanh
) (BUILD_COMPLEX (minus_zero
, plus_infty
));
4181 check ("real(catanh(-0 + i Inf)) = -0", __real__ result
, minus_zero
);
4182 check ("imag(catanh(-0 + i Inf)) = pi/2", __imag__ result
, M_PI_2
);
4183 result
= FUNC(catanh
) (BUILD_COMPLEX (minus_zero
, minus_infty
));
4184 check ("real(catanh(-0 - i Inf)) = -0", __real__ result
, minus_zero
);
4185 check ("imag(catanh(-0 - i Inf)) = -pi/2", __imag__ result
, -M_PI_2
);
4186 result
= FUNC(catanh
) (BUILD_COMPLEX (0, plus_infty
));
4187 check ("real(catanh(0 + i Inf)) = 0", __real__ result
, 0);
4188 check ("imag(catanh(0 + i Inf)) = pi/2", __imag__ result
, M_PI_2
);
4189 result
= FUNC(catanh
) (BUILD_COMPLEX (0, minus_infty
));
4190 check ("real(catanh(0 - i Inf)) = 0", __real__ result
, 0);
4191 check ("imag(catanh(0 - i Inf)) = -pi/2", __imag__ result
, -M_PI_2
);
4192 result
= FUNC(catanh
) (BUILD_COMPLEX (0.1, plus_infty
));
4193 check ("real(catanh(0.1 + i Inf)) = 0", __real__ result
, 0);
4194 check ("imag(catanh(0.1 + i Inf)) = pi/2", __imag__ result
, M_PI_2
);
4195 result
= FUNC(catanh
) (BUILD_COMPLEX (0.1, minus_infty
));
4196 check ("real(catanh(0.1 - i Inf)) = 0", __real__ result
, 0);
4197 check ("imag(catanh(0.1 - i Inf)) = -pi/2", __imag__ result
, -M_PI_2
);
4199 result
= FUNC(catanh
) (BUILD_COMPLEX (minus_infty
, 0));
4200 check ("real(catanh(-Inf + i0)) = -0", __real__ result
, minus_zero
);
4201 check ("imag(catanh(-Inf + i0)) = pi/2", __imag__ result
, M_PI_2
);
4202 result
= FUNC(catanh
) (BUILD_COMPLEX (minus_infty
, minus_zero
));
4203 check ("real(catanh(-Inf - i0)) = -0", __real__ result
, minus_zero
);
4204 check ("imag(catanh(-Inf - i0)) = -pi/2", __imag__ result
, -M_PI_2
);
4205 result
= FUNC(catanh
) (BUILD_COMPLEX (minus_infty
, 100));
4206 check ("real(catanh(-Inf + i100)) = -0", __real__ result
, minus_zero
);
4207 check ("imag(catanh(-Inf + i100)) = pi/2", __imag__ result
, M_PI_2
);
4208 result
= FUNC(catanh
) (BUILD_COMPLEX (minus_infty
, -100));
4209 check ("real(catanh(-Inf - i100)) = -0", __real__ result
, minus_zero
);
4210 check ("imag(catanh(-Inf - i100)) = -pi/2", __imag__ result
, -M_PI_2
);
4212 result
= FUNC(catanh
) (BUILD_COMPLEX (plus_infty
, 0));
4213 check ("real(catanh(+Inf + i0)) = 0", __real__ result
, 0);
4214 check ("imag(catanh(+Inf + i0)) = pi/2", __imag__ result
, M_PI_2
);
4215 result
= FUNC(catanh
) (BUILD_COMPLEX (plus_infty
, minus_zero
));
4216 check ("real(catanh(+Inf - i0)) = 0", __real__ result
, 0);
4217 check ("imag(catanh(+Inf - i0)) = -pi/2", __imag__ result
, -M_PI_2
);
4218 result
= FUNC(catanh
) (BUILD_COMPLEX (plus_infty
, 0.5));
4219 check ("real(catanh(+Inf + i0.5)) = 0", __real__ result
, 0);
4220 check ("imag(catanh(+Inf + i0.5)) = pi/2", __imag__ result
, M_PI_2
);
4221 result
= FUNC(catanh
) (BUILD_COMPLEX (plus_infty
, -0.5));
4222 check ("real(catanh(+Inf - i0.5)) = 0", __real__ result
, 0);
4223 check ("imag(catanh(+Inf - i0.5)) = -pi/2", __imag__ result
, -M_PI_2
);
4225 result
= FUNC(catanh
) (BUILD_COMPLEX (0, nan_value
));
4226 check ("real(catanh(0 + i NaN)) = 0", __real__ result
, 0);
4227 check_isnan ("imag(catanh(0 + i NaN)) = NaN", __imag__ result
);
4228 result
= FUNC(catanh
) (BUILD_COMPLEX (minus_zero
, nan_value
));
4229 check ("real(catanh(-0 + i NaN)) = -0", __real__ result
, minus_zero
);
4230 check_isnan ("imag(catanh(-0 + i NaN)) = NaN", __imag__ result
);
4232 result
= FUNC(catanh
) (BUILD_COMPLEX (plus_infty
, nan_value
));
4233 check ("real(catanh(+Inf + i NaN)) = 0", __real__ result
, 0);
4234 check_isnan ("imag(catanh(+Inf + i NaN)) = NaN", __imag__ result
);
4235 result
= FUNC(catanh
) (BUILD_COMPLEX (minus_infty
, nan_value
));
4236 check ("real(catanh(-Inf + i NaN)) = -0", __real__ result
, minus_zero
);
4237 check_isnan ("imag(catanh(-Inf + i NaN)) = NaN", __imag__ result
);
4239 result
= FUNC(catanh
) (BUILD_COMPLEX (nan_value
, 0));
4240 check_isnan ("real(catanh(NaN + i0)) = NaN", __real__ result
);
4241 check_isnan ("imag(catanh(NaN + i0)) = NaN", __imag__ result
);
4242 result
= FUNC(catanh
) (BUILD_COMPLEX (nan_value
, minus_zero
));
4243 check_isnan ("real(catanh(NaN - i0)) = NaN", __real__ result
);
4244 check_isnan ("imag(catanh(NaN - i0)) = NaN", __imag__ result
);
4246 result
= FUNC(catanh
) (BUILD_COMPLEX (nan_value
, plus_infty
));
4247 check ("real(catanh(NaN + i Inf)) = +-0", FUNC(fabs
) (__real__ result
), 0);
4248 check ("imag(catanh(NaN + i Inf)) = pi/2", __imag__ result
, M_PI_2
);
4249 result
= FUNC(catanh
) (BUILD_COMPLEX (nan_value
, minus_infty
));
4250 check ("real(catanh(NaN - i Inf)) = +-0", FUNC(fabs
) (__real__ result
), 0);
4251 check ("imag(catanh(NaN - i Inf)) = -pi/2", __imag__ result
, -M_PI_2
);
4253 result
= FUNC(catanh
) (BUILD_COMPLEX (10.5, nan_value
));
4254 check_isnan_maybe_exc ("real(catanh(10.5 + i NaN)) = NaN plus maybe invalid exception",
4255 __real__ result
, INVALID_EXCEPTION
);
4256 check_isnan ("imag(catanh(10.5 + i NaN)) = NaN plus maybe invalid exception",
4258 result
= FUNC(catanh
) (BUILD_COMPLEX (-10.5, nan_value
));
4259 check_isnan_maybe_exc ("real(catanh(-10.5 + i NaN)) = NaN plus maybe invalid exception",
4260 __real__ result
, INVALID_EXCEPTION
);
4261 check_isnan ("imag(catanh(-10.5 + i NaN)) = NaN plus maybe invalid exception",
4264 result
= FUNC(catanh
) (BUILD_COMPLEX (nan_value
, 0.75));
4265 check_isnan_maybe_exc ("real(catanh(NaN + i0.75)) = NaN plus maybe invalid exception",
4266 __real__ result
, INVALID_EXCEPTION
);
4267 check_isnan ("imag(catanh(NaN + i0.75)) = NaN plus maybe invalid exception",
4269 result
= FUNC(catanh
) (BUILD_COMPLEX (nan_value
, -0.75));
4270 check_isnan_maybe_exc ("real(catanh(NaN - i0.75)) = NaN plus maybe invalid exception",
4271 __real__ result
, INVALID_EXCEPTION
);
4272 check_isnan ("imag(catanh(NaN - i0.75)) = NaN plus maybe invalid exception",
4275 result
= FUNC(catanh
) (BUILD_COMPLEX (nan_value
, nan_value
));
4276 check_isnan ("real(catanh(NaN + i NaN)) = NaN", __real__ result
);
4277 check_isnan ("imag(catanh(NaN + i NaN)) = NaN", __imag__ result
);
4279 result
= FUNC(catanh
) (BUILD_COMPLEX (0.7, 1.2));
4280 check_eps ("real(catanh(0.7 + i 1.2)) == 0.26007...", __real__ result
,
4281 0.2600749516525135959L, CHOOSE (2e-18, 0, 0));
4282 check_eps ("imag(catanh(0.7 + i 1.2)) == 0.97024...", __imag__ result
,
4283 0.9702403077950989849L, CHOOSE (3e-17, 0, 0));
4285 result
= FUNC(catanh
) (BUILD_COMPLEX (-2, -3));
4286 check_eps ("real(catanh(-2 - i 3)) == -0.14694...", __real__ result
,
4287 -0.1469466662255297520L, CHOOSE (3e-20, 6e-17, 2e-8));
4288 check ("imag(catanh(-2 - i 3)) == -1.33897...", __imag__ result
,
4289 -1.3389725222944935611L);
4296 __complex__ MATHTYPE result
;
4298 result
= FUNC(ctan
) (BUILD_COMPLEX (0, 0));
4299 check ("real(ctan(0 + i0)) = 0", __real__ result
, 0);
4300 check ("imag(ctan(0 + i0)) = 0", __imag__ result
, 0);
4301 result
= FUNC(ctan
) (BUILD_COMPLEX (0, minus_zero
));
4302 check ("real(ctan(0 - i0)) = 0", __real__ result
, 0);
4303 check ("imag(ctan(0 - i0)) = -0", __imag__ result
, minus_zero
);
4304 result
= FUNC(ctan
) (BUILD_COMPLEX (minus_zero
, 0));
4305 check ("real(ctan(-0 + i0)) = -0", __real__ result
, minus_zero
);
4306 check ("imag(ctan(-0 + i0)) = 0", __imag__ result
, 0);
4307 result
= FUNC(ctan
) (BUILD_COMPLEX (minus_zero
, minus_zero
));
4308 check ("real(ctan(-0 - i0)) = -0", __real__ result
, minus_zero
);
4309 check ("imag(ctan(-0 - i0)) = -0", __imag__ result
, minus_zero
);
4312 result
= FUNC(ctan
) (BUILD_COMPLEX (0, plus_infty
));
4313 check ("real(ctan(0 + i Inf)) = 0", __real__ result
, 0);
4314 check ("imag(ctan(0 + i Inf)) = 1", __imag__ result
, 1);
4315 result
= FUNC(ctan
) (BUILD_COMPLEX (1, plus_infty
));
4316 check ("real(ctan(1 + i Inf)) = 0", __real__ result
, 0);
4317 check ("imag(ctan(1 + i Inf)) = 1", __imag__ result
, 1);
4318 result
= FUNC(ctan
) (BUILD_COMPLEX (minus_zero
, plus_infty
));
4319 check ("real(ctan(-0 + i Inf)) = -0", __real__ result
, minus_zero
);
4320 check ("imag(ctan(-0 + i Inf)) = 1", __imag__ result
, 1);
4321 result
= FUNC(ctan
) (BUILD_COMPLEX (-1, plus_infty
));
4322 check ("real(ctan(-1 + i Inf)) = -0", __real__ result
, minus_zero
);
4323 check ("imag(ctan(-1 + i Inf)) = 1", __imag__ result
, 1);
4325 result
= FUNC(ctan
) (BUILD_COMPLEX (0, minus_infty
));
4326 check ("real(ctan(0 - i Inf)) = 0", __real__ result
, 0);
4327 check ("imag(ctan(0 - i Inf)) = -1", __imag__ result
, -1);
4328 result
= FUNC(ctan
) (BUILD_COMPLEX (1, minus_infty
));
4329 check ("real(ctan(1 - i Inf)) = 0", __real__ result
, 0);
4330 check ("imag(ctan(1 - i Inf)) = -1", __imag__ result
, -1);
4331 result
= FUNC(ctan
) (BUILD_COMPLEX (minus_zero
, minus_infty
));
4332 check ("real(ctan(-0 - i Inf)) = -0", __real__ result
, minus_zero
);
4333 check ("imag(ctan(-0 - i Inf)) = -1", __imag__ result
, -1);
4334 result
= FUNC(ctan
) (BUILD_COMPLEX (-1, minus_infty
));
4335 check ("real(ctan(-1 - i Inf)) = -0", __real__ result
, minus_zero
);
4336 check ("imag(ctan(-1 - i Inf)) = -1", __imag__ result
, -1);
4338 result
= FUNC(ctan
) (BUILD_COMPLEX (plus_infty
, 0));
4339 check_isnan_exc ("real(ctan(Inf + i 0)) = NaN plus invalid exception",
4340 __real__ result
, INVALID_EXCEPTION
);
4341 check_isnan ("imag(ctan(Inf + i 0)) = NaN plus invalid exception",
4343 result
= FUNC(ctan
) (BUILD_COMPLEX (plus_infty
, 2));
4344 check_isnan_exc ("real(ctan(Inf + i 2)) = NaN plus invalid exception",
4345 __real__ result
, INVALID_EXCEPTION
);
4346 check_isnan ("imag(ctan(Inf + i 2)) = NaN plus invalid exception",
4348 result
= FUNC(ctan
) (BUILD_COMPLEX (minus_infty
, 0));
4349 check_isnan_exc ("real(ctan(-Inf + i 0)) = NaN plus invalid exception",
4350 __real__ result
, INVALID_EXCEPTION
);
4351 check_isnan ("imag(ctan(-Inf + i 0)) = NaN plus invalid exception",
4353 result
= FUNC(ctan
) (BUILD_COMPLEX (minus_infty
, 2));
4354 check_isnan_exc ("real(ctan(- Inf + i 2)) = NaN plus invalid exception",
4355 __real__ result
, INVALID_EXCEPTION
);
4356 check_isnan ("imag(ctan(- Inf + i 2)) = NaN plus invalid exception",
4358 result
= FUNC(ctan
) (BUILD_COMPLEX (plus_infty
, minus_zero
));
4359 check_isnan_exc ("real(ctan(Inf - i 0)) = NaN plus invalid exception",
4360 __real__ result
, INVALID_EXCEPTION
);
4361 check_isnan ("imag(ctan(Inf - i 0)) = NaN plus invalid exception",
4363 result
= FUNC(ctan
) (BUILD_COMPLEX (plus_infty
, -2));
4364 check_isnan_exc ("real(ctan(Inf - i 2)) = NaN plus invalid exception",
4365 __real__ result
, INVALID_EXCEPTION
);
4366 check_isnan ("imag(ctan(Inf - i 2)) = NaN plus invalid exception",
4368 result
= FUNC(ctan
) (BUILD_COMPLEX (minus_infty
, minus_zero
));
4369 check_isnan_exc ("real(ctan(-Inf - i 0)) = NaN plus invalid exception",
4370 __real__ result
, INVALID_EXCEPTION
);
4371 check_isnan ("imag(ctan(-Inf - i 0)) = NaN plus invalid exception",
4373 result
= FUNC(ctan
) (BUILD_COMPLEX (minus_infty
, -2));
4374 check_isnan_exc ("real(ctan(-Inf - i 2)) = NaN plus invalid exception",
4375 __real__ result
, INVALID_EXCEPTION
);
4376 check_isnan ("imag(ctan(-Inf - i 2)) = NaN plus invalid exception",
4379 result
= FUNC(ctan
) (BUILD_COMPLEX (nan_value
, plus_infty
));
4380 check ("real(ctan(NaN + i Inf)) = +-0", FUNC(fabs
) (__real__ result
), 0);
4381 check ("imag(ctan(NaN + i Inf)) = 1", __imag__ result
, 1);
4382 result
= FUNC(ctan
) (BUILD_COMPLEX (nan_value
, minus_infty
));
4383 check ("real(ctan(NaN - i Inf)) = +-0", FUNC(fabs
) (__real__ result
), 0);
4384 check ("imag(ctan(NaN - i Inf)) = -1", __imag__ result
, -1);
4386 result
= FUNC(ctan
) (BUILD_COMPLEX (0, nan_value
));
4387 check ("real(ctan(0 + i NaN)) = 0", __real__ result
, 0);
4388 check_isnan ("imag(ctan(0 + i NaN)) = NaN", __imag__ result
);
4389 result
= FUNC(ctan
) (BUILD_COMPLEX (minus_zero
, nan_value
));
4390 check ("real(ctan(-0 + i NaN)) = -0", __real__ result
, minus_zero
);
4391 check_isnan ("imag(ctan(-0 + i NaN)) = NaN", __imag__ result
);
4393 result
= FUNC(ctan
) (BUILD_COMPLEX (0.5, nan_value
));
4394 check_isnan_maybe_exc ("real(ctan(0.5 + i NaN)) = NaN plus maybe invalid exception",
4395 __real__ result
, INVALID_EXCEPTION
);
4396 check_isnan ("imag(ctan(0.5 + i NaN)) = NaN plus maybe invalid exception",
4398 result
= FUNC(ctan
) (BUILD_COMPLEX (-4.5, nan_value
));
4399 check_isnan_maybe_exc ("real(ctan(-4.5 + i NaN)) = NaN plus maybe invalid exception",
4400 __real__ result
, INVALID_EXCEPTION
);
4401 check_isnan ("imag(ctan(-4.5 + i NaN)) = NaN plus maybe invalid exception",
4404 result
= FUNC(ctan
) (BUILD_COMPLEX (nan_value
, 0));
4405 check_isnan_maybe_exc ("real(ctan(NaN + i 0)) = NaN plus maybe invalid exception",
4406 __real__ result
, INVALID_EXCEPTION
);
4407 check_isnan ("imag(ctan(NaN + i 0)) = NaN plus maybe invalid exception",
4409 result
= FUNC(ctan
) (BUILD_COMPLEX (nan_value
, 5));
4410 check_isnan_maybe_exc ("real(ctan(NaN + i 5)) = NaN plus maybe invalid exception",
4411 __real__ result
, INVALID_EXCEPTION
);
4412 check_isnan ("imag(ctan(NaN + i 5)) = NaN plus maybe invalid exception",
4414 result
= FUNC(ctan
) (BUILD_COMPLEX (nan_value
, minus_zero
));
4415 check_isnan_maybe_exc ("real(ctan(NaN - i 0)) = NaN plus maybe invalid exception",
4416 __real__ result
, INVALID_EXCEPTION
);
4417 check_isnan ("imag(ctan(NaN - i 0)) = NaN plus maybe invalid exception",
4419 result
= FUNC(ctan
) (BUILD_COMPLEX (nan_value
, -0.25));
4420 check_isnan_maybe_exc ("real(ctan(NaN -i 0.25)) = NaN plus maybe invalid exception",
4421 __real__ result
, INVALID_EXCEPTION
);
4422 check_isnan ("imag(ctan(NaN -i 0.25)) = NaN plus maybe invalid exception",
4425 result
= FUNC(ctan
) (BUILD_COMPLEX (nan_value
, nan_value
));
4426 check_isnan ("real(ctan(NaN + i NaN)) = NaN", __real__ result
);
4427 check_isnan ("imag(ctan(NaN + i NaN)) = NaN", __imag__ result
);
4429 result
= FUNC(ctan
) (BUILD_COMPLEX (0.7, 1.2));
4430 check_eps ("real(ctan(0.7 + i 1.2)) == 0.17207...", __real__ result
,
4431 0.1720734197630349001L, CHOOSE(1e-17L, 3e-17, 2e-8));
4432 check_eps ("imag(ctan(0.7 + i 1.2)) == 0.95448...", __imag__ result
,
4433 0.9544807059989405538L, CHOOSE(2e-17L, 2e-16, 0));
4435 result
= FUNC(ctan
) (BUILD_COMPLEX (-2, -3));
4436 check_eps ("real(ctan(-2 - i 3)) == -0.00376...", __real__ result
,
4437 0.0037640256415042482L, CHOOSE(1e-19L, 0, 0));
4438 check_eps ("imag(ctan(-2 - i 3)) == -1.00323...", __imag__ result
,
4439 -1.0032386273536098014L, CHOOSE(2e-19L, 0, 2e-7));
4446 __complex__ MATHTYPE result
;
4448 result
= FUNC(ctanh
) (BUILD_COMPLEX (0, 0));
4449 check ("real(ctanh(0 + i0)) = 0", __real__ result
, 0);
4450 check ("imag(ctanh(0 + i0)) = 0", __imag__ result
, 0);
4451 result
= FUNC(ctanh
) (BUILD_COMPLEX (0, minus_zero
));
4452 check ("real(ctanh(0 - i0)) = 0", __real__ result
, 0);
4453 check ("imag(ctanh(0 - i0)) = -0", __imag__ result
, minus_zero
);
4454 result
= FUNC(ctanh
) (BUILD_COMPLEX (minus_zero
, 0));
4455 check ("real(ctanh(-0 + i0)) = -0", __real__ result
, minus_zero
);
4456 check ("imag(ctanh(-0 + i0)) = 0", __imag__ result
, 0);
4457 result
= FUNC(ctanh
) (BUILD_COMPLEX (minus_zero
, minus_zero
));
4458 check ("real(ctanh(-0 - i0)) = -0", __real__ result
, minus_zero
);
4459 check ("imag(ctanh(-0 - i0)) = -0", __imag__ result
, minus_zero
);
4461 result
= FUNC(ctanh
) (BUILD_COMPLEX (plus_infty
, 0));
4462 check ("real(ctanh(+Inf + i0)) = 1", __real__ result
, 1);
4463 check ("imag(ctanh(+Inf + i0)) = 0", __imag__ result
, 0);
4464 result
= FUNC(ctanh
) (BUILD_COMPLEX (plus_infty
, 1));
4465 check ("real(ctanh(+Inf + i1)) = 1", __real__ result
, 1);
4466 check ("imag(ctanh(+Inf + i1)) = 0", __imag__ result
, 0);
4467 result
= FUNC(ctanh
) (BUILD_COMPLEX (plus_infty
, minus_zero
));
4468 check ("real(ctanh(+Inf - i0)) = 1", __real__ result
, 1);
4469 check ("imag(ctanh(+Inf - i0)) = -0", __imag__ result
, minus_zero
);
4470 result
= FUNC(ctanh
) (BUILD_COMPLEX (plus_infty
, -1));
4471 check ("real(ctanh(+Inf - i1)) = 1", __real__ result
, 1);
4472 check ("imag(ctanh(+Inf - i1)) = -0", __imag__ result
, minus_zero
);
4473 result
= FUNC(ctanh
) (BUILD_COMPLEX (minus_infty
, 0));
4474 check ("real(ctanh(-Inf + i0)) = -1", __real__ result
, -1);
4475 check ("imag(ctanh(-Inf + i0)) = 0", __imag__ result
, 0);
4476 result
= FUNC(ctanh
) (BUILD_COMPLEX (minus_infty
, 1));
4477 check ("real(ctanh(-Inf + i1)) = -1", __real__ result
, -1);
4478 check ("imag(ctanh(-Inf + i1)) = 0", __imag__ result
, 0);
4479 result
= FUNC(ctanh
) (BUILD_COMPLEX (minus_infty
, minus_zero
));
4480 check ("real(ctanh(-Inf - i0)) = -1", __real__ result
, -1);
4481 check ("imag(ctanh(-Inf - i0)) = -0", __imag__ result
, minus_zero
);
4482 result
= FUNC(ctanh
) (BUILD_COMPLEX (minus_infty
, -1));
4483 check ("real(ctanh(-Inf - i1)) = -1", __real__ result
, -1);
4484 check ("imag(ctanh(-Inf - i1)) = -0", __imag__ result
, minus_zero
);
4486 result
= FUNC(ctanh
) (BUILD_COMPLEX (0, plus_infty
));
4487 check_isnan_exc ("real(ctanh(0 + i Inf)) = NaN plus invalid exception",
4488 __real__ result
, INVALID_EXCEPTION
);
4489 check_isnan ("imag(ctanh(0 + i Inf)) = NaN plus invalid exception",
4491 result
= FUNC(ctanh
) (BUILD_COMPLEX (2, plus_infty
));
4492 check_isnan_exc ("real(ctanh(2 + i Inf)) = NaN plus invalid exception",
4493 __real__ result
, INVALID_EXCEPTION
);
4494 check_isnan ("imag(ctanh(2 + i Inf)) = NaN plus invalid exception",
4496 result
= FUNC(ctanh
) (BUILD_COMPLEX (0, minus_infty
));
4497 check_isnan_exc ("real(ctanh(0 - i Inf)) = NaN plus invalid exception",
4498 __real__ result
, INVALID_EXCEPTION
);
4499 check_isnan ("imag(ctanh(0 - i Inf)) = NaN plus invalid exception",
4501 result
= FUNC(ctanh
) (BUILD_COMPLEX (2, minus_infty
));
4502 check_isnan_exc ("real(ctanh(2 - i Inf)) = NaN plus invalid exception",
4503 __real__ result
, INVALID_EXCEPTION
);
4504 check_isnan ("imag(ctanh(2 - i Inf)) = NaN plus invalid exception",
4506 result
= FUNC(ctanh
) (BUILD_COMPLEX (minus_zero
, plus_infty
));
4507 check_isnan_exc ("real(ctanh(-0 + i Inf)) = NaN plus invalid exception",
4508 __real__ result
, INVALID_EXCEPTION
);
4509 check_isnan ("imag(ctanh(-0 + i Inf)) = NaN plus invalid exception",
4511 result
= FUNC(ctanh
) (BUILD_COMPLEX (-2, plus_infty
));
4512 check_isnan_exc ("real(ctanh(-2 + i Inf)) = NaN plus invalid exception",
4513 __real__ result
, INVALID_EXCEPTION
);
4514 check_isnan ("imag(ctanh(-2 + i Inf)) = NaN plus invalid exception",
4516 result
= FUNC(ctanh
) (BUILD_COMPLEX (minus_zero
, minus_infty
));
4517 check_isnan_exc ("real(ctanh(-0 - i Inf)) = NaN plus invalid exception",
4518 __real__ result
, INVALID_EXCEPTION
);
4519 check_isnan ("imag(ctanh(-0 - i Inf)) = NaN plus invalid exception",
4521 result
= FUNC(ctanh
) (BUILD_COMPLEX (-2, minus_infty
));
4522 check_isnan_exc ("real(ctanh(-2 - i Inf)) = NaN plus invalid exception",
4523 __real__ result
, INVALID_EXCEPTION
);
4524 check_isnan ("imag(ctanh(-2 - i Inf)) = NaN plus invalid exception",
4527 result
= FUNC(ctanh
) (BUILD_COMPLEX (plus_infty
, nan_value
));
4528 check ("real(ctanh(+Inf + i NaN)) = 1", __real__ result
, 1);
4529 check ("imag(ctanh(+Inf + i NaN)) = +-0", FUNC(fabs
) (__imag__ result
), 0);
4530 result
= FUNC(ctanh
) (BUILD_COMPLEX (minus_infty
, nan_value
));
4531 check ("real(ctanh(-Inf + i NaN)) = -1", __real__ result
, -1);
4532 check ("imag(ctanh(-Inf + i NaN)) = +-0", FUNC(fabs
) (__imag__ result
), 0);
4534 result
= FUNC(ctanh
) (BUILD_COMPLEX (nan_value
, 0));
4535 check_isnan ("real(ctanh(NaN + i0)) = NaN", __real__ result
);
4536 check ("imag(ctanh(NaN + i0)) = 0", __imag__ result
, 0);
4537 result
= FUNC(ctanh
) (BUILD_COMPLEX (nan_value
, minus_zero
));
4538 check_isnan ("real(ctanh(NaN - i0)) = NaN", __real__ result
);
4539 check ("imag(ctanh(NaN - i0)) = -0", __imag__ result
, minus_zero
);
4541 result
= FUNC(ctanh
) (BUILD_COMPLEX (nan_value
, 0.5));
4542 check_isnan_maybe_exc ("real(ctanh(NaN + i0.5)) = NaN plus maybe invalid exception",
4543 __real__ result
, INVALID_EXCEPTION
);
4544 check_isnan ("imag(ctanh(NaN + i0.5)) = NaN plus maybe invalid exception",
4546 result
= FUNC(ctanh
) (BUILD_COMPLEX (nan_value
, -4.5));
4547 check_isnan_maybe_exc ("real(ctanh(NaN - i4.5)) = NaN plus maybe invalid exception",
4548 __real__ result
, INVALID_EXCEPTION
);
4549 check_isnan ("imag(ctanh(NaN - i4.5)) = NaN plus maybe invalid exception",
4552 result
= FUNC(ctanh
) (BUILD_COMPLEX (0, nan_value
));
4553 check_isnan_maybe_exc ("real(ctanh(0 + i NaN)) = NaN plus maybe invalid exception",
4554 __real__ result
, INVALID_EXCEPTION
);
4555 check_isnan ("imag(ctanh(0 + i NaN)) = NaN plus maybe invalid exception",
4557 result
= FUNC(ctanh
) (BUILD_COMPLEX (5, nan_value
));
4558 check_isnan_maybe_exc ("real(ctanh(5 + i NaN)) = NaN plus maybe invalid exception",
4559 __real__ result
, INVALID_EXCEPTION
);
4560 check_isnan ("imag(ctanh(5 + i NaN)) = NaN plus maybe invalid exception",
4562 result
= FUNC(ctanh
) (BUILD_COMPLEX (minus_zero
, nan_value
));
4563 check_isnan_maybe_exc ("real(ctanh(-0 + i NaN)) = NaN plus maybe invalid exception",
4564 __real__ result
, INVALID_EXCEPTION
);
4565 check_isnan ("imag(ctanh(-0 + i NaN)) = NaN plus maybe invalid exception",
4567 result
= FUNC(ctanh
) (BUILD_COMPLEX (-0.25, nan_value
));
4568 check_isnan_maybe_exc ("real(ctanh(-0.25 + i NaN)) = NaN plus maybe invalid exception",
4569 __real__ result
, INVALID_EXCEPTION
);
4570 check_isnan ("imag(ctanh(-0.25 + i NaN)) = NaN plus maybe invalid exception",
4573 result
= FUNC(ctanh
) (BUILD_COMPLEX (nan_value
, nan_value
));
4574 check_isnan ("real(ctanh(NaN + i NaN)) = NaN", __real__ result
);
4575 check_isnan ("imag(ctanh(NaN + i NaN)) = NaN", __imag__ result
);
4577 result
= FUNC(ctanh
) (BUILD_COMPLEX (0, M_PI_4
));
4578 check ("real(ctanh (0 + i pi/4)) == 0", __real__ result
, 0);
4579 check_eps ("imag(ctanh (0 + i pi/4)) == 1", __imag__ result
, 1,
4580 CHOOSE (0, 2e-16, 2e-7));
4582 result
= FUNC(ctanh
) (BUILD_COMPLEX (0.7, 1.2));
4583 check_eps ("real(ctanh(0.7 + i 1.2)) == 1.34721...", __real__ result
,
4584 1.3472197399061191630L, CHOOSE(4e-17L, 6e-17, 2e-7));
4585 check_eps ("imag(ctanh(0.7 + i 1.2)) == -0.47786...", __imag__ result
,
4586 0.4778641038326365540L, CHOOSE(9e-17L, 6e-17, 0));
4588 result
= FUNC(ctanh
) (BUILD_COMPLEX (-2, -3));
4589 check_eps ("real(ctanh(-2 - i 3)) == --0.96538...", __real__ result
,
4590 -0.9653858790221331242L, CHOOSE(2e-19L, 0, 0));
4591 check_eps ("imag(ctanh(-2 - i 3)) == -0.00988...", __imag__ result
,
4592 0.0098843750383224937L, CHOOSE(2e-20L, 0, 1e-9));
4599 __complex__ MATHTYPE result
;
4601 result
= FUNC(clog
) (BUILD_COMPLEX (minus_zero
, 0));
4602 check_isinfn_exc ("real(clog(-0 + i0)) = -Inf plus divide-by-zero exception",
4603 __real__ result
, DIVIDE_BY_ZERO_EXCEPTION
);
4604 check ("imag(clog(-0 + i0)) = pi plus divide-by-zero exception",
4605 __imag__ result
, M_PI
);
4606 result
= FUNC(clog
) (BUILD_COMPLEX (minus_zero
, minus_zero
));
4607 check_isinfn_exc ("real(clog(-0 - i0)) = -Inf plus divide-by-zero exception",
4608 __real__ result
, DIVIDE_BY_ZERO_EXCEPTION
);
4609 check ("imag(clog(-0 - i0)) = -pi plus divide-by-zero exception",
4610 __imag__ result
, -M_PI
);
4612 result
= FUNC(clog
) (BUILD_COMPLEX (0, 0));
4613 check_isinfn_exc ("real(clog(0 + i0)) = -Inf plus divide-by-zero exception",
4614 __real__ result
, DIVIDE_BY_ZERO_EXCEPTION
);
4615 check ("imag(clog(0 + i0)) = 0 plus divide-by-zero exception",
4616 __imag__ result
, 0);
4617 result
= FUNC(clog
) (BUILD_COMPLEX (0, minus_zero
));
4618 check_isinfn_exc ("real(clog(0 - i0)) = -Inf plus divide-by-zero exception",
4619 __real__ result
, DIVIDE_BY_ZERO_EXCEPTION
);
4620 check ("imag(clog(0 - i0)) = -0 plus divide-by-zero exception",
4621 __imag__ result
, minus_zero
);
4623 result
= FUNC(clog
) (BUILD_COMPLEX (minus_infty
, plus_infty
));
4624 check_isinfp ("real(clog(-Inf + i Inf)) = +Inf", __real__ result
);
4625 check ("imag(clog(-Inf + i Inf)) = 3*pi/4", __imag__ result
, M_PI
- M_PI_4
);
4626 result
= FUNC(clog
) (BUILD_COMPLEX (minus_infty
, minus_infty
));
4627 check_isinfp ("real(clog(-Inf - i Inf)) = +Inf", __real__ result
);
4628 check ("imag(clog(-Inf - i Inf)) = -3*pi/4", __imag__ result
, M_PI_4
- M_PI
);
4630 result
= FUNC(clog
) (BUILD_COMPLEX (plus_infty
, plus_infty
));
4631 check_isinfp ("real(clog(+Inf + i Inf)) = +Inf", __real__ result
);
4632 check ("imag(clog(+Inf + i Inf)) = pi/4", __imag__ result
, M_PI_4
);
4633 result
= FUNC(clog
) (BUILD_COMPLEX (plus_infty
, minus_infty
));
4634 check_isinfp ("real(clog(+Inf - i Inf)) = +Inf", __real__ result
);
4635 check ("imag(clog(+Inf - i Inf)) = -pi/4", __imag__ result
, -M_PI_4
);
4637 result
= FUNC(clog
) (BUILD_COMPLEX (0, plus_infty
));
4638 check_isinfp ("real(clog(0 + i Inf)) = +Inf", __real__ result
);
4639 check ("imag(clog(0 + i Inf)) = pi/2", __imag__ result
, M_PI_2
);
4640 result
= FUNC(clog
) (BUILD_COMPLEX (3, plus_infty
));
4641 check_isinfp ("real(clog(3 + i Inf)) = +Inf", __real__ result
);
4642 check ("imag(clog(3 + i Inf)) = pi/2", __imag__ result
, M_PI_2
);
4643 result
= FUNC(clog
) (BUILD_COMPLEX (minus_zero
, plus_infty
));
4644 check_isinfp ("real(clog(-0 + i Inf)) = +Inf", __real__ result
);
4645 check ("imag(clog(-0 + i Inf)) = pi/2", __imag__ result
, M_PI_2
);
4646 result
= FUNC(clog
) (BUILD_COMPLEX (-3, plus_infty
));
4647 check_isinfp ("real(clog(-3 + i Inf)) = +Inf", __real__ result
);
4648 check ("imag(clog(-3 + i Inf)) = pi/2", __imag__ result
, M_PI_2
);
4649 result
= FUNC(clog
) (BUILD_COMPLEX (0, minus_infty
));
4650 check_isinfp ("real(clog(0 - i Inf)) = +Inf", __real__ result
);
4651 check ("imag(clog(0 - i Inf)) = -pi/2", __imag__ result
, -M_PI_2
);
4652 result
= FUNC(clog
) (BUILD_COMPLEX (3, minus_infty
));
4653 check_isinfp ("real(clog(3 - i Inf)) = +Inf", __real__ result
);
4654 check ("imag(clog(3 - i Inf)) = -pi/2", __imag__ result
, -M_PI_2
);
4655 result
= FUNC(clog
) (BUILD_COMPLEX (minus_zero
, minus_infty
));
4656 check_isinfp ("real(clog(-0 - i Inf)) = +Inf", __real__ result
);
4657 check ("imag(clog(-0 - i Inf)) = -pi/2", __imag__ result
, -M_PI_2
);
4658 result
= FUNC(clog
) (BUILD_COMPLEX (-3, minus_infty
));
4659 check_isinfp ("real(clog(-3 - i Inf)) = +Inf", __real__ result
);
4660 check ("imag(clog(-3 - i Inf)) = -pi/2", __imag__ result
, -M_PI_2
);
4662 result
= FUNC(clog
) (BUILD_COMPLEX (minus_infty
, 0));
4663 check_isinfp ("real(clog(-Inf + i0)) = +Inf", __real__ result
);
4664 check ("imag(clog(-Inf + i0)) = pi", __imag__ result
, M_PI
);
4665 result
= FUNC(clog
) (BUILD_COMPLEX (minus_infty
, 1));
4666 check_isinfp ("real(clog(-Inf + i1)) = +Inf", __real__ result
);
4667 check ("imag(clog(-Inf + i1)) = pi", __imag__ result
, M_PI
);
4668 result
= FUNC(clog
) (BUILD_COMPLEX (minus_infty
, minus_zero
));
4669 check_isinfp ("real(clog(-Inf - i0)) = +Inf", __real__ result
);
4670 check ("imag(clog(-Inf - i0)) = -pi", __imag__ result
, -M_PI
);
4671 result
= FUNC(clog
) (BUILD_COMPLEX (minus_infty
, -1));
4672 check_isinfp ("real(clog(-Inf - i1)) = +Inf", __real__ result
);
4673 check ("imag(clog(-Inf - i1)) = -pi", __imag__ result
, -M_PI
);
4675 result
= FUNC(clog
) (BUILD_COMPLEX (plus_infty
, 0));
4676 check_isinfp ("real(clog(+Inf + i0)) = +Inf", __real__ result
);
4677 check ("imag(clog(+Inf + i0)) = 0", __imag__ result
, 0);
4678 result
= FUNC(clog
) (BUILD_COMPLEX (plus_infty
, 1));
4679 check_isinfp ("real(clog(+Inf + i1)) = +Inf", __real__ result
);
4680 check ("imag(clog(+Inf + i1)) = 0", __imag__ result
, 0);
4681 result
= FUNC(clog
) (BUILD_COMPLEX (plus_infty
, minus_zero
));
4682 check_isinfp ("real(clog(+Inf - i0)) = +Inf", __real__ result
);
4683 check ("imag(clog(+Inf - i0)) = -0", __imag__ result
, minus_zero
);
4684 result
= FUNC(clog
) (BUILD_COMPLEX (plus_infty
, -1));
4685 check_isinfp ("real(clog(+Inf - i1)) = +Inf", __real__ result
);
4686 check ("imag(clog(+Inf - i1)) = -0", __imag__ result
, minus_zero
);
4688 result
= FUNC(clog
) (BUILD_COMPLEX (plus_infty
, nan_value
));
4689 check_isinfp ("real(clog(+Inf + i NaN)) = +Inf", __real__ result
);
4690 check_isnan ("imag(clog(+Inf + i NaN)) = NaN", __imag__ result
);
4691 result
= FUNC(clog
) (BUILD_COMPLEX (minus_infty
, nan_value
));
4692 check_isinfp ("real(clog(-Inf + i NaN)) = +Inf", __real__ result
);
4693 check_isnan ("imag(clog(-Inf + i NaN)) = NaN", __imag__ result
);
4695 result
= FUNC(clog
) (BUILD_COMPLEX (nan_value
, plus_infty
));
4696 check_isinfp ("real(clog(NaN + i Inf)) = +Inf", __real__ result
);
4697 check_isnan ("imag(clog(NaN + i Inf)) = NaN", __imag__ result
);
4698 result
= FUNC(clog
) (BUILD_COMPLEX (nan_value
, minus_infty
));
4699 check_isinfp ("real(clog(NaN - i Inf)) = +Inf", __real__ result
);
4700 check_isnan ("imag(clog(NaN - i Inf)) = NaN", __imag__ result
);
4702 result
= FUNC(clog
) (BUILD_COMPLEX (0, nan_value
));
4703 check_isnan_maybe_exc ("real(clog(0 + i NaN)) = NaN plus maybe invalid exception",
4704 __real__ result
, INVALID_EXCEPTION
);
4705 check_isnan ("imag(clog(0 + i NaN)) = NaN plus maybe invalid exception",
4707 result
= FUNC(clog
) (BUILD_COMPLEX (3, nan_value
));
4708 check_isnan_maybe_exc ("real(clog(3 + i NaN)) = NaN plus maybe invalid exception",
4709 __real__ result
, INVALID_EXCEPTION
);
4710 check_isnan ("imag(clog(3 + i NaN)) = NaN plus maybe invalid exception",
4712 result
= FUNC(clog
) (BUILD_COMPLEX (minus_zero
, nan_value
));
4713 check_isnan_maybe_exc ("real(clog(-0 + i NaN)) = NaN plus maybe invalid exception",
4714 __real__ result
, INVALID_EXCEPTION
);
4715 check_isnan ("imag(clog(-0 + i NaN)) = NaN plus maybe invalid exception",
4717 result
= FUNC(clog
) (BUILD_COMPLEX (-3, nan_value
));
4718 check_isnan_maybe_exc ("real(clog(-3 + i NaN)) = NaN plus maybe invalid exception",
4719 __real__ result
, INVALID_EXCEPTION
);
4720 check_isnan ("imag(clog(-3 + i NaN)) = NaN plus maybe invalid exception",
4723 result
= FUNC(clog
) (BUILD_COMPLEX (nan_value
, 0));
4724 check_isnan_maybe_exc ("real(clog(NaN + i0)) = NaN plus maybe invalid exception",
4725 __real__ result
, INVALID_EXCEPTION
);
4726 check_isnan ("imag(clog(NaN + i0)) = NaN plus maybe invalid exception",
4728 result
= FUNC(clog
) (BUILD_COMPLEX (nan_value
, 5));
4729 check_isnan_maybe_exc ("real(clog(NaN + i5)) = NaN plus maybe invalid exception",
4730 __real__ result
, INVALID_EXCEPTION
);
4731 check_isnan ("imag(clog(NaN + i5)) = NaN plus maybe invalid exception",
4733 result
= FUNC(clog
) (BUILD_COMPLEX (nan_value
, minus_zero
));
4734 check_isnan_maybe_exc ("real(clog(NaN - i0)) = NaN plus maybe invalid exception",
4735 __real__ result
, INVALID_EXCEPTION
);
4736 check_isnan ("imag(clog(NaN - i0)) = NaN plus maybe invalid exception",
4738 result
= FUNC(clog
) (BUILD_COMPLEX (nan_value
, -5));
4739 check_isnan_maybe_exc ("real(clog(NaN - i5)) = NaN plus maybe invalid exception",
4740 __real__ result
, INVALID_EXCEPTION
);
4741 check_isnan ("imag(clog(NaN - i5)) = NaN plus maybe invalid exception",
4744 result
= FUNC(clog
) (BUILD_COMPLEX (nan_value
, nan_value
));
4745 check_isnan ("real(clog(NaN + i NaN)) = NaN", __real__ result
);
4746 check_isnan ("imag(clog(NaN + i NaN)) = NaN", __imag__ result
);
4748 result
= FUNC(clog
) (BUILD_COMPLEX (0.7, 1.2));
4749 check_eps ("real(clog(0.7 + i 1.2)) == 0.32876...", __real__ result
,
4750 0.3287600014583970919L, CHOOSE(5e-17L, 6e-17, 3e-8));
4751 check_eps ("imag(clog(0.7 + i 1.2)) == 1.04272...", __imag__ result
,
4752 1.0427218783685369524L, CHOOSE(2e-17L, 0, 0));
4754 result
= FUNC(clog
) (BUILD_COMPLEX (-2, -3));
4755 check ("real(clog(-2 - i 3)) == -1.28247...", __real__ result
,
4756 1.2824746787307683680L);
4757 check_eps ("imag(clog(-2 - i 3)) == -2.15879...", __imag__ result
,
4758 -2.1587989303424641704L, CHOOSE(3e-19L, 0, 0));
4765 __complex__ MATHTYPE result
;
4767 result
= FUNC(clog10
) (BUILD_COMPLEX (minus_zero
, 0));
4768 check_isinfn_exc ("real(clog10(-0 + i0)) = -Inf plus divide-by-zero exception",
4769 __real__ result
, DIVIDE_BY_ZERO_EXCEPTION
);
4770 check ("imag(clog10(-0 + i0)) = pi plus divide-by-zero exception",
4771 __imag__ result
, M_PI
);
4772 result
= FUNC(clog10
) (BUILD_COMPLEX (minus_zero
, minus_zero
));
4773 check_isinfn_exc ("real(clog10(-0 - i0)) = -Inf plus divide-by-zero exception",
4774 __real__ result
, DIVIDE_BY_ZERO_EXCEPTION
);
4775 check ("imag(clog10(-0 - i0)) = -pi plus divide-by-zero exception",
4776 __imag__ result
, -M_PI
);
4778 result
= FUNC(clog10
) (BUILD_COMPLEX (0, 0));
4779 check_isinfn_exc ("real(clog10(0 + i0)) = -Inf plus divide-by-zero exception",
4780 __real__ result
, DIVIDE_BY_ZERO_EXCEPTION
);
4781 check ("imag(clog10(0 + i0)) = 0 plus divide-by-zero exception",
4782 __imag__ result
, 0);
4783 result
= FUNC(clog10
) (BUILD_COMPLEX (0, minus_zero
));
4784 check_isinfn_exc ("real(clog10(0 - i0)) = -Inf plus divide-by-zero exception",
4785 __real__ result
, DIVIDE_BY_ZERO_EXCEPTION
);
4786 check ("imag(clog10(0 - i0)) = -0 plus divide-by-zero exception",
4787 __imag__ result
, minus_zero
);
4789 result
= FUNC(clog10
) (BUILD_COMPLEX (minus_infty
, plus_infty
));
4790 check_isinfp ("real(clog10(-Inf + i Inf)) = +Inf", __real__ result
);
4791 check_eps ("imag(clog10(-Inf + i Inf)) = 3*pi/4*M_LOG10E", __imag__ result
,
4792 (M_PI
- M_PI_4
) * M_LOG10E
, CHOOSE (0, 3e-16, 0));
4793 result
= FUNC(clog10
) (BUILD_COMPLEX (minus_infty
, minus_infty
));
4794 check_isinfp ("real(clog10(-Inf - i Inf)) = +Inf", __real__ result
);
4795 check_eps ("imag(clog10(-Inf - i Inf)) = -3*pi/4*M_LOG10E", __imag__ result
,
4796 (M_PI_4
- M_PI
) * M_LOG10E
, CHOOSE (0, 3e-16, 0));
4798 result
= FUNC(clog10
) (BUILD_COMPLEX (plus_infty
, plus_infty
));
4799 check_isinfp ("real(clog10(+Inf + i Inf)) = +Inf", __real__ result
);
4800 check_eps ("imag(clog10(+Inf + i Inf)) = pi/4*M_LOG10E", __imag__ result
,
4801 M_PI_4
* M_LOG10E
, CHOOSE (0, 6e-17, 3e-8));
4802 result
= FUNC(clog10
) (BUILD_COMPLEX (plus_infty
, minus_infty
));
4803 check_isinfp ("real(clog10(+Inf - i Inf)) = +Inf", __real__ result
);
4804 check_eps ("imag(clog10(+Inf - i Inf)) = -pi/4*M_LOG10E", __imag__ result
,
4805 -M_PI_4
* M_LOG10E
, CHOOSE (0, 6e-17, 3e-8));
4807 result
= FUNC(clog10
) (BUILD_COMPLEX (0, plus_infty
));
4808 check_isinfp ("real(clog10(0 + i Inf)) = +Inf", __real__ result
);
4809 check_eps ("imag(clog10(0 + i Inf)) = pi/2*M_LOG10E", __imag__ result
,
4810 M_PI_2
* M_LOG10E
, CHOOSE (0, 2e-16, 6e-8));
4811 result
= FUNC(clog10
) (BUILD_COMPLEX (3, plus_infty
));
4812 check_isinfp ("real(clog10(3 + i Inf)) = +Inf", __real__ result
);
4813 check_eps ("imag(clog10(3 + i Inf)) = pi/2*M_LOG10E", __imag__ result
,
4814 M_PI_2
* M_LOG10E
, CHOOSE (0, 2e-16, 6e-8));
4815 result
= FUNC(clog10
) (BUILD_COMPLEX (minus_zero
, plus_infty
));
4816 check_isinfp ("real(clog10(-0 + i Inf)) = +Inf", __real__ result
);
4817 check_eps ("imag(clog10(-0 + i Inf)) = pi/2*M_LOG10E", __imag__ result
,
4818 M_PI_2
* M_LOG10E
, CHOOSE (0, 2e-16, 6e-8));
4819 result
= FUNC(clog10
) (BUILD_COMPLEX (-3, plus_infty
));
4820 check_isinfp ("real(clog10(-3 + i Inf)) = +Inf", __real__ result
);
4821 check_eps ("imag(clog10(-3 + i Inf)) = pi/2*M_LOG10E", __imag__ result
,
4822 M_PI_2
* M_LOG10E
, CHOOSE (0, 2e-16, 6e-8));
4823 result
= FUNC(clog10
) (BUILD_COMPLEX (0, minus_infty
));
4824 check_isinfp ("real(clog10(0 - i Inf)) = +Inf", __real__ result
);
4825 check_eps ("imag(clog10(0 - i Inf)) = -pi/2*M_LOG10E", __imag__ result
,
4826 -M_PI_2
*M_LOG10E
, CHOOSE (0, 2e-16, 6e-8));
4827 result
= FUNC(clog10
) (BUILD_COMPLEX (3, minus_infty
));
4828 check_isinfp ("real(clog10(3 - i Inf)) = +Inf", __real__ result
);
4829 check_eps ("imag(clog10(3 - i Inf)) = -pi/2*M_LOG10E", __imag__ result
,
4830 -M_PI_2
*M_LOG10E
, CHOOSE (0, 2e-16, 6e-8));
4831 result
= FUNC(clog10
) (BUILD_COMPLEX (minus_zero
, minus_infty
));
4832 check_isinfp ("real(clog10(-0 - i Inf)) = +Inf", __real__ result
);
4833 check_eps ("imag(clog10(-0 - i Inf)) = -pi/2*M_LOG10E", __imag__ result
,
4834 -M_PI_2
* M_LOG10E
, CHOOSE (0, 2e-16, 6e-8));
4835 result
= FUNC(clog10
) (BUILD_COMPLEX (-3, minus_infty
));
4836 check_isinfp ("real(clog10(-3 - i Inf)) = +Inf", __real__ result
);
4837 check_eps ("imag(clog10(-3 - i Inf)) = -pi/2*M_LOG10E", __imag__ result
,
4838 -M_PI_2
* M_LOG10E
, CHOOSE (0, 2e-16, 6e-8));
4840 result
= FUNC(clog10
) (BUILD_COMPLEX (minus_infty
, 0));
4841 check_isinfp ("real(clog10(-Inf + i0)) = +Inf", __real__ result
);
4842 check_eps ("imag(clog10(-Inf + i0)) = pi*M_LOG10E", __imag__ result
,
4843 M_PI
* M_LOG10E
, CHOOSE (0, 3e-16, 2e-7));
4844 result
= FUNC(clog10
) (BUILD_COMPLEX (minus_infty
, 1));
4845 check_isinfp ("real(clog10(-Inf + i1)) = +Inf", __real__ result
);
4846 check_eps ("imag(clog10(-Inf + i1)) = pi*M_LOG10E", __imag__ result
,
4847 M_PI
* M_LOG10E
, CHOOSE (0, 3e-16, 2e-7));
4848 result
= FUNC(clog10
) (BUILD_COMPLEX (minus_infty
, minus_zero
));
4849 check_isinfp ("real(clog10(-Inf - i0)) = +Inf", __real__ result
);
4850 check_eps ("imag(clog10(-Inf - i0)) = -pi*M_LOG10E", __imag__ result
,
4851 -M_PI
* M_LOG10E
, CHOOSE (0, 3e-16, 2e-7));
4852 result
= FUNC(clog10
) (BUILD_COMPLEX (minus_infty
, -1));
4853 check_isinfp ("real(clog10(-Inf - i1)) = +Inf", __real__ result
);
4854 check_eps ("imag(clog10(-Inf - i1)) = -pi*M_LOG10E", __imag__ result
,
4855 -M_PI
* M_LOG10E
, CHOOSE (0, 3e-16, 2e-7));
4857 result
= FUNC(clog10
) (BUILD_COMPLEX (plus_infty
, 0));
4858 check_isinfp ("real(clog10(+Inf + i0)) = +Inf", __real__ result
);
4859 check ("imag(clog10(+Inf + i0)) = 0", __imag__ result
, 0);
4860 result
= FUNC(clog10
) (BUILD_COMPLEX (plus_infty
, 1));
4861 check_isinfp ("real(clog10(+Inf + i1)) = +Inf", __real__ result
);
4862 check ("imag(clog10(+Inf + i1)) = 0", __imag__ result
, 0);
4863 result
= FUNC(clog10
) (BUILD_COMPLEX (plus_infty
, minus_zero
));
4864 check_isinfp ("real(clog10(+Inf - i0)) = +Inf", __real__ result
);
4865 check ("imag(clog10(+Inf - i0)) = -0", __imag__ result
, minus_zero
);
4866 result
= FUNC(clog10
) (BUILD_COMPLEX (plus_infty
, -1));
4867 check_isinfp ("real(clog10(+Inf - i1)) = +Inf", __real__ result
);
4868 check ("imag(clog10(+Inf - i1)) = -0", __imag__ result
, minus_zero
);
4870 result
= FUNC(clog10
) (BUILD_COMPLEX (plus_infty
, nan_value
));
4871 check_isinfp ("real(clog10(+Inf + i NaN)) = +Inf", __real__ result
);
4872 check_isnan ("imag(clog10(+Inf + i NaN)) = NaN", __imag__ result
);
4873 result
= FUNC(clog10
) (BUILD_COMPLEX (minus_infty
, nan_value
));
4874 check_isinfp ("real(clog10(-Inf + i NaN)) = +Inf", __real__ result
);
4875 check_isnan ("imag(clog10(-Inf + i NaN)) = NaN", __imag__ result
);
4877 result
= FUNC(clog10
) (BUILD_COMPLEX (nan_value
, plus_infty
));
4878 check_isinfp ("real(clog10(NaN + i Inf)) = +Inf", __real__ result
);
4879 check_isnan ("imag(clog10(NaN + i Inf)) = NaN", __imag__ result
);
4880 result
= FUNC(clog10
) (BUILD_COMPLEX (nan_value
, minus_infty
));
4881 check_isinfp ("real(clog10(NaN - i Inf)) = +Inf", __real__ result
);
4882 check_isnan ("imag(clog10(NaN - i Inf)) = NaN", __imag__ result
);
4884 result
= FUNC(clog10
) (BUILD_COMPLEX (0, nan_value
));
4885 check_isnan_maybe_exc ("real(clog10(0 + i NaN)) = NaN plus maybe invalid exception",
4886 __real__ result
, INVALID_EXCEPTION
);
4887 check_isnan ("imag(clog10(0 + i NaN)) = NaN plus maybe invalid exception",
4889 result
= FUNC(clog10
) (BUILD_COMPLEX (3, nan_value
));
4890 check_isnan_maybe_exc ("real(clog10(3 + i NaN)) = NaN plus maybe invalid exception",
4891 __real__ result
, INVALID_EXCEPTION
);
4892 check_isnan ("imag(clog10(3 + i NaN)) = NaN plus maybe invalid exception",
4894 result
= FUNC(clog10
) (BUILD_COMPLEX (minus_zero
, nan_value
));
4895 check_isnan_maybe_exc ("real(clog10(-0 + i NaN)) = NaN plus maybe invalid exception",
4896 __real__ result
, INVALID_EXCEPTION
);
4897 check_isnan ("imag(clog10(-0 + i NaN)) = NaN plus maybe invalid exception",
4899 result
= FUNC(clog10
) (BUILD_COMPLEX (-3, nan_value
));
4900 check_isnan_maybe_exc ("real(clog10(-3 + i NaN)) = NaN plus maybe invalid exception",
4901 __real__ result
, INVALID_EXCEPTION
);
4902 check_isnan ("imag(clog10(-3 + i NaN)) = NaN plus maybe invalid exception",
4905 result
= FUNC(clog10
) (BUILD_COMPLEX (nan_value
, 0));
4906 check_isnan_maybe_exc ("real(clog10(NaN + i0)) = NaN plus maybe invalid exception",
4907 __real__ result
, INVALID_EXCEPTION
);
4908 check_isnan ("imag(clog10(NaN + i0)) = NaN plus maybe invalid exception",
4910 result
= FUNC(clog10
) (BUILD_COMPLEX (nan_value
, 5));
4911 check_isnan_maybe_exc ("real(clog10(NaN + i5)) = NaN plus maybe invalid exception",
4912 __real__ result
, INVALID_EXCEPTION
);
4913 check_isnan ("imag(clog10(NaN + i5)) = NaN plus maybe invalid exception",
4915 result
= FUNC(clog10
) (BUILD_COMPLEX (nan_value
, minus_zero
));
4916 check_isnan_maybe_exc ("real(clog10(NaN - i0)) = NaN plus maybe invalid exception",
4917 __real__ result
, INVALID_EXCEPTION
);
4918 check_isnan ("imag(clog10(NaN - i0)) = NaN plus maybe invalid exception",
4920 result
= FUNC(clog10
) (BUILD_COMPLEX (nan_value
, -5));
4921 check_isnan_maybe_exc ("real(clog10(NaN - i5)) = NaN plus maybe invalid exception",
4922 __real__ result
, INVALID_EXCEPTION
);
4923 check_isnan ("imag(clog10(NaN - i5)) = NaN plus maybe invalid exception",
4926 result
= FUNC(clog10
) (BUILD_COMPLEX (nan_value
, nan_value
));
4927 check_isnan ("real(clog10(NaN + i NaN)) = NaN", __real__ result
);
4928 check_isnan ("imag(clog10(NaN + i NaN)) = NaN", __imag__ result
);
4930 result
= FUNC(clog10
) (BUILD_COMPLEX (0.7, 1.2));
4931 check_eps ("real(clog10(0.7 + i 1.2)) == 0.14277...", __real__ result
,
4932 0.1427786545038868803L, CHOOSE(2e-17L, 6e-17, 2e-8));
4933 check_eps ("imag(clog10(0.7 + i 1.2)) == 0.45284...", __imag__ result
,
4934 0.4528483579352493248L, CHOOSE(6e-18, 6e-17, 3e-8));
4936 result
= FUNC(clog10
) (BUILD_COMPLEX (-2, -3));
4937 check ("real(clog10(-2 - i 3)) == -0.55697...", __real__ result
,
4938 0.5569716761534183846L);
4939 check_eps ("imag(clog10(-2 - i 3)) == -0.93755...", __imag__ result
,
4940 -0.9375544629863747085L, CHOOSE (6e-20, 2e-16, 0));
4947 __complex__ MATHTYPE result
;
4949 result
= FUNC(csqrt
) (BUILD_COMPLEX (0, 0));
4950 check ("real(csqrt(0 + i0)) = 0", __real__ result
, 0);
4951 check ("imag(csqrt(0 + i0)) = 0", __imag__ result
, 0);
4952 result
= FUNC(csqrt
) (BUILD_COMPLEX (0, minus_zero
));
4953 check ("real(csqrt(0 - i0)) = 0", __real__ result
, 0);
4954 check ("imag(csqrt(0 - i0)) = -0", __imag__ result
, minus_zero
);
4955 result
= FUNC(csqrt
) (BUILD_COMPLEX (minus_zero
, 0));
4956 check ("real(csqrt(-0 + i0)) = 0", __real__ result
, 0);
4957 check ("imag(csqrt(-0 + i0)) = 0", __imag__ result
, 0);
4958 result
= FUNC(csqrt
) (BUILD_COMPLEX (minus_zero
, minus_zero
));
4959 check ("real(csqrt(-0 - i0)) = 0", __real__ result
, 0);
4960 check ("imag(csqrt(-0 - i0)) = -0", __imag__ result
, minus_zero
);
4962 result
= FUNC(csqrt
) (BUILD_COMPLEX (minus_infty
, 0));
4963 check ("real(csqrt(-Inf + i0)) = 0", __real__ result
, 0);
4964 check_isinfp ("imag(csqrt(-Inf + i0)) = +Inf", __imag__ result
);
4965 result
= FUNC(csqrt
) (BUILD_COMPLEX (minus_infty
, 6));
4966 check ("real(csqrt(-Inf + i6)) = 0", __real__ result
, 0);
4967 check_isinfp ("imag(csqrt(-Inf + i6)) = +Inf", __imag__ result
);
4968 result
= FUNC(csqrt
) (BUILD_COMPLEX (minus_infty
, minus_zero
));
4969 check ("real(csqrt(-Inf - i0)) = 0", __real__ result
, 0);
4970 check_isinfn ("imag(csqrt(-Inf - i0)) = -Inf", __imag__ result
);
4971 result
= FUNC(csqrt
) (BUILD_COMPLEX (minus_infty
, -6));
4972 check ("real(csqrt(-Inf - i6)) = 0", __real__ result
, 0);
4973 check_isinfn ("imag(csqrt(-Inf - i6)) = -Inf", __imag__ result
);
4975 result
= FUNC(csqrt
) (BUILD_COMPLEX (plus_infty
, 0));
4976 check_isinfp ("real(csqrt(+Inf + i0)) = +Inf", __real__ result
);
4977 check ("imag(csqrt(+Inf + i0)) = 0", __imag__ result
, 0);
4978 result
= FUNC(csqrt
) (BUILD_COMPLEX (plus_infty
, 6));
4979 check_isinfp ("real(csqrt(+Inf + i6)) = +Inf", __real__ result
);
4980 check ("imag(csqrt(+Inf + i6)) = 0", __imag__ result
, 0);
4981 result
= FUNC(csqrt
) (BUILD_COMPLEX (plus_infty
, minus_zero
));
4982 check_isinfp ("real(csqrt(+Inf - i0)) = +Inf", __real__ result
);
4983 check ("imag(csqrt(+Inf - i0)) = -0", __imag__ result
, minus_zero
);
4984 result
= FUNC(csqrt
) (BUILD_COMPLEX (plus_infty
, -6));
4985 check_isinfp ("real(csqrt(+Inf - i6)) = +Inf", __real__ result
);
4986 check ("imag(csqrt(+Inf - i6)) = -0", __imag__ result
, minus_zero
);
4988 result
= FUNC(csqrt
) (BUILD_COMPLEX (0, plus_infty
));
4989 check_isinfp ("real(csqrt(0 + i Inf)) = +Inf", __real__ result
);
4990 check_isinfp ("imag(csqrt(0 + i Inf)) = +Inf", __imag__ result
);
4991 result
= FUNC(csqrt
) (BUILD_COMPLEX (4, plus_infty
));
4992 check_isinfp ("real(csqrt(4 + i Inf)) = +Inf", __real__ result
);
4993 check_isinfp ("imag(csqrt(4 + i Inf)) = +Inf", __imag__ result
);
4994 result
= FUNC(csqrt
) (BUILD_COMPLEX (plus_infty
, plus_infty
));
4995 check_isinfp ("real(csqrt(+Inf + i Inf)) = +Inf", __real__ result
);
4996 check_isinfp ("imag(csqrt(+Inf + i Inf)) = +Inf", __imag__ result
);
4997 result
= FUNC(csqrt
) (BUILD_COMPLEX (minus_zero
, plus_infty
));
4998 check_isinfp ("real(csqrt(-0 + i Inf)) = +Inf", __real__ result
);
4999 check_isinfp ("imag(csqrt(-0 + i Inf)) = +Inf", __imag__ result
);
5000 result
= FUNC(csqrt
) (BUILD_COMPLEX (-4, plus_infty
));
5001 check_isinfp ("real(csqrt(-4 + i Inf)) = +Inf", __real__ result
);
5002 check_isinfp ("imag(csqrt(-4 + i Inf)) = +Inf", __imag__ result
);
5003 result
= FUNC(csqrt
) (BUILD_COMPLEX (minus_infty
, plus_infty
));
5004 check_isinfp ("real(csqrt(-Inf + i Inf)) = +Inf", __real__ result
);
5005 check_isinfp ("imag(csqrt(-Inf + i Inf)) = +Inf", __imag__ result
);
5006 result
= FUNC(csqrt
) (BUILD_COMPLEX (0, minus_infty
));
5007 check_isinfp ("real(csqrt(0 - i Inf)) = +Inf", __real__ result
);
5008 check_isinfn ("imag(csqrt(0 - i Inf)) = -Inf", __imag__ result
);
5009 result
= FUNC(csqrt
) (BUILD_COMPLEX (4, minus_infty
));
5010 check_isinfp ("real(csqrt(4 - i Inf)) = +Inf", __real__ result
);
5011 check_isinfn ("imag(csqrt(4 - i Inf)) = -Inf", __imag__ result
);
5012 result
= FUNC(csqrt
) (BUILD_COMPLEX (plus_infty
, minus_infty
));
5013 check_isinfp ("real(csqrt(+Inf - i Inf)) = +Inf", __real__ result
);
5014 check_isinfn ("imag(csqrt(+Inf - i Inf)) = -Inf", __imag__ result
);
5015 result
= FUNC(csqrt
) (BUILD_COMPLEX (minus_zero
, minus_infty
));
5016 check_isinfp ("real(csqrt(-0 - i Inf)) = +Inf", __real__ result
);
5017 check_isinfn ("imag(csqrt(-0 - i Inf)) = -Inf", __imag__ result
);
5018 result
= FUNC(csqrt
) (BUILD_COMPLEX (-4, minus_infty
));
5019 check_isinfp ("real(csqrt(-4 - i Inf)) = +Inf", __real__ result
);
5020 check_isinfn ("imag(csqrt(-4 - i Inf)) = -Inf", __imag__ result
);
5021 result
= FUNC(csqrt
) (BUILD_COMPLEX (minus_infty
, minus_infty
));
5022 check_isinfp ("real(csqrt(-Inf - i Inf)) = +Inf", __real__ result
);
5023 check_isinfn ("imag(csqrt(-Inf - i Inf)) = -Inf", __imag__ result
);
5025 result
= FUNC(csqrt
) (BUILD_COMPLEX (minus_infty
, nan_value
));
5026 check_isnan ("real(csqrt(-Inf + i NaN)) = NaN", __real__ result
);
5027 check_isinfp ("imag(csqrt(-Inf + i NaN)) = +-Inf",
5028 FUNC(fabs
) (__imag__ result
));
5030 result
= FUNC(csqrt
) (BUILD_COMPLEX (plus_infty
, nan_value
));
5031 check_isinfp ("real(csqrt(+Inf + i NaN)) = +Inf", __real__ result
);
5032 check_isnan ("imag(csqrt(+Inf + i NaN)) = NaN", __imag__ result
);
5034 result
= FUNC(csqrt
) (BUILD_COMPLEX (0, nan_value
));
5035 check_isnan_maybe_exc ("real(csqrt(0 + i NaN)) = NaN plus maybe invalid exception",
5036 __real__ result
, INVALID_EXCEPTION
);
5037 check_isnan ("imag(csqrt(0 + i NaN)) = NaN plus maybe invalid exception",
5039 result
= FUNC(csqrt
) (BUILD_COMPLEX (1, nan_value
));
5040 check_isnan_maybe_exc ("real(csqrt(1 + i NaN)) = NaN plus maybe invalid exception",
5041 __real__ result
, INVALID_EXCEPTION
);
5042 check_isnan ("imag(csqrt(1 + i NaN)) = NaN plus maybe invalid exception",
5044 result
= FUNC(csqrt
) (BUILD_COMPLEX (minus_zero
, nan_value
));
5045 check_isnan_maybe_exc ("real(csqrt(-0 + i NaN)) = NaN plus maybe invalid exception",
5046 __real__ result
, INVALID_EXCEPTION
);
5047 check_isnan ("imag(csqrt(-0 + i NaN)) = NaN plus maybe invalid exception",
5049 result
= FUNC(csqrt
) (BUILD_COMPLEX (-1, nan_value
));
5050 check_isnan_maybe_exc ("real(csqrt(-1 + i NaN)) = NaN plus maybe invalid exception",
5051 __real__ result
, INVALID_EXCEPTION
);
5052 check_isnan ("imag(csqrt(-1 + i NaN)) = NaN plus maybe invalid exception",
5055 result
= FUNC(csqrt
) (BUILD_COMPLEX (nan_value
, 0));
5056 check_isnan_maybe_exc ("real(csqrt(NaN + i0)) = NaN plus maybe invalid exception",
5057 __real__ result
, INVALID_EXCEPTION
);
5058 check_isnan ("imag(csqrt(NaN + i0)) = NaN plus maybe invalid exception",
5060 result
= FUNC(csqrt
) (BUILD_COMPLEX (nan_value
, 8));
5061 check_isnan_maybe_exc ("real(csqrt(NaN + i8)) = NaN plus maybe invalid exception",
5062 __real__ result
, INVALID_EXCEPTION
);
5063 check_isnan ("imag(csqrt(NaN + i8)) = NaN plus maybe invalid exception",
5065 result
= FUNC(csqrt
) (BUILD_COMPLEX (nan_value
, minus_zero
));
5066 check_isnan_maybe_exc ("real(csqrt(NaN - i0)) = NaN plus maybe invalid exception",
5067 __real__ result
, INVALID_EXCEPTION
);
5068 check_isnan ("imag(csqrt(NaN - i0)) = NaN plus maybe invalid exception",
5070 result
= FUNC(csqrt
) (BUILD_COMPLEX (nan_value
, -8));
5071 check_isnan_maybe_exc ("real(csqrt(NaN - i8)) = NaN plus maybe invalid exception",
5072 __real__ result
, INVALID_EXCEPTION
);
5073 check_isnan ("imag(csqrt(NaN - i8)) = NaN plus maybe invalid exception",
5076 result
= FUNC(csqrt
) (BUILD_COMPLEX (nan_value
, nan_value
));
5077 check_isnan ("real(csqrt(NaN + i NaN)) = NaN", __real__ result
);
5078 check_isnan ("imag(csqrt(NaN + i NaN)) = NaN", __imag__ result
);
5080 result
= FUNC(csqrt
) (BUILD_COMPLEX (16.0, -30.0));
5081 check ("real(csqrt(16 - 30i)) = 5", __real__ result
, 5.0);
5082 check ("imag(csqrt(16 - 30i)) = -3", __imag__ result
, -3.0);
5084 result
= FUNC(csqrt
) (BUILD_COMPLEX (-1, 0));
5085 check ("real(csqrt(1 + i0) = 0", __real__ result
, 0);
5086 check ("imag(csqrt(1 + i0) = 1", __imag__ result
, 1);
5088 result
= FUNC(csqrt
) (BUILD_COMPLEX (0, 2));
5089 check ("real(csqrt(0 + i 2) = 1", __real__ result
, 1);
5090 check ("imag(csqrt(0 + i 2) = 1", __imag__ result
, 1);
5092 result
= FUNC(csqrt
) (BUILD_COMPLEX (119, 120));
5093 check ("real(csqrt(119 + i 120) = 12", __real__ result
, 12);
5094 check ("imag(csqrt(119 + i 120) = 5", __imag__ result
, 5);
5096 result
= FUNC(csqrt
) (BUILD_COMPLEX (0.7, 1.2));
5097 check_eps ("real(csqrt(0.7 + i 1.2)) == 1.02206...", __real__ result
,
5098 1.0220676100300264507L, CHOOSE(3e-17L, 3e-16, 2e-7));
5099 check_eps ("imag(csqrt(0.7 + i 1.2)) == 0.58704...", __imag__ result
,
5100 0.5870453129635652115L, CHOOSE(7e-18L, 0, 0));
5102 result
= FUNC(csqrt
) (BUILD_COMPLEX (-2, -3));
5103 check_eps ("real(csqrt(-2 - i 3)) == -0.89597...", __real__ result
,
5104 0.8959774761298381247L, CHOOSE(6e-20L, 2e-16, 6e-8));
5105 check ("imag(csqrt(-2 - i 3)) == -1.67414...", __imag__ result
,
5106 -1.6741492280355400404L);
5113 __complex__ MATHTYPE result
;
5115 result
= FUNC (cpow
) (BUILD_COMPLEX (1, 0), BUILD_COMPLEX (0, 0));
5116 check ("real(cpow (1 + i0), (0 + i0)) == 0", __real__ result
, 1);
5117 check ("imag(cpow (1 + i0), (0 + i0)) == 0", __imag__ result
, 0);
5119 result
= FUNC (cpow
) (BUILD_COMPLEX (2, 0), BUILD_COMPLEX (10, 0));
5120 check_eps ("real(cpow (2 + i0), (10 + i0)) == 1024", __real__ result
, 1024,
5121 CHOOSE (2e-16L, 0, 0));
5122 check ("imag(cpow (2 + i0), (10 + i0)) == 0", __imag__ result
, 0);
5124 result
= FUNC (cpow
) (BUILD_COMPLEX (M_E
, 0), BUILD_COMPLEX (0, 2*M_PI
));
5125 check_eps ("real(cpow (e + i0), (0 + i 2*PI)) == 1", __real__ result
, 1,
5126 CHOOSE (0, 0, 6e-8));
5127 check_eps ("imag(cpow (e + i0), (0 + i 2*PI)) == 0", __imag__ result
, 0,
5128 CHOOSE (3e-18L, 3e-16, 4e-7));
5130 result
= FUNC (cpow
) (BUILD_COMPLEX (2, 3), BUILD_COMPLEX (4, 0));
5131 check_eps ("real(cpow (2 + i3), (4 + i0)) == -119", __real__ result
, -119,
5132 CHOOSE (9e-16L, 2e-14, 4e-5));
5133 check_eps ("imag(cpow (2 + i3), (4 + i0)) == -120", __imag__ result
, -120,
5134 CHOOSE (1e-15L, 0, 5e-5));
5141 /* cabs (x + iy) is specified as hypot (x,y) */
5143 a
= random_greater (0);
5144 check_isinfp_ext ("cabs (+inf + i x) == +inf",
5145 FUNC(cabs
) (BUILD_COMPLEX (plus_infty
, a
)), a
);
5146 check_isinfp_ext ("cabs (-inf + i x) == +inf",
5147 FUNC(cabs
) (BUILD_COMPLEX (minus_infty
, a
)), a
);
5149 check_isinfp ("cabs (+inf+ iNaN) == +inf",
5150 FUNC(cabs
) (BUILD_COMPLEX(minus_infty
, nan_value
)));
5151 check_isinfp ("cabs (-inf+ iNaN) == +inf",
5152 FUNC(cabs
) (BUILD_COMPLEX(minus_infty
, nan_value
)));
5154 check_isnan ("cabs (NaN+ iNaN) == NaN",
5155 FUNC(cabs
) (BUILD_COMPLEX(nan_value
, nan_value
)));
5157 a
= FUNC(cabs
) (BUILD_COMPLEX (12.4L, 0.7L));
5158 check ("cabs (x,y) == cabs (y,x)",
5159 FUNC(cabs
) (BUILD_COMPLEX(0.7L, 12.4L)), a
);
5160 check ("cabs (x,y) == cabs (-x,y)",
5161 FUNC(cabs
) (BUILD_COMPLEX(-12.4L, 0.7L)), a
);
5162 check ("cabs (x,y) == cabs (-y,x)",
5163 FUNC(cabs
) (BUILD_COMPLEX(-0.7L, 12.4L)), a
);
5164 check ("cabs (x,y) == cabs (-x,-y)",
5165 FUNC(cabs
) (BUILD_COMPLEX(-12.4L, -0.7L)), a
);
5166 check ("cabs (x,y) == cabs (-y,-x)",
5167 FUNC(cabs
) (BUILD_COMPLEX(-0.7L, -12.4L)), a
);
5168 check ("cabs (x,0) == fabs (x)", FUNC(cabs
) (BUILD_COMPLEX(-0.7L, 0)), 0.7L);
5169 check ("cabs (x,0) == fabs (x)", FUNC(cabs
) (BUILD_COMPLEX(0.7L, 0)), 0.7L);
5170 check ("cabs (x,0) == fabs (x)", FUNC(cabs
) (BUILD_COMPLEX(-1.0L, 0)), 1.0L);
5171 check ("cabs (x,0) == fabs (x)", FUNC(cabs
) (BUILD_COMPLEX(1.0L, 0)), 1.0L);
5172 check ("cabs (x,0) == fabs (x)", FUNC(cabs
) (BUILD_COMPLEX(-5.7e7L
, 0)),
5174 check ("cabs (x,0) == fabs (x)", FUNC(cabs
) (BUILD_COMPLEX(5.7e7L
, 0)),
5177 check_eps ("cabs (0.7 + i 1.2) == 1.38924...", FUNC(cabs
) (BUILD_COMPLEX(0.7, 1.2)),
5178 1.3892443989449804508L, CHOOSE(7e-17L, 3e-16, 0));
5185 /* carg (x + iy) is specified as atan2 (y, x) */
5188 x
= random_greater (0);
5189 check ("carg (x + i 0) == 0 for x > 0",
5190 FUNC(carg
) (BUILD_COMPLEX(x
, 0)), 0);
5191 x
= random_greater (0);
5192 check ("carg (x - i 0) == -0 for x > 0",
5193 FUNC(carg
) (BUILD_COMPLEX(x
, minus_zero
)), minus_zero
);
5195 check ("carg (+0 + i 0) == +0", FUNC(carg
) (BUILD_COMPLEX(0, 0)), 0);
5196 check ("carg (+0 - i 0) == -0", FUNC(carg
) (BUILD_COMPLEX(0, minus_zero
)),
5199 x
= -random_greater (0);
5200 check ("carg (x + i 0) == +pi for x < 0", FUNC(carg
) (BUILD_COMPLEX(x
, 0)),
5203 x
= -random_greater (0);
5204 check ("carg (x - i 0) == -pi for x < 0",
5205 FUNC(carg
) (BUILD_COMPLEX(x
, minus_zero
)), -M_PI
);
5207 check ("carg (-0 + i 0) == +pi", FUNC(carg
) (BUILD_COMPLEX(minus_zero
, 0)),
5209 check ("carg (-0 - i 0) == -pi",
5210 FUNC(carg
) (BUILD_COMPLEX(minus_zero
, minus_zero
)), -M_PI
);
5212 x
= random_greater (0);
5213 check ("carg (+0 + i y) == pi/2 for y > 0", FUNC(carg
) (BUILD_COMPLEX(0, x
)),
5216 x
= random_greater (0);
5217 check ("carg (-0 + i y) == pi/2 for y > 0",
5218 FUNC(carg
) (BUILD_COMPLEX(minus_zero
, x
)), M_PI_2
);
5220 x
= random_less (0);
5221 check ("carg (+0 + i y) == -pi/2 for y < 0", FUNC(carg
) (BUILD_COMPLEX(0, x
)),
5224 x
= random_less (0);
5225 check ("carg (-0 + i y) == -pi/2 for y < 0",
5226 FUNC(carg
) (BUILD_COMPLEX(minus_zero
, x
)), -M_PI_2
);
5228 x
= random_greater (0);
5229 check ("carg (inf + i y) == +0 for finite y > 0",
5230 FUNC(carg
) (BUILD_COMPLEX(plus_infty
, x
)), 0);
5232 x
= -random_greater (0);
5233 check ("carg (inf + i y) == -0 for finite y < 0",
5234 FUNC(carg
) (BUILD_COMPLEX(plus_infty
, x
)), minus_zero
);
5236 x
= random_value (-1e4
, 1e4
);
5237 check ("carg(x + i inf) == pi/2 for finite x",
5238 FUNC(carg
) (BUILD_COMPLEX(x
, plus_infty
)), M_PI_2
);
5240 x
= random_value (-1e4
, 1e4
);
5241 check ("carg(x - i inf) == -pi/2 for finite x",
5242 FUNC(carg
) (BUILD_COMPLEX(x
, minus_infty
)), -M_PI_2
);
5244 x
= random_greater (0);
5245 check ("carg (-inf + i y) == +pi for finite y > 0",
5246 FUNC(carg
) (BUILD_COMPLEX(minus_infty
, x
)), M_PI
);
5248 x
= -random_greater (0);
5249 check ("carg (-inf + i y) == -pi for finite y < 0",
5250 FUNC(carg
) (BUILD_COMPLEX(minus_infty
, x
)), -M_PI
);
5252 check ("carg (+inf + i inf) == +pi/4",
5253 FUNC(carg
) (BUILD_COMPLEX(plus_infty
, plus_infty
)), M_PI_4
);
5255 check ("carg (+inf -i inf) == -pi/4",
5256 FUNC(carg
) (BUILD_COMPLEX(plus_infty
, minus_infty
)), -M_PI_4
);
5258 check ("carg (-inf +i inf) == +3*pi/4",
5259 FUNC(carg
) (BUILD_COMPLEX(minus_infty
, plus_infty
)), 3 * M_PI_4
);
5261 check ("carg (-inf -i inf) == -3*pi/4",
5262 FUNC(carg
) (BUILD_COMPLEX(minus_infty
, minus_infty
)), -3 * M_PI_4
);
5268 nearbyint_test (void)
5270 check ("nearbyint(+0) = 0", FUNC(nearbyint
) (0.0), 0.0);
5271 check ("nearbyint(-0) = -0", FUNC(nearbyint
) (minus_zero
), minus_zero
);
5272 check_isinfp ("nearbyint(+Inf) = +Inf", FUNC(nearbyint
) (plus_infty
));
5273 check_isinfn ("nearbyint(-Inf) = -Inf", FUNC(nearbyint
) (minus_infty
));
5280 check ("rint(0) = 0", FUNC(rint
) (0.0), 0.0);
5281 check ("rint(-0) = -0", FUNC(rint
) (minus_zero
), minus_zero
);
5282 check_isinfp ("rint(+Inf) = +Inf", FUNC(rint
) (plus_infty
));
5283 check_isinfn ("rint(-Inf) = -Inf", FUNC(rint
) (minus_infty
));
5290 /* XXX this test is incomplete. We need to have a way to specifiy
5291 the rounding method and test the critical cases. So far, only
5292 unproblematic numbers are tested. */
5294 check_long ("lrint(0) = 0", FUNC(lrint
) (0.0), 0);
5295 check_long ("lrint(-0) = 0", FUNC(lrint
) (minus_zero
), 0);
5296 check_long ("lrint(0.2) = 0", FUNC(lrint
) (0.2), 0);
5297 check_long ("lrint(-0.2) = 0", FUNC(lrint
) (-0.2), 0);
5299 check_long ("lrint(1.4) = 1", FUNC(lrint
) (1.4), 1);
5300 check_long ("lrint(-1.4) = -1", FUNC(lrint
) (-1.4), -1);
5302 check_long ("lrint(8388600.3) = 8388600", FUNC(lrint
) (8388600.3), 8388600);
5303 check_long ("lrint(-8388600.3) = -8388600", FUNC(lrint
) (-8388600.3),
5311 /* XXX this test is incomplete. We need to have a way to specifiy
5312 the rounding method and test the critical cases. So far, only
5313 unproblematic numbers are tested. */
5315 check_longlong ("llrint(0) = 0", FUNC(llrint
) (0.0), 0);
5316 check_longlong ("llrint(-0) = 0", FUNC(llrint
) (minus_zero
), 0);
5317 check_longlong ("llrint(0.2) = 0", FUNC(llrint
) (0.2), 0);
5318 check_longlong ("llrint(-0.2) = 0", FUNC(llrint
) (-0.2), 0);
5320 check_longlong ("llrint(1.4) = 1", FUNC(llrint
) (1.4), 1);
5321 check_longlong ("llrint(-1.4) = -1", FUNC(llrint
) (-1.4), -1);
5323 check_longlong ("llrint(8388600.3) = 8388600", FUNC(llrint
) (8388600.3),
5325 check_longlong ("llrint(-8388600.3) = -8388600", FUNC(llrint
) (-8388600.3),
5328 /* Test boundary conditions. */
5330 check_longlong ("llrint(2097151.0) = 2097151", FUNC(llrint
) (2097151.0),
5333 check_longlong ("llrint(8388608.0) = 8388608", FUNC(llrint
) (8388608.0),
5336 check_longlong ("llrint(16777216.0) = 16777216",
5337 FUNC(llrint
) (16777216.0), 16777216LL);
5339 check_longlong ("llrint(2199023255552.0) = 2199023255552",
5340 FUNC(llrint
) (2199023255552.0), 2199023255552LL);
5342 check_longlong ("llrint(4398046511104.0) = 4398046511104",
5343 FUNC(llrint
) (4398046511104.0), 4398046511104LL);
5344 /* 0x10000000000000 */
5345 check_longlong ("llrint(4503599627370496.0) = 4503599627370496",
5346 FUNC(llrint
) (4503599627370496.0), 4503599627370496LL);
5347 /* 0x10000080000000 */
5348 check_longlong ("llrint(4503601774854144.0) = 4503601774854144",
5349 FUNC(llrint
) (4503601774854144.0), 4503601774854144LL);
5350 /* 0x20000000000000 */
5351 check_longlong ("llrint(9007199254740992.0) = 9007199254740992",
5352 FUNC(llrint
) (9007199254740992.0), 9007199254740992LL);
5353 /* 0x80000000000000 */
5354 check_longlong ("llrint(36028797018963968.0) = 36028797018963968",
5355 FUNC(llrint
) (36028797018963968.0), 36028797018963968LL);
5356 /* 0x100000000000000 */
5357 check_longlong ("llrint(72057594037927936.0) = 72057594037927936",
5358 FUNC(llrint
) (72057594037927936.0), 72057594037927936LL);
5365 check ("round(0) = 0", FUNC(round
) (0), 0);
5366 check ("round(-0) = -0", FUNC(round
) (minus_zero
), minus_zero
);
5367 check ("round(0.2) = 0", FUNC(round
) (0.2), 0.0);
5368 check ("round(-0.2) = -0", FUNC(round
) (-0.2), minus_zero
);
5369 check ("round(0.5) = 1", FUNC(round
) (0.5), 1.0);
5370 check ("round(-0.5) = -1", FUNC(round
) (-0.5), -1.0);
5371 check ("round(0.8) = 1", FUNC(round
) (0.8), 1.0);
5372 check ("round(-0.8) = -1", FUNC(round
) (-0.8), -1.0);
5373 check ("round(1.5) = 2", FUNC(round
) (1.5), 2.0);
5374 check ("round(-1.5) = -2", FUNC(round
) (-1.5), -2.0);
5375 check ("round(2097152.5) = 2097153", FUNC(round
) (2097152.5), 2097153);
5376 check ("round(-2097152.5) = -2097153", FUNC(round
) (-2097152.5), -2097153);
5383 check_long ("lround(0) = 0", FUNC(lround
) (0), 0);
5384 check_long ("lround(-0) = 0", FUNC(lround
) (minus_zero
), 0);
5385 check_long ("lround(0.2) = 0", FUNC(lround
) (0.2), 0.0);
5386 check_long ("lround(-0.2) = 0", FUNC(lround
) (-0.2), 0);
5387 check_long ("lround(0.5) = 1", FUNC(lround
) (0.5), 1);
5388 check_long ("lround(-0.5) = -1", FUNC(lround
) (-0.5), -1);
5389 check_long ("lround(0.8) = 1", FUNC(lround
) (0.8), 1);
5390 check_long ("lround(-0.8) = -1", FUNC(lround
) (-0.8), -1);
5391 check_long ("lround(1.5) = 2", FUNC(lround
) (1.5), 2);
5392 check_long ("lround(-1.5) = -2", FUNC(lround
) (-1.5), -2);
5393 check_long ("lround(22514.5) = 22515", FUNC(lround
) (22514.5), 22515);
5394 check_long ("lround(-22514.5) = -22515", FUNC(lround
) (-22514.5), -22515);
5396 check_long ("lround(2097152.5) = 2097153", FUNC(lround
) (2097152.5),
5398 check_long ("lround(-2097152.5) = -2097153", FUNC(lround
) (-2097152.5),
5407 check_longlong ("llround(0) = 0", FUNC(llround
) (0), 0);
5408 check_longlong ("llround(-0) = 0", FUNC(llround
) (minus_zero
), 0);
5409 check_longlong ("llround(0.2) = 0", FUNC(llround
) (0.2), 0.0);
5410 check_longlong ("llround(-0.2) = 0", FUNC(llround
) (-0.2), 0);
5411 check_longlong ("llround(0.5) = 1", FUNC(llround
) (0.5), 1);
5412 check_longlong ("llround(-0.5) = -1", FUNC(llround
) (-0.5), -1);
5413 check_longlong ("llround(0.8) = 1", FUNC(llround
) (0.8), 1);
5414 check_longlong ("llround(-0.8) = -1", FUNC(llround
) (-0.8), -1);
5415 check_longlong ("llround(1.5) = 2", FUNC(llround
) (1.5), 2);
5416 check_longlong ("llround(-1.5) = -2", FUNC(llround
) (-1.5), -2);
5417 check_longlong ("llround(22514.5) = 22515", FUNC(llround
) (22514.5), 22515);
5418 check_longlong ("llround(-22514.5) = -22515", FUNC(llround
) (-22514.5),
5421 check_longlong ("llround(2097152.5) = 2097153",
5422 FUNC(llround
) (2097152.5), 2097153);
5423 check_longlong ("llround(-2097152.5) = -2097153",
5424 FUNC(llround
) (-2097152.5), -2097153);
5425 check_longlong ("llround(34359738368.5) = 34359738369",
5426 FUNC(llround
) (34359738368.5), 34359738369ll);
5427 check_longlong ("llround(-34359738368.5) = -34359738369",
5428 FUNC(llround
) (-34359738368.5), -34359738369ll);
5431 /* Test boundary conditions. */
5433 check_longlong ("llround(2097151.0) = 2097151", FUNC(llround
) (2097151.0),
5436 check_longlong ("llround(8388608.0) = 8388608", FUNC(llround
) (8388608.0),
5439 check_longlong ("llround(16777216.0) = 16777216",
5440 FUNC(llround
) (16777216.0), 16777216LL);
5442 check_longlong ("llround(2199023255552.0) = 2199023255552",
5443 FUNC(llround
) (2199023255552.0), 2199023255552LL);
5445 check_longlong ("llround(4398046511104.0) = 4398046511104",
5446 FUNC(llround
) (4398046511104.0), 4398046511104LL);
5447 /* 0x10000000000000 */
5448 check_longlong ("llround(4503599627370496.0) = 4503599627370496",
5449 FUNC(llround
) (4503599627370496.0), 4503599627370496LL);
5450 /* 0x10000080000000 */
5451 check_longlong ("llrint(4503601774854144.0) = 4503601774854144",
5452 FUNC(llrint
) (4503601774854144.0), 4503601774854144LL);
5453 /* 0x20000000000000 */
5454 check_longlong ("llround(9007199254740992.0) = 9007199254740992",
5455 FUNC(llround
) (9007199254740992.0), 9007199254740992LL);
5456 /* 0x80000000000000 */
5457 check_longlong ("llround(36028797018963968.0) = 36028797018963968",
5458 FUNC(llround
) (36028797018963968.0), 36028797018963968LL);
5459 /* 0x100000000000000 */
5460 check_longlong ("llround(72057594037927936.0) = 72057594037927936",
5461 FUNC(llround
) (72057594037927936.0), 72057594037927936LL);
5468 check ("fma(1.0, 2.0, 3.0) = 5.0", FUNC(fma
) (1.0, 2.0, 3.0), 5.0);
5469 check_isnan ("fma(NaN, 2.0, 3.0) = NaN", FUNC(fma
) (nan_value
, 2.0, 3.0));
5470 check_isnan ("fma(1.0, NaN, 3.0) = NaN", FUNC(fma
) (1.0, nan_value
, 3.0));
5471 check_isnan_maybe_exc ("fma(1.0, 2.0, NaN) = NaN",
5472 FUNC(fma
) (1.0, 2.0, nan_value
), INVALID_EXCEPTION
);
5473 check_isnan_maybe_exc ("fma(+Inf, 0.0, NaN) = NaN",
5474 FUNC(fma
) (plus_infty
, 0.0, nan_value
),
5476 check_isnan_maybe_exc ("fma(-Inf, 0.0, NaN) = NaN",
5477 FUNC(fma
) (minus_infty
, 0.0, nan_value
),
5479 check_isnan_maybe_exc ("fma(0.0, +Inf, NaN) = NaN",
5480 FUNC(fma
) (0.0, plus_infty
, nan_value
),
5482 check_isnan_maybe_exc ("fma(0.0, -Inf, NaN) = NaN",
5483 FUNC(fma
) (0.0, minus_infty
, nan_value
),
5485 check_isnan_exc ("fma(+Inf, 0.0, 1.0) = NaN",
5486 FUNC(fma
) (plus_infty
, 0.0, 1.0), INVALID_EXCEPTION
);
5487 check_isnan_exc ("fma(-Inf, 0.0, 1.0) = NaN",
5488 FUNC(fma
) (minus_infty
, 0.0, 1.0), INVALID_EXCEPTION
);
5489 check_isnan_exc ("fma(0.0, +Inf, 1.0) = NaN",
5490 FUNC(fma
) (0.0, plus_infty
, 1.0), INVALID_EXCEPTION
);
5491 check_isnan_exc ("fma(0.0, -Inf, 1.0) = NaN",
5492 FUNC(fma
) (0.0, minus_infty
, 1.0), INVALID_EXCEPTION
);
5494 check_isnan_exc ("fma(+Inf, +Inf, -Inf) = NaN",
5495 FUNC(fma
) (plus_infty
, plus_infty
, minus_infty
),
5497 check_isnan_exc ("fma(-Inf, +Inf, +Inf) = NaN",
5498 FUNC(fma
) (minus_infty
, plus_infty
, plus_infty
),
5500 check_isnan_exc ("fma(+Inf, -Inf, +Inf) = NaN",
5501 FUNC(fma
) (plus_infty
, minus_infty
, plus_infty
),
5503 check_isnan_exc ("fma(-Inf, -Inf, -Inf) = NaN",
5504 FUNC(fma
) (minus_infty
, minus_infty
, minus_infty
),
5510 inverse_func_pair_test (const char *test_name
,
5511 mathfunc f1
, mathfunc inverse
,
5512 MATHTYPE x
, MATHTYPE epsilon
)
5514 MATHTYPE a
, b
, difference
;
5522 output_new_test (test_name
);
5523 result
= check_equal (b
, x
, epsilon
, &difference
);
5524 output_result (test_name
, result
,
5525 b
, x
, difference
, PRINT
, PRINT
);
5530 inverse_functions (void)
5532 inverse_func_pair_test ("asin(sin(x)) == x",
5533 FUNC(sin
), FUNC(asin
), 1.0,
5534 CHOOSE (2e-18L, 0, 3e-7L));
5535 inverse_func_pair_test ("sin(asin(x)) == x",
5536 FUNC(asin
), FUNC(sin
), 1.0, 0.0);
5538 inverse_func_pair_test ("acos(cos(x)) == x",
5539 FUNC(cos
), FUNC(acos
), 1.0,
5540 CHOOSE (4e-18L, 1e-15L, 0));
5541 inverse_func_pair_test ("cos(acos(x)) == x",
5542 FUNC(acos
), FUNC(cos
), 1.0, 0.0);
5543 inverse_func_pair_test ("atan(tan(x)) == x",
5544 FUNC(tan
), FUNC(atan
), 1.0, CHOOSE (2e-18L, 0, 0));
5545 inverse_func_pair_test ("tan(atan(x)) == x",
5546 FUNC(atan
), FUNC(tan
), 1.0,
5547 CHOOSE (2e-18L, 1e-15L, 2e-7));
5549 inverse_func_pair_test ("asinh(sinh(x)) == x",
5550 FUNC(sinh
), FUNC(asinh
), 1.0, CHOOSE (1e-18L, 0, 1e-7));
5551 inverse_func_pair_test ("sinh(asinh(x)) == x",
5552 FUNC(asinh
), FUNC(sinh
), 1.0,
5553 CHOOSE (2e-18L, 2e-16L, 2e-7));
5555 inverse_func_pair_test ("acosh(cosh(x)) == x",
5556 FUNC(cosh
), FUNC(acosh
), 1.0,
5557 CHOOSE (1e-18L, 1e-15L, 6e-8));
5558 inverse_func_pair_test ("cosh(acosh(x)) == x",
5559 FUNC(acosh
), FUNC(cosh
), 1.0, 0.0);
5561 inverse_func_pair_test ("atanh(tanh(x)) == x",
5562 FUNC(tanh
), FUNC(atanh
), 1.0, CHOOSE (1e-18L, 1e-15L, 0));
5563 inverse_func_pair_test ("tanh(atanh(x)) == x",
5564 FUNC(atanh
), FUNC(tanh
), 1.0, 0.0);
5568 /* Test sin and cos with the identity: sin(x)^2 + cos(x)^2 = 1. */
5570 identities1_test (MATHTYPE x
, MATHTYPE epsilon
)
5572 MATHTYPE res1
, res2
, res3
, diff
;
5575 res1
= FUNC(sin
) (x
);
5577 res2
= FUNC(cos
) (x
);
5579 res3
= res1
* res1
+ res2
* res2
;
5582 output_new_test ("sin^2 + cos^2 == 1");
5583 result
= check_equal (res3
, 1.0, epsilon
, &diff
);
5584 output_result_ext ("sin^2 + cos^2 == 1", result
,
5585 res3
, 1.0, diff
, x
, PRINT
, PRINT
);
5589 /* Test sin, cos, tan with the following relation: tan = sin/cos. */
5591 identities2_test (MATHTYPE x
, MATHTYPE epsilon
)
5594 MATHTYPE res1
, res2
, res3
, res4
, diff
;
5597 res1
= FUNC(sin
) (x
);
5599 res2
= FUNC(cos
) (x
);
5601 res3
= FUNC(tan
) (x
);
5606 output_new_test ("sin/cos == tan");
5607 result
= check_equal (res4
, res3
, epsilon
, &diff
);
5608 output_result_ext ("sin/cos == tan", result
,
5609 res4
, res3
, diff
, x
, PRINT
, PRINT
);
5614 /* Test cosh and sinh with the identity cosh^2 - sinh^2 = 1. */
5616 identities3_test (MATHTYPE x
, MATHTYPE epsilon
)
5618 MATHTYPE res1
, res2
, res3
, diff
;
5621 res1
= FUNC(sinh
) (x
);
5623 res2
= FUNC(cosh
) (x
);
5625 res3
= res2
* res2
- res1
* res1
;
5628 output_new_test ("cosh^2 - sinh^2 == 1");
5629 result
= check_equal (res3
, 1.0, epsilon
, &diff
);
5630 output_result_ext ("cosh^2 - sinh^2 == 1", result
,
5631 res3
, 1.0, diff
, x
, PRINT
, PRINT
);
5638 identities1_test (0.2L, CHOOSE (1e-18L, 0, 2e-7));
5639 identities1_test (0.9L, CHOOSE (1e-18L, 0, 1e-7));
5640 identities1_test (0, 0);
5641 identities1_test (-1, CHOOSE (1e-18L, 0, 1e-7));
5643 identities2_test (0.2L, CHOOSE (1e-19L, 1e-16, 0));
5644 identities2_test (0.9L, CHOOSE (0, 1e-15, 2e-7));
5645 identities2_test (0, 0);
5646 identities2_test (-1, CHOOSE (1e-18L, 1e-15, 2e-7));
5648 identities3_test (0.2L, CHOOSE (1e-18L, 0, 1e-7));
5649 identities3_test (0.9L, CHOOSE (1e-18L, 1e-15, 1e-6));
5650 identities3_test (0, CHOOSE (0, 0, 1e-6));
5651 identities3_test (-1, CHOOSE (1e-18L, 7e-16, 1e-6));
5656 Let's test that basic arithmetic is working
5657 tests: Infinity and NaN
5662 /* variables are declared volatile to forbid some compiler
5664 volatile MATHTYPE Inf_var
, NaN_var
, zero_var
, one_var
;
5669 NaN_var
= nan_value
;
5670 Inf_var
= one_var
/ zero_var
;
5677 /* Clear all exceptions. The previous computations raised exceptions. */
5678 feclearexcept (FE_ALL_EXCEPT
);
5680 check_isinfp ("isinf (inf) == +1", Inf_var
);
5681 check_isinfn ("isinf (-inf) == -1", -Inf_var
);
5682 check_bool ("!isinf (1)", !(FUNC(isinf
) (one_var
)));
5683 check_bool ("!isinf (NaN)", !(FUNC(isinf
) (NaN_var
)));
5685 check_isnan ("isnan (NaN)", NaN_var
);
5686 check_isnan ("isnan (-NaN)", -NaN_var
);
5687 check_bool ("!isnan (1)", !(FUNC(isnan
) (one_var
)));
5688 check_bool ("!isnan (inf)", !(FUNC(isnan
) (Inf_var
)));
5690 check_bool ("inf == inf", Inf_var
== Inf_var
);
5691 check_bool ("-inf == -inf", -Inf_var
== -Inf_var
);
5692 check_bool ("inf != -inf", Inf_var
!= -Inf_var
);
5693 check_bool ("NaN != NaN", NaN_var
!= NaN_var
);
5696 the same tests but this time with NAN from <bits/nan.h>
5697 NAN is a double const
5699 check_bool ("isnan (NAN)", isnan (NAN
));
5700 check_bool ("isnan (-NAN)", isnan (-NAN
));
5701 check_bool ("!isinf (NAN)", !(isinf (NAN
)));
5702 check_bool ("!isinf (-NAN)", !(isinf (-NAN
)));
5703 check_bool ("NAN != NAN", NAN
!= NAN
);
5706 And again with the value returned by the `nan' function.
5708 check_bool ("isnan (NAN)", FUNC(isnan
) (FUNC(nan
) ("")));
5709 check_bool ("isnan (-NAN)", FUNC(isnan
) (-FUNC(nan
) ("")));
5710 check_bool ("!isinf (NAN)", !(FUNC(isinf
) (FUNC(nan
) (""))));
5711 check_bool ("!isinf (-NAN)", !(FUNC(isinf
) (-FUNC(nan
) (""))));
5712 check_bool ("NAN != NAN", FUNC(nan
) ("") != FUNC(nan
) (""));
5714 /* test if EPSILON is ok */
5715 x1
= MATHCONST (1.0);
5716 x2
= x1
+ CHOOSE (LDBL_EPSILON
, DBL_EPSILON
, FLT_EPSILON
);
5717 check_bool ("1 != 1+EPSILON", x1
!= x2
);
5719 x1
= MATHCONST (1.0);
5720 x2
= x1
- CHOOSE (LDBL_EPSILON
, DBL_EPSILON
, FLT_EPSILON
);
5721 check_bool ("1 != 1-EPSILON", x1
!= x2
);
5723 /* test if HUGE_VALx is ok */
5724 x1
= CHOOSE (HUGE_VALL
, HUGE_VAL
, HUGE_VALF
);
5725 check_bool ("isinf (HUGE_VALx) == +1", ISINF (x1
) == +1);
5726 x1
= -CHOOSE (HUGE_VALL
, HUGE_VAL
, HUGE_VALF
);
5727 check_bool ("isinf (-HUGE_VALx) == -1", ISINF (x1
) == -1);
5735 fpstack_test ("start *init*");
5737 nan_value
= plus_zero
/ plus_zero
; /* Suppress GCC warning */
5739 minus_zero
= FUNC (copysign
) (0.0, -1.0);
5740 plus_infty
= CHOOSE (HUGE_VALL
, HUGE_VAL
, HUGE_VALF
);
5741 minus_infty
= -CHOOSE (HUGE_VALL
, HUGE_VAL
, HUGE_VALF
);
5747 (void) &minus_infty
;
5749 /* Clear all exceptions. From now on we must not get random exceptions. */
5750 feclearexcept (FE_ALL_EXCEPT
);
5752 /* Test to make sure we start correctly. */
5753 fpstack_test ("end *init*");
5757 static struct option long_options
[] =
5759 {"verbose", optional_argument
, NULL
, 'v'},
5760 {"silent", no_argument
, NULL
, 's'},
5766 parse_options (int argc
, char *argv
[])
5775 c
= getopt_long (argc
, argv
, "v::s",
5776 long_options
, &option_index
);
5778 /* Detect the end of the options. */
5786 verbose
= (unsigned int) strtoul (optarg
, NULL
, 0);
5800 main (int argc
, char *argv
[])
5803 parse_options (argc
, argv
);
5810 /* keep the tests a wee bit ordered (according to ISO 9X) */
5811 /* classification functions */
5817 /* trigonometric functions */
5827 /* hyperbolic functions */
5835 /* exponential and logarithmic functions */
5851 /* power and absolute value functions */
5858 /* error and gamma functions */
5864 /* nearest integer functions */
5876 /* remainder functions */
5881 /* manipulation functions */
5885 /* maximum, minimum and positive difference functions */
5890 /* complex functions */
5911 /* multiply and add */
5916 inverse_functions ();
5918 printf ("\nTest suite completed:\n");
5919 printf (" %d test cases plus %d tests for exception flags executed.\n",
5920 noTests
, noExcTests
);
5923 printf (" %d errors occured.\n", noErrors
);
5926 printf (" All tests passed successfully.\n");