diff --git a/src/lisp/e_acosh.c b/src/lisp/e_acosh.c index 683955410c1e30c413bbfe6800a120686fff9a04..fb248d544d309076f7235afdac6e0c25a720d0fe 100644 --- a/src/lisp/e_acosh.c +++ b/src/lisp/e_acosh.c @@ -45,7 +45,10 @@ ln2 = 6.93147180559945286227e-01; /* 0x3FE62E42, 0xFEFA39EF */ { double t; int hx; - hx = __HI(x); + union { int i[2]; double d; } ux; + + ux.d = x; + hx = ux.i[HIWORD]; if(hx<0x3ff00000) { /* x < 1 */ return (x-x)/(x-x); } else if(hx >=0x41b00000) { /* x > 2**28 */ @@ -53,13 +56,13 @@ ln2 = 6.93147180559945286227e-01; /* 0x3FE62E42, 0xFEFA39EF */ return x+x; } else return __ieee754_log(x)+ln2; /* acosh(huge)=log(2x) */ - } else if(((hx-0x3ff00000)|__LO(x))==0) { + } else if(((hx-0x3ff00000)|ux.i[LOWORD])==0) { return 0.0; /* acosh(1) = 0 */ } else if (hx > 0x40000000) { /* 2**28 > x > 2 */ t=x*x; return __ieee754_log(2.0*x-one/(x+sqrt(t-one))); } else { /* 1<x<2 */ t = x-one; - return log1p(t+sqrt(2.0*t+t*t)); + return fdlibm_log1p(t+sqrt(2.0*t+t*t)); } } diff --git a/src/lisp/e_atanh.c b/src/lisp/e_atanh.c index 302a89f44ccac81a510e6aa9940927b5e0e2dd96..358843698fa156d7c67b23f325e868146b41639c 100644 --- a/src/lisp/e_atanh.c +++ b/src/lisp/e_atanh.c @@ -50,19 +50,24 @@ static double zero = 0.0; double t; int hx,ix; unsigned lx; - hx = __HI(x); /* high word */ - lx = __LO(x); /* low word */ + union { int i[2]; double d; } ux; + + ux.d = x; + hx = ux.i[HIWORD]; /* high word */ + lx = ux.i[LOWORD]; /* low word */ ix = hx&0x7fffffff; if ((ix|((lx|(-lx))>>31))>0x3ff00000) /* |x|>1 */ return (x-x)/(x-x); if(ix==0x3ff00000) return x/zero; if(ix<0x3e300000&&(huge+x)>zero) return x; /* x<2**-28 */ - __HI(x) = ix; /* x <- |x| */ + ux.d = x; + ux.i[HIWORD] = ix; /* x <- |x| */ + x = ux.d; if(ix<0x3fe00000) { /* x < 0.5 */ t = x+x; - t = 0.5*log1p(t+t*x/(one-x)); + t = 0.5*fdlibm_log1p(t+t*x/(one-x)); } else - t = 0.5*log1p((x+x)/(one-x)); + t = 0.5*fdlibm_log1p((x+x)/(one-x)); if(hx>=0) return t; else return -t; } diff --git a/src/lisp/fdlibm.h b/src/lisp/fdlibm.h index 325d7d42f6da040773a7b3afdcd57d39bd0ff589..72f57f823a7327df425f6fcf65f17dc8f7ab78f5 100644 --- a/src/lisp/fdlibm.h +++ b/src/lisp/fdlibm.h @@ -52,7 +52,9 @@ extern double fdlibm_sin(double x); extern double fdlibm_cos(double x); extern double fdlibm_tan(double x); extern double fdlibm_expm1(double x); +extern double fdlibm_log1p(double x); extern double __ieee754_exp(double x); +extern double __ieee754_log(double x); #endif diff --git a/src/lisp/s_asinh.c b/src/lisp/s_asinh.c index c8094673bb389a9e7525c1cb3d48835f9fc53315..6cae81ff299c4763a5d5511e017e36e9bd605338 100644 --- a/src/lisp/s_asinh.c +++ b/src/lisp/s_asinh.c @@ -34,15 +34,18 @@ ln2 = 6.93147180559945286227e-01, /* 0x3FE62E42, 0xFEFA39EF */ huge= 1.00000000000000000000e+300; #ifdef __STDC__ - double asinh(double x) + double fdlibm_asinh(double x) #else - double asinh(x) + double fdlibm_asinh(x) double x; #endif { double t,w; int hx,ix; - hx = __HI(x); + union { int i[2]; double d; } ux; + + ux.d = x; + hx = ux.i[HIWORD]; ix = hx&0x7fffffff; if(ix>=0x7ff00000) return x+x; /* x is inf or NaN */ if(ix< 0x3e300000) { /* |x|<2**-28 */ @@ -55,7 +58,7 @@ huge= 1.00000000000000000000e+300; w = __ieee754_log(2.0*t+one/(sqrt(x*x+one)+t)); } else { /* 2.0 > |x| > 2**-28 */ t = x*x; - w =log1p(fabs(x)+t/(one+sqrt(one+t))); + w =fdlibm_log1p(fabs(x)+t/(one+sqrt(one+t))); } if(hx>0) return w; else return -w; }