Deleted Added
full compact
0a1
> /* from: FreeBSD: head/lib/msun/src/e_acosh.c 176451 2008-02-22 02:30:36Z das */
16c17
< __FBSDID("$FreeBSD: head/lib/msun/src/e_acosh.c 176451 2008-02-22 02:30:36Z das $");
---
> __FBSDID("$FreeBSD: head/lib/msun/src/e_acoshl.c 251599 2013-06-10 06:04:58Z das $");
18,25c19,20
< /* __ieee754_acosh(x)
< * Method :
< * Based on
< * acosh(x) = log [ x + sqrt(x*x-1) ]
< * we have
< * acosh(x) := log(x)+ln2, if x is large; else
< * acosh(x) := log(2x-1/(sqrt(x*x-1)+x)) if x>2; else
< * acosh(x) := log1p(t+sqrt(2.0*t+t*t)); where t=x-1.
---
> /*
> * See e_acosh.c for complete comments.
27,29c22,23
< * Special cases:
< * acosh(x) is NaN with signal if x<1.
< * acosh(NaN) is NaN without signal.
---
> * Converted to long double by David Schultz <das@FreeBSD.ORG> and
> * Bruce D. Evans.
31a26,31
> #include <float.h>
> #ifdef __i386__
> #include <ieeefp.h>
> #endif
>
> #include "fpmath.h"
34a35,50
> /* EXP_LARGE is the threshold above which we use acosh(x) ~= log(2x). */
> #if LDBL_MANT_DIG == 64
> #define EXP_LARGE 34
> #elif LDBL_MANT_DIG == 113
> #define EXP_LARGE 58
> #else
> #error "Unsupported long double format"
> #endif
>
> #if LDBL_MAX_EXP != 0x4000
> /* We also require the usual expsign encoding. */
> #error "Unsupported long double format"
> #endif
>
> #define BIAS (LDBL_MAX_EXP - 1)
>
36,37c52
< one = 1.0,
< ln2 = 6.93147180559945286227e-01; /* 0x3FE62E42, 0xFEFA39EF */
---
> one = 1.0;
39,40c54,66
< double
< __ieee754_acosh(double x)
---
> #if LDBL_MANT_DIG == 64
> static const union IEEEl2bits
> u_ln2 = LD80C(0xb17217f7d1cf79ac, -1, 6.93147180559945309417e-1L);
> #define ln2 u_ln2.e
> #elif LDBL_MANT_DIG == 113
> static const long double
> ln2 = 6.93147180559945309417232121458176568e-1L; /* 0x162e42fefa39ef35793c7673007e6.0p-113 */
> #else
> #error "Unsupported long double format"
> #endif
>
> long double
> acoshl(long double x)
42,50c68,77
< double t;
< int32_t hx;
< u_int32_t lx;
< EXTRACT_WORDS(hx,lx,x);
< if(hx<0x3ff00000) { /* x < 1 */
< return (x-x)/(x-x);
< } else if(hx >=0x41b00000) { /* x > 2**28 */
< if(hx >=0x7ff00000) { /* x is inf of NaN */
< return x+x;
---
> long double t;
> int16_t hx;
>
> ENTERI();
> GET_LDBL_EXPSIGN(hx, x);
> if (hx < 0x3fff) { /* x < 1, or misnormal */
> RETURNI((x-x)/(x-x));
> } else if (hx >= BIAS + EXP_LARGE) { /* x >= LARGE */
> if (hx >= 0x7fff) { /* x is inf, NaN or misnormal */
> RETURNI(x+x);
52,55c79,82
< return __ieee754_log(x)+ln2; /* acosh(huge)=log(2x) */
< } else if(((hx-0x3ff00000)|lx)==0) {
< return 0.0; /* acosh(1) = 0 */
< } else if (hx > 0x40000000) { /* 2**28 > x > 2 */
---
> RETURNI(logl(x)+ln2); /* acosh(huge)=log(2x), or misnormal */
> } else if (hx == 0x3fff && x == 1) {
> RETURNI(0.0); /* acosh(1) = 0 */
> } else if (hx >= 0x4000) { /* LARGE > x >= 2, or misnormal */
57c84
< return __ieee754_log(2.0*x-one/(x+sqrt(t-one)));
---
> RETURNI(logl(2.0*x-one/(x+sqrtl(t-one))));
60c87
< return log1p(t+sqrt(2.0*t+t*t));
---
> RETURNI(log1pl(t+sqrtl(2.0*t+t*t)));