1111*/
1212#include <math.h>
1313
14- #define two_over_pi 0.636619772367581
15- #define p0 0.135788409787738e8
16- #define p1 -0.494290810090284e7
17- #define p2 0.440103053537527e6
18- #define p3 -0.138472724998245e5
19- #define p4 0.145968840666577e3
20- #define q0 0.864455865292253e7
21- #define q1 0.408179225234330e6
22- #define q2 0.946309610153821e4
23- #define q3 0.132653490878614e3
14+ #define two_over_pi 0.63661977236758134f
15+ #define p0 0.135788409787738e8f
16+ #define p1 -0.494290810090284e7f
17+ #define p2 0.440103053537527e6f
18+ #define p3 -0.138472724998245e5f
19+ #define p4 0.145968840666577e3f
20+ #define q0 0.864455865292253e7f
21+ #define q1 0.408179225234330e6f
22+ #define q2 0.946309610153821e4f
23+ #define q3 0.132653490878614e3f
2424
2525float sinus (float arg , int quad )
2626{
@@ -31,34 +31,44 @@ float sinus(float arg, int quad)
3131 float temp1 , temp2 ;
3232
3333 x = arg ;
34- if (x < 0 ) {
34+ if (x < 0.0f ) {
3535 x = - x ;
3636 quad = quad + 2 ;
3737 }
38- x = x * two_over_pi ; /*underflow?*/
39- if ( x > 32764 ) {
38+ x = x * two_over_pi ; /* underflow? */
39+ if ( x > 32764.0f ) {
4040 y = modff (x ,& e );
4141 e = e + quad ;
42- modff (0.25 * e ,& f );
43- quad = e - 4 * f ;
44- }else {
42+ modff (0.25f * e ,& f );
43+ quad = e - 4.0f * f ;
44+ } else {
4545 k = x ;
4646 y = x - k ;
47- quad = (quad + k ) & 03 ;
47+ quad = (quad + k ) & 0x3 ;
4848 }
49- if (quad & 01 )
50- y = 1 - y ;
51- if (quad > 1 )
49+ if (quad & 0x1 ) {
50+ y = 1.0f - y ;
51+ }
52+ if (quad > 1 ) {
5253 y = - y ;
54+ }
5355
5456 ysq = y * y ;
5557 temp1 = ((((p4 * ysq + p3 )* ysq + p2 )* ysq + p1 )* ysq + p0 )* y ;
5658 temp2 = ((((ysq + q3 )* ysq + q2 )* ysq + q1 )* ysq + q0 );
5759 return (temp1 /temp2 );
5860}
5961
62+ /**
63+ * @remarks Minimum ulp:
64+ * ulp of -5 at +0x1.fe2dd0p-9 (|x| < pi/2)
65+ */
6066float _sinf_c (float arg ) {
67+ if (fabsf (arg ) < 0x1.0p-11f ) {
68+ return arg ;
69+ }
6170 return sinus (arg , 0 );
6271}
6372
73+
6474double _sin_c (double ) __attribute__((alias ("_sinf_c" )));
0 commit comments