From patchwork Fri Mar 28 15:19:49 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Joseph Myers X-Patchwork-Id: 334 Return-Path: X-Original-To: siddhesh@wilcox.dreamhost.com Delivered-To: siddhesh@wilcox.dreamhost.com Received: from homiemail-mx23.g.dreamhost.com (caibbdcaabja.dreamhost.com [208.113.200.190]) by wilcox.dreamhost.com (Postfix) with ESMTP id 5CE6C36067F for ; Fri, 28 Mar 2014 08:20:05 -0700 (PDT) Received: by homiemail-mx23.g.dreamhost.com (Postfix, from userid 14307373) id 0DAD4620CAB04; Fri, 28 Mar 2014 08:20:05 -0700 (PDT) X-Original-To: glibc@patchwork.siddhesh.in Delivered-To: x14307373@homiemail-mx23.g.dreamhost.com Received: from sourceware.org (server1.sourceware.org [209.132.180.131]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by homiemail-mx23.g.dreamhost.com (Postfix) with ESMTPS id DABB1620C8000 for ; Fri, 28 Mar 2014 08:20:04 -0700 (PDT) DomainKey-Signature: a=rsa-sha1; c=nofws; d=sourceware.org; h=list-id :list-unsubscribe:list-subscribe:list-archive:list-post :list-help:sender:date:from:to:subject:message-id:mime-version :content-type; q=dns; s=default; b=Dfdz1qaHBBHycmxnBs3Z0HGIgUYzs p4LBbXfFo3DtTCmDgA77YhHMc4hirfdk2EfNFQ7WWSn4swwRoa4YsaeGg1QR16e2 Kik1ZkkHj21xmw1v/7XVyQpBxyrRdTWXi4vEK32ZV/KiC10ENmzFWbhr/HO/STb2 Ei1/3YnihMPITo= DKIM-Signature: v=1; a=rsa-sha1; c=relaxed; d=sourceware.org; h=list-id :list-unsubscribe:list-subscribe:list-archive:list-post :list-help:sender:date:from:to:subject:message-id:mime-version :content-type; s=default; bh=vgrWtsjvK66klfEk9gOgvBDb8NU=; b=Qoa OSiNedkcyZg1CGAVCpYKvCb234RYj0rw0HSnGv+HYYIwHPew23h7FKQHik4EkqGA sjtG126w/iGQmiuaaVGhglFKegXp7jhLcoX/rkMgYUyfOhrJucobK/2xGcVkv1dm cldE0/DE0Z0xiF1icN2d/FKEtuI/WLPoBFmdpWr8= Received: (qmail 28079 invoked by alias); 28 Mar 2014 15:20:00 -0000 Mailing-List: contact libc-alpha-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Unsubscribe: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: libc-alpha-owner@sourceware.org Delivered-To: mailing list libc-alpha@sourceware.org Received: (qmail 28064 invoked by uid 89); 28 Mar 2014 15:19:59 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-2.0 required=5.0 tests=AWL, BAYES_00 autolearn=ham version=3.3.2 X-HELO: relay1.mentorg.com Date: Fri, 28 Mar 2014 15:19:49 +0000 From: "Joseph S. Myers" To: Subject: Fix clog10 (-0 +/- 0i) (bug 16362) Message-ID: MIME-Version: 1.0 X-DH-Original-To: glibc@patchwork.siddhesh.in 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. 2014-03-28 Joseph Myers [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. diff --git a/math/libm-test.inc b/math/libm-test.inc index 9c4c2bf..cefcb96 100644 --- a/math/libm-test.inc +++ b/math/libm-test.inc @@ -6130,8 +6130,8 @@ clog_test (void) static const struct test_c_c_data clog10_test_data[] = { - TEST_c_c (clog10, minus_zero, 0, minus_infty, M_PIl, DIVIDE_BY_ZERO_EXCEPTION), - TEST_c_c (clog10, minus_zero, minus_zero, minus_infty, -M_PIl, DIVIDE_BY_ZERO_EXCEPTION), + TEST_c_c (clog10, minus_zero, 0, minus_infty, M_PI_LOG10El, DIVIDE_BY_ZERO_EXCEPTION), + TEST_c_c (clog10, minus_zero, minus_zero, minus_infty, -M_PI_LOG10El, DIVIDE_BY_ZERO_EXCEPTION), TEST_c_c (clog10, 0, 0, minus_infty, 0.0, DIVIDE_BY_ZERO_EXCEPTION), TEST_c_c (clog10, 0, minus_zero, minus_infty, minus_zero, DIVIDE_BY_ZERO_EXCEPTION), diff --git a/math/s_clog10.c b/math/s_clog10.c index 417d561..e757879 100644 --- a/math/s_clog10.c +++ b/math/s_clog10.c @@ -25,6 +25,9 @@ /* log_10 (2). */ #define M_LOG10_2 0.3010299956639811952137388947244930267682 +/* pi * log10 (e). */ +#define M_PI_LOG10E 1.364376353841841347485783625431355770210 + __complex__ double __clog10 (__complex__ double x) { @@ -35,7 +38,7 @@ __clog10 (__complex__ double 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_LOG10E : 0.0; __imag__ result = __copysign (__imag__ result, __imag__ x); /* Yes, the following line raises an exception. */ __real__ result = -1.0 / fabs (__real__ x); diff --git a/math/s_clog10f.c b/math/s_clog10f.c index a9120e0..ca2cdf4 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); diff --git a/math/s_clog10l.c b/math/s_clog10l.c index ac33a8f..cdb5d61 100644 --- a/math/s_clog10l.c +++ b/math/s_clog10l.c @@ -32,6 +32,9 @@ /* log_10 (2). */ #define M_LOG10_2l 0.3010299956639811952137388947244930267682L +/* pi * log10 (e). */ +#define M_PI_LOG10El 1.364376353841841347485783625431355770210L + __complex__ long double __clog10l (__complex__ long double x) { @@ -42,7 +45,7 @@ __clog10l (__complex__ long double x) if (__glibc_unlikely (rcls == FP_ZERO && icls == FP_ZERO)) { /* Real and imaginary part are 0.0. */ - __imag__ result = signbit (__real__ x) ? M_PIl : 0.0; + __imag__ result = signbit (__real__ x) ? M_PI_LOG10El : 0.0; __imag__ result = __copysignl (__imag__ result, __imag__ x); /* Yes, the following line raises an exception. */ __real__ result = -1.0 / fabsl (__real__ x);