From patchwork Tue Jun 10 09:02:08 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Rajalakshmi Srinivasaraghavan X-Patchwork-Id: 357799 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org 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 ozlabs.org (Postfix) with ESMTPS id 62F811400A8 for ; Tue, 10 Jun 2014 19:02:33 +1000 (EST) DomainKey-Signature: a=rsa-sha1; c=nofws; d=sourceware.org; h=list-id :list-unsubscribe:list-subscribe:list-archive:list-post :list-help:sender:from:to:cc:subject:date:message-id; q=dns; s= default; b=oETzPuVLCdXEFtI7I5sXkVZZVsc87S4oe5QbYnZ1MEw3VPNgCv9ff f8e6huRoMfe92+3ujYh7CXlde7wnuRjz0w6YuNLmOejXScrrlmZY9ZFtFoth9jHg 22KqWXh+/ohuvIBUHeFCVLJFpY5wtfs2VLJdb5SgiQUnSQseSvCVYc= 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:from:to:cc:subject:date:message-id; s=default; bh=bQk0qUEqAh+Y+dFPFLmK8SiZM2s=; b=mD8gRLbEn7gNJ4JNyPTE1Clwy+UW NlhG+SsTaPhM/U82p3mG79khzD4UFSwlgyaH/nWaDA3DbXAxSaN9mNk0wBjFV2QA XOfUpMA6qfO0YdIydVeitGUWJ0lvrakOW8dFIg4cb09VKSWuAyGDx+jKBmDjtRQh nNoyyPgvaDZrMn0= Received: (qmail 18130 invoked by alias); 10 Jun 2014 09:02:27 -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 18110 invoked by uid 89); 10 Jun 2014 09:02:25 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-2.4 required=5.0 tests=AWL, BAYES_00, RP_MATCHES_RCVD autolearn=ham version=3.3.2 X-HELO: e28smtp05.in.ibm.com From: Rajalakshmi Srinivasaraghavan To: libc-alpha@sourceware.org Cc: Rajalakshmi Srinivasaraghavan Subject: [PATCH] [BZ #17031][PowerPC64] Fix nearbyintl failure for few inputs Date: Tue, 10 Jun 2014 04:02:08 -0500 Message-Id: <1402390928-37048-1-git-send-email-raji@linux.vnet.ibm.com> X-TM-AS-MML: disable X-Content-Scanned: Fidelis XPS MAILER x-cbid: 14061009-8256-0000-0000-00000DAA18A5 This patch fixes few failures in nearbyintl() where the fraction part is close to 0.5. [BZ #17031] sysdeps/ieee754/ldbl-128ibm/s_nearbyintl.c: Consider the low double, adjusted for any remainder from the high double. Signed-off-by: Rajalakshmi Srinivasaraghavan --- NEWS | 2 +- sysdeps/ieee754/ldbl-128ibm/s_nearbyintl.c | 5 +++++ 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/NEWS b/NEWS index 622cdbf..eb6b736 100644 --- a/NEWS +++ b/NEWS @@ -19,7 +19,7 @@ Version 2.20 16791, 16796, 16799, 16800, 16815, 16823, 16824, 16831, 16838, 16849, 16854, 16876, 16877, 16878, 16882, 16885, 16888, 16890, 16912, 16915, 16916, 16917, 16922, 16927, 16928, 16932, 16943, 16958, 16965, 16966, - 16967, 16977, 16978, 16984, 16990, 17009. + 16967, 16977, 16978, 16984, 16990, 17009, 17031. * The minimum Linux kernel version that this version of the GNU C Library can be used with is 2.6.32. diff --git a/sysdeps/ieee754/ldbl-128ibm/s_nearbyintl.c b/sysdeps/ieee754/ldbl-128ibm/s_nearbyintl.c index 4e997a6..8f34604 100644 --- a/sysdeps/ieee754/ldbl-128ibm/s_nearbyintl.c +++ b/sysdeps/ieee754/ldbl-128ibm/s_nearbyintl.c @@ -38,6 +38,7 @@ __nearbyintl (long double x) if (fabs (u.d[0].d) < TWO52) { + double xh = u.d[0].d; double high = u.d[0].d; feholdexcept (&env); if (high > 0.0) @@ -52,6 +53,10 @@ __nearbyintl (long double x) high += TWO52; if (high == 0.0) high = -0.0; } + if (u.d[1].d > 0.0 && (xh - high == 0.5)) + high += 1.0; + else if (u.d[1].d < 0.0 && (-(xh - high) == 0.5)) + high -= 1.0; u.d[0].d = high; u.d[1].d = 0.0; math_force_eval (u.d[0]);