about summary refs log tree commit diff
path: root/sysdeps/ieee754
diff options
context:
space:
mode:
Diffstat (limited to 'sysdeps/ieee754')
-rw-r--r--sysdeps/ieee754/ldbl-128/s_expm1l.c15
1 files changed, 12 insertions, 3 deletions
diff --git a/sysdeps/ieee754/ldbl-128/s_expm1l.c b/sysdeps/ieee754/ldbl-128/s_expm1l.c
index f708af504c..573d00be57 100644
--- a/sysdeps/ieee754/ldbl-128/s_expm1l.c
+++ b/sysdeps/ieee754/ldbl-128/s_expm1l.c
@@ -137,9 +137,18 @@ __expm1l (long double x)
   if (x < minarg)
     return (4.0/big - 1.0L);
 
-  /* Avoid internal underflow when result does not underflow.  */
-  if (fabsl (x) < 0x1p-113L && fabsl (x) >= LDBL_MIN)
-    return x;
+  /* Avoid internal underflow when result does not underflow, while
+     ensuring underflow (without returning a zero of the wrong sign)
+     when the result does underflow.  */
+  if (fabsl (x) < 0x1p-113L)
+    {
+      if (fabsl (x) < LDBL_MIN)
+	{
+	  long double force_underflow = x * x;
+	  math_force_eval (force_underflow);
+	}
+      return x;
+    }
 
   /* Express x = ln 2 (k + remainder), remainder not exceeding 1/2. */
   xx = C1 + C2;			/* ln 2. */