1 /* Compute sine and cosine of argument.
2 Copyright (C) 1997-2023 Free Software Foundation, Inc.
3 This file is part of the GNU C Library.
5 The GNU C Library is free software; you can redistribute it and/or
6 modify it under the terms of the GNU Lesser General Public
7 License as published by the Free Software Foundation; either
8 version 2.1 of the 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 Lesser General Public License for more details.
15 You should have received a copy of the GNU Lesser General Public
16 License along with the GNU C Library; if not, see
17 <https://www.gnu.org/licenses/>. */
22 #include <math_private.h>
23 #include <fenv_private.h>
24 #include <math-underflow.h>
25 #include <libm-alias-double.h>
36 __sincos (double x
, double *sinx
, double *cosx
)
41 SET_RESTORE_ROUND_53BIT (FE_TONEAREST
);
44 k
= u
.i
[HIGH_HALF
] & 0x7fffffff;
49 /* |x| < 2^-27 => cos (x) = 1, sin (x) = x. */
53 math_check_force_underflow (x
);
59 else if (k
< 0x3feb6000)
61 *sinx
= do_sin (x
, 0);
62 *cosx
= do_cos (x
, 0);
70 *sinx
= copysign (do_cos (a
, da
), x
);
71 *cosx
= do_sin (a
, da
);
80 /* If |x| < 105414350 use simple range reduction. */
81 n
= k
< 0x419921FB ? reduce_sincos (x
, &a
, &da
) : __branred (x
, &a
, &da
);
97 *sinx
= do_sin (a
, da
);
99 *cosx
= (n
& 2) ? -xx
: xx
;
106 *sinx
= *cosx
= x
/ x
;
109 libm_alias_double (__sincos
, sincos
)