Update.
[glibc.git] / sysdeps / libm-ieee754 / e_asinf.c
blob5270f31144fbe5b372dcc0f2e59a02c9655843f3
1 /* e_asinf.c -- float version of e_asin.c.
2 * Conversion to float by Ian Lance Taylor, Cygnus Support, ian@cygnus.com.
3 */
5 /*
6 * ====================================================
7 * Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved.
9 * Developed at SunPro, a Sun Microsystems, Inc. business.
10 * Permission to use, copy, modify, and distribute this
11 * software is freely granted, provided that this notice
12 * is preserved.
13 * ====================================================
16 #if defined(LIBM_SCCS) && !defined(lint)
17 static char rcsid[] = "$NetBSD: e_asinf.c,v 1.5 1995/05/12 04:57:25 jtc Exp $";
18 #endif
20 #include "math.h"
21 #include "math_private.h"
23 #ifdef __STDC__
24 static const float
25 #else
26 static float
27 #endif
28 one = 1.0000000000e+00, /* 0x3F800000 */
29 huge = 1.000e+30,
30 pio2_hi = 1.5707962513e+00, /* 0x3fc90fda */
31 pio2_lo = 7.5497894159e-08, /* 0x33a22168 */
32 pio4_hi = 7.8539818525e-01, /* 0x3f490fdb */
33 /* coefficient for R(x^2) */
34 pS0 = 1.6666667163e-01, /* 0x3e2aaaab */
35 pS1 = -3.2556581497e-01, /* 0xbea6b090 */
36 pS2 = 2.0121252537e-01, /* 0x3e4e0aa8 */
37 pS3 = -4.0055535734e-02, /* 0xbd241146 */
38 pS4 = 7.9153501429e-04, /* 0x3a4f7f04 */
39 pS5 = 3.4793309169e-05, /* 0x3811ef08 */
40 qS1 = -2.4033949375e+00, /* 0xc019d139 */
41 qS2 = 2.0209457874e+00, /* 0x4001572d */
42 qS3 = -6.8828397989e-01, /* 0xbf303361 */
43 qS4 = 7.7038154006e-02; /* 0x3d9dc62e */
45 #ifdef __STDC__
46 float __ieee754_asinf(float x)
47 #else
48 float __ieee754_asinf(x)
49 float x;
50 #endif
52 float t,w,p,q,c,r,s;
53 int32_t hx,ix;
54 GET_FLOAT_WORD(hx,x);
55 ix = hx&0x7fffffff;
56 if(ix==0x3f800000) {
57 /* asin(1)=+-pi/2 with inexact */
58 return x*pio2_hi+x*pio2_lo;
59 } else if(ix> 0x3f800000) { /* |x|>= 1 */
60 return (x-x)/(x-x); /* asin(|x|>1) is NaN */
61 } else if (ix<0x3f000000) { /* |x|<0.5 */
62 if(ix<0x32000000) { /* if |x| < 2**-27 */
63 if(huge+x>one) return x;/* return x with inexact if x!=0*/
64 } else {
65 t = x*x;
66 p = t*(pS0+t*(pS1+t*(pS2+t*(pS3+t*(pS4+t*pS5)))));
67 q = one+t*(qS1+t*(qS2+t*(qS3+t*qS4)));
68 w = p/q;
69 return x+x*w;
72 /* 1> |x|>= 0.5 */
73 w = one-fabsf(x);
74 t = w*(float)0.5;
75 p = t*(pS0+t*(pS1+t*(pS2+t*(pS3+t*(pS4+t*pS5)))));
76 q = one+t*(qS1+t*(qS2+t*(qS3+t*qS4)));
77 s = __ieee754_sqrtf(t);
78 if(ix>=0x3F79999A) { /* if |x| > 0.975 */
79 w = p/q;
80 t = pio2_hi-((float)2.0*(s+s*w)-pio2_lo);
81 } else {
82 int32_t iw;
83 w = s;
84 GET_FLOAT_WORD(iw,w);
85 SET_FLOAT_WORD(w,iw&0xfffff000);
86 c = (t-w*w)/(s+w);
87 r = p/q;
88 p = (float)2.0*s*r-(pio2_lo-(float)2.0*c);
89 q = pio4_hi-(float)2.0*w;
90 t = pio4_hi-(p-q);
92 if(hx>0) return t; else return -t;