xpressn.c: add domain check for acosh, atanh replacement functions

This commit is contained in:
h_vogt 2013-10-09 21:39:50 +02:00 committed by rlar
parent 2f508696a6
commit 3fae8e0ba9
1 changed files with 10 additions and 2 deletions

View File

@ -194,14 +194,22 @@ mathfunction(int f, double z, double x)
#ifdef HAVE_ACOSH #ifdef HAVE_ACOSH
y = acosh(x); y = acosh(x);
#else #else
y = (log(x + sqrt(x*x-1.0))); /* domain check (HUGE_VAL like gnu libc) */
if (x < 1.)
y = HUGE_VAL;
else
y = (log(x + sqrt(x*x-1.0)));
#endif #endif
break; break;
case 33: case 33:
#ifdef HAVE_ATANH #ifdef HAVE_ATANH
y = atanh(x); y = atanh(x);
#else #else
y = (log((1.0 + x) / (1.0 - x)) / 2.0); /* domain check (HUGE_VAL like gnu libc) */
if (fabs(x) >= 1.)
y = HUGE_VAL;
else
y = (log((1.0 + x) / (1.0 - x)) / 2.0);
#endif #endif
break; break;
case 34: case 34: