summary refs log tree commit diff
path: root/math/s_clog10l.c
diff options
context:
space:
mode:
authorJoseph Myers <joseph@codesourcery.com>2014-04-02 13:10:19 +0000
committerJoseph Myers <joseph@codesourcery.com>2014-04-02 13:10:19 +0000
commit6f05bafebac30a389807979f8efbb709f84b486f (patch)
treeecd76f4b39be7484aa2e5bfb1d18e164d66a0674 /math/s_clog10l.c
parentb0abbc21034f0e5edc49023d8fda0616173faf17 (diff)
downloadglibc-6f05bafebac30a389807979f8efbb709f84b486f.tar.gz
glibc-6f05bafebac30a389807979f8efbb709f84b486f.tar.xz
glibc-6f05bafebac30a389807979f8efbb709f84b486f.zip
Fix clog / clog10 sign of zero result in round-downward mode (bug 16789).
This patch fixes bug 16789, incorrect sign of (real part) zero result
from clog and clog10 in round-downward mode, arising from that real
part being computed as 0 - 0.  To ensure that an underflow exception
occurred, the code used an underflowing value (the next term in the
series for log1p) in arithmetic computing the real part of the result,
yielding the problematic 0 - 0 computation in some cases even when the
mathematical result would be small but positive.  The patch changes
this code to use the math_force_eval approach to ensuring that an
underflowing computation actually occurs.  Tests of clog and clog10
are enabled in all rounding modes.

Tested x86_64 and x86 and ulps updated accordingly.

	[BZ #16789]
	* math/s_clog.c (__clog): Use math_force_eval to ensure underflow
	instead of using underflowing value in computing result.
	* math/s_clog10.c (__clog10): Likewise.
	* math/s_clog10f.c (__clog10f): Likewise.
	* math/s_clog10l.c (__clog10l): Likewise.
	* math/s_clogf.c (__clogf): Likewise.
	* math/s_clogl.c (__clogl): Likewise.
	* math/libm-test.inc (clog_test): Use ALL_RM_TEST.
	(clog10_test): Likewise.
	* sysdeps/i386/fpu/libm-test-ulps: Update.
	* sysdeps/x86_64/fpu/libm-test-ulps: Likewise.
Diffstat (limited to 'math/s_clog10l.c')
-rw-r--r--math/s_clog10l.c7
1 files changed, 5 insertions, 2 deletions
diff --git a/math/s_clog10l.c b/math/s_clog10l.c
index cdb5d61014..fd86ecb47d 100644
--- a/math/s_clog10l.c
+++ b/math/s_clog10l.c
@@ -80,8 +80,11 @@ __clog10l (__complex__ long double x)
 	{
 	  long double absy2 = absy * absy;
 	  if (absy2 <= LDBL_MIN * 2.0L * M_LN10l)
-	    __real__ result
-	      = (absy2 / 2.0L - absy2 * absy2 / 4.0L) * M_LOG10El;
+	    {
+	      long double force_underflow = absy2 * absy2;
+	      __real__ result = absy2 * (M_LOG10El / 2.0);
+	      math_force_eval (force_underflow);
+	    }
 	  else
 	    __real__ result = __log1pl (absy2) * (M_LOG10El / 2.0L);
 	}