1 /* s_cosl.c -- long double version of s_cos.c.
2 * Conversion to long double by Ulrich Drepper,
3 * Cygnus Support, drepper@cygnus.com.
7 * ====================================================
8 * Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved.
10 * Developed at SunPro, a Sun Microsystems, Inc. business.
11 * Permission to use, copy, modify, and distribute this
12 * software is freely granted, provided that this notice
14 * ====================================================
17 #if defined(LIBM_SCCS) && !defined(lint)
18 static char rcsid
[] = "$NetBSD: $";
22 * Return cosine function of x.
25 * __kernel_sinl ... sine function on [-pi/4,pi/4]
26 * __kernel_cosl ... cosine function on [-pi/4,pi/4]
27 * __ieee754_rem_pio2l ... argument reduction routine
30 * Let S,C and T denote the sin, cos and tan respectively on
31 * [-PI/4, +PI/4]. Reduce the argument x to y1+y2 = x-k*pi/2
32 * in [-pi/4 , +pi/4], and let n = k mod 4.
35 * n sin(x) cos(x) tan(x)
36 * ----------------------------------------------------------
41 * ----------------------------------------------------------
44 * Let trig be any of sin, cos, or tan.
45 * trig(+-INF) is NaN, with signals;
46 * trig(NaN) is that NaN;
49 * TRIG(x) returns trig(x) nearly rounded
53 #include "math_private.h"
56 long double __cosl(long double x
)
62 long double y
[2],z
=0.0;
66 GET_LDOUBLE_EXP(se
,x
);
70 if(ix
<= 0x3ffe) return __kernel_cosl(x
,z
);
72 /* cos(Inf or NaN) is NaN */
73 else if (se
==0x7fff) return x
-x
;
75 /* argument reduction needed */
77 n
= __ieee754_rem_pio2l(x
,y
);
79 case 0: return __kernel_cosl(y
[0],y
[1]);
80 case 1: return -__kernel_sinl(y
[0],y
[1],1);
81 case 2: return -__kernel_cosl(y
[0],y
[1]);
83 return __kernel_sinl(y
[0],y
[1],1);
87 weak_alias (__cosl
, cosl
)