From 3fae8e0ba9090991b0ac9a69b714df7544a9c707 Mon Sep 17 00:00:00 2001 From: h_vogt Date: Wed, 9 Oct 2013 21:39:50 +0200 Subject: [PATCH] xpressn.c: add domain check for acosh, atanh replacement functions --- src/frontend/numparam/xpressn.c | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/src/frontend/numparam/xpressn.c b/src/frontend/numparam/xpressn.c index 6aed9d4e0..2bd039d28 100644 --- a/src/frontend/numparam/xpressn.c +++ b/src/frontend/numparam/xpressn.c @@ -194,14 +194,22 @@ mathfunction(int f, double z, double x) #ifdef HAVE_ACOSH y = acosh(x); #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 break; case 33: #ifdef HAVE_ATANH y = atanh(x); #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 break; case 34: