From 289e0779571a36a8f30ae0408b4902bb7f2ab92e Mon Sep 17 00:00:00 2001 From: Joseph Myers Date: Fri, 28 Mar 2014 20:53:32 +0000 Subject: Fix clog10 (-0 +/- 0i) (bug 16362). This patch fixes the imaginary part of clog10 (-0 +/- 0i), which should be +/-pi / log(10) by analogy with clog (the functions were wrongly returning a result with imaginary part +/-pi, same as for clog, and the tests matched the incorrect result, though both functions and tests were correct for the similar case of clog10 (-inf +/- 0i)). Tested x86_64 and x86. [BZ #16362] * math/s_clog10.c (M_PI_LOG10E): New macro. (__clog10): Use M_PI_LOG10E instead of M_PI when real and imaginary parts are 0. * math/s_clog10f.c (M_PI_LOG10Ef): New macro. (__clog10f): Use M_PI_LOG10Ef instead of M_PI when real and imaginary parts are 0. * math/s_clog10l.c (M_PI_LOG10El): New macro. (__clog10l): Use M_PI_LOG10El instead of M_PIl when real and imaginary parts are 0. * math/libm-test.inc (clog10_test_data): Update expected results for when real and imaginary parts are 0. --- math/s_clog10f.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) (limited to 'math/s_clog10f.c') diff --git a/math/s_clog10f.c b/math/s_clog10f.c index a9120e03f8..ca2cdf4f80 100644 --- a/math/s_clog10f.c +++ b/math/s_clog10f.c @@ -25,6 +25,9 @@ /* log_10 (2). */ #define M_LOG10_2f 0.3010299956639811952137388947244930267682f +/* pi * log10 (e). */ +#define M_PI_LOG10Ef 1.364376353841841347485783625431355770210f + __complex__ float __clog10f (__complex__ float x) { @@ -35,7 +38,7 @@ __clog10f (__complex__ float x) if (__glibc_unlikely (rcls == FP_ZERO && icls == FP_ZERO)) { /* Real and imaginary part are 0.0. */ - __imag__ result = signbit (__real__ x) ? M_PI : 0.0; + __imag__ result = signbit (__real__ x) ? M_PI_LOG10Ef : 0.0; __imag__ result = __copysignf (__imag__ result, __imag__ x); /* Yes, the following line raises an exception. */ __real__ result = -1.0 / fabsf (__real__ x); -- cgit 1.4.1