* sources.am, Makefile.in: Rebuilt.
[official-gcc.git] / libgcc-math / flt-32 / e_asinf.c
blobf563d374d55f51008aaff9a8cf8972c6a70d6e63
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 * ====================================================
17 Modifications for single precision expansion are
18 Copyright (C) 2001 Stephen L. Moshier <moshier@na-net.ornl.gov>
19 and are incorporated herein by permission of the author. The author
20 reserves the right to distribute this material elsewhere under different
21 copying permissions. These modifications are distributed here under
22 the following terms:
24 This library is free software; you can redistribute it and/or
25 modify it under the terms of the GNU Lesser General Public
26 License as published by the Free Software Foundation; either
27 version 2.1 of the License, or (at your option) any later version.
29 This library is distributed in the hope that it will be useful,
30 but WITHOUT ANY WARRANTY; without even the implied warranty of
31 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
32 Lesser General Public License for more details.
34 You should have received a copy of the GNU Lesser General Public
35 License along with this library; if not, write to the Free Software
36 Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */
38 #if defined(LIBM_SCCS) && !defined(lint)
39 static char rcsid[] = "$NetBSD: e_asinf.c,v 1.5 1995/05/12 04:57:25 jtc Exp $";
40 #endif
42 #include "math_private.h"
44 #ifdef __STDC__
45 static const float
46 #else
47 static float
48 #endif
49 one = 1.0000000000e+00, /* 0x3F800000 */
50 huge = 1.000e+30,
52 pio2_hi = 1.57079637050628662109375f,
53 pio2_lo = -4.37113900018624283e-8f,
54 pio4_hi = 0.785398185253143310546875f,
56 /* asin x = x + x^3 p(x^2)
57 -0.5 <= x <= 0.5;
58 Peak relative error 4.8e-9 */
59 p0 = 1.666675248e-1f,
60 p1 = 7.495297643e-2f,
61 p2 = 4.547037598e-2f,
62 p3 = 2.417951451e-2f,
63 p4 = 4.216630880e-2f;
65 #ifdef __STDC__
66 float __ieee754_asinf(float x)
67 #else
68 float __ieee754_asinf(x)
69 float x;
70 #endif
72 float t,w,p,q,c,r,s;
73 int32_t hx,ix;
74 GET_FLOAT_WORD(hx,x);
75 ix = hx&0x7fffffff;
76 if(ix==0x3f800000) {
77 /* asin(1)=+-pi/2 with inexact */
78 return x*pio2_hi+x*pio2_lo;
79 } else if(ix> 0x3f800000) { /* |x|>= 1 */
80 return (x-x)/(x-x); /* asin(|x|>1) is NaN */
81 } else if (ix<0x3f000000) { /* |x|<0.5 */
82 if(ix<0x32000000) { /* if |x| < 2**-27 */
83 if(huge+x>one) return x;/* return x with inexact if x!=0*/
84 } else {
85 t = x*x;
86 w = t * (p0 + t * (p1 + t * (p2 + t * (p3 + t * p4))));
87 return x+x*w;
90 /* 1> |x|>= 0.5 */
91 w = one-fabsf(x);
92 t = w*0.5f;
93 p = t * (p0 + t * (p1 + t * (p2 + t * (p3 + t * p4))));
94 s = __ieee754_sqrtf(t);
95 if(ix>=0x3F79999A) { /* if |x| > 0.975 */
96 t = pio2_hi-(2.0f*(s+s*p)-pio2_lo);
97 } else {
98 int32_t iw;
99 w = s;
100 GET_FLOAT_WORD(iw,w);
101 SET_FLOAT_WORD(w,iw&0xfffff000);
102 c = (t-w*w)/(s+w);
103 r = p;
104 p = 2.0f*s*r-(pio2_lo-2.0f*c);
105 q = pio4_hi-2.0f*w;
106 t = pio4_hi-(p-q);
108 if(hx>0) return t; else return -t;