1 /* origin: FreeBSD /usr/src/lib/msun/src/e_acosf.c */
3 * Conversion to float by Ian Lance Taylor, Cygnus Support, ian@cygnus.com.
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
13 * ====================================================
19 one = 1.0000000000e+00, /* 0x3F800000 */
20 pi = 3.1415925026e+00, /* 0x40490fda */
21 pio2_hi = 1.5707962513e+00; /* 0x3fc90fda */
22 static const volatile float
23 pio2_lo = 7.5497894159e-08; /* 0x33a22168 */
25 pS0 = 1.6666586697e-01,
26 pS1 = -4.2743422091e-02,
27 pS2 = -8.6563630030e-03,
28 qS1 = -7.0662963390e-01;
32 float z,p,q,r,w,s,c,df;
35 GET_FLOAT_WORD(hx, x);
37 if (ix >= 0x3f800000) { /* |x| >= 1 */
38 if (ix == 0x3f800000) { /* |x| == 1 */
39 if (hx > 0) return 0.0f; /* acos(1) = 0 */
40 return pi + 2.0f*pio2_lo; /* acos(-1)= pi */
42 return (x-x)/(x-x); /* acos(|x|>1) is NaN */
44 if (ix < 0x3f000000) { /* |x| < 0.5 */
45 if (ix <= 0x32800000) /* |x| < 2**-26 */
46 return pio2_hi + pio2_lo;
48 p = z*(pS0+z*(pS1+z*pS2));
51 return pio2_hi - (x - (pio2_lo-x*r));
52 } else if (hx < 0) { /* x < -0.5 */
54 p = z*(pS0+z*(pS1+z*pS2));
59 return pi - 2.0f*(s+w);
60 } else { /* x > 0.5 */
66 GET_FLOAT_WORD(idf,df);
67 SET_FLOAT_WORD(df,idf&0xfffff000);
69 p = z*(pS0+z*(pS1+z*pS2));