e_asinf.c revision 181405
1254721Semaste/* e_asinf.c -- float version of e_asin.c.
2254721Semaste * Conversion to float by Ian Lance Taylor, Cygnus Support, ian@cygnus.com.
3254721Semaste */
4254721Semaste
5254721Semaste/*
6254721Semaste * ====================================================
7254721Semaste * Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved.
8254721Semaste *
9254721Semaste * Developed at SunPro, a Sun Microsystems, Inc. business.
10254721Semaste * Permission to use, copy, modify, and distribute this
11254721Semaste * software is freely granted, provided that this notice
12254721Semaste * is preserved.
13254721Semaste * ====================================================
14254721Semaste */
15254721Semaste
16254721Semaste#include <sys/cdefs.h>
17254721Semaste__FBSDID("$FreeBSD: head/lib/msun/src/e_asinf.c 181405 2008-08-08 00:21:27Z das $");
18254721Semaste
19254721Semaste#include "math.h"
20254721Semaste#include "math_private.h"
21254721Semaste
22254721Semastestatic const float
23254721Semasteone =  1.0000000000e+00, /* 0x3F800000 */
24254721Semastehuge =  1.000e+30,
25254721Semaste	/* coefficient for R(x^2) */
26254721SemastepS0 =  1.6666586697e-01,
27254721SemastepS1 = -4.2743422091e-02,
28254721SemastepS2 = -8.6563630030e-03,
29254721SemasteqS1 = -7.0662963390e-01;
30254721Semaste
31254721Semastestatic const double
32254721Semastepio2 =  1.570796326794896558e+00;
33254721Semaste
34254721Semastefloat
35254721Semaste__ieee754_asinf(float x)
36254721Semaste{
37254721Semaste	double s;
38254721Semaste	float t,w,p,q;
39254721Semaste	int32_t hx,ix;
40254721Semaste	GET_FLOAT_WORD(hx,x);
41254721Semaste	ix = hx&0x7fffffff;
42254721Semaste	if(ix>=0x3f800000) {		/* |x| >= 1 */
43254721Semaste	    if(ix==0x3f800000)		/* |x| == 1 */
44254721Semaste		return x*pio2;		/* asin(+-1) = +-pi/2 with inexact */
45254721Semaste	    return (x-x)/(x-x);		/* asin(|x|>1) is NaN */
46254721Semaste	} else if (ix<0x3f000000) {	/* |x|<0.5 */
47254721Semaste	    if(ix<0x39800000) {		/* |x| < 2**-12 */
48254721Semaste		if(huge+x>one) return x;/* return x with inexact if x!=0*/
49254721Semaste	    }
50254721Semaste	    t = x*x;
51254721Semaste	    p = t*(pS0+t*(pS1+t*pS2));
52254721Semaste	    q = one+t*qS1;
53254721Semaste	    w = p/q;
54254721Semaste	    return x+x*w;
55254721Semaste	}
56254721Semaste	/* 1> |x|>= 0.5 */
57254721Semaste	w = one-fabsf(x);
58254721Semaste	t = w*(float)0.5;
59254721Semaste	p = t*(pS0+t*(pS1+t*pS2));
60254721Semaste	q = one+t*qS1;
61254721Semaste	s = sqrt(t);
62254721Semaste	w = p/q;
63254721Semaste	t = pio2-2.0*(s+s*w);
64254721Semaste	if(hx>0) return t; else return -t;
65254721Semaste}
66254721Semaste