/* origin: FreeBSD /usr/src/lib/msun/src/e_asinf.c */1/*2* Conversion to float by Ian Lance Taylor, Cygnus Support, [email protected].3*/4/*5* ====================================================6* Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved.7*8* Developed at SunPro, a Sun Microsystems, Inc. business.9* Permission to use, copy, modify, and distribute this10* software is freely granted, provided that this notice11* is preserved.12* ====================================================13*/14#include "libm.h"1516static const double17pio2 = 1.570796326794896558e+00;1819static const float20/* coefficients for R(x^2) */21pS0 = 1.6666586697e-01,22pS1 = -4.2743422091e-02,23pS2 = -8.6563630030e-03,24qS1 = -7.0662963390e-01;2526static float R(float z)27{28float_t p, q;29p = z*(pS0+z*(pS1+z*pS2));30q = 1.0f+z*qS1;31return p/q;32}3334float asinf(float x)35{36double s;37float z;38uint32_t hx,ix;3940GET_FLOAT_WORD(hx, x);41ix = hx & 0x7fffffff;42if (ix >= 0x3f800000) { /* |x| >= 1 */43if (ix == 0x3f800000) /* |x| == 1 */44return x*pio2 + 0x1p-120f; /* asin(+-1) = +-pi/2 with inexact */45return 0/(x-x); /* asin(|x|>1) is NaN */46}47if (ix < 0x3f000000) { /* |x| < 0.5 */48/* if 0x1p-126 <= |x| < 0x1p-12, avoid raising underflow */49if (ix < 0x39800000 && ix >= 0x00800000)50return x;51return x + x*R(x*x);52}53/* 1 > |x| >= 0.5 */54z = (1 - fabsf(x))*0.5f;55s = sqrt(z);56x = pio2 - 2*(s+s*R(z));57if (hx >> 31)58return -x;59return x;60}616263