From owner-cvs-all@FreeBSD.ORG Wed May 2 15:24:49 2007 Return-Path: X-Original-To: cvs-all@FreeBSD.org Delivered-To: cvs-all@FreeBSD.org Received: from mx1.freebsd.org (mx1.freebsd.org [69.147.83.52]) by hub.freebsd.org (Postfix) with ESMTP id EF6E516A401; Wed, 2 May 2007 15:24:49 +0000 (UTC) (envelope-from bde@FreeBSD.org) Received: from repoman.freebsd.org (repoman.freebsd.org [69.147.83.41]) by mx1.freebsd.org (Postfix) with ESMTP id E204413C4D3; Wed, 2 May 2007 15:24:49 +0000 (UTC) (envelope-from bde@FreeBSD.org) Received: from repoman.freebsd.org (localhost [127.0.0.1]) by repoman.freebsd.org (8.13.8/8.13.8) with ESMTP id l42FOn01033761; Wed, 2 May 2007 15:24:49 GMT (envelope-from bde@repoman.freebsd.org) Received: (from bde@localhost) by repoman.freebsd.org (8.13.8/8.13.8/Submit) id l42FOnXp033760; Wed, 2 May 2007 15:24:49 GMT (envelope-from bde) Message-Id: <200705021524.l42FOnXp033760@repoman.freebsd.org> From: Bruce Evans Date: Wed, 2 May 2007 15:24:49 +0000 (UTC) To: src-committers@FreeBSD.org, cvs-src@FreeBSD.org, cvs-all@FreeBSD.org X-FreeBSD-CVS-Branch: HEAD Cc: Subject: cvs commit: src/lib/msun/bsdsrc b_tgamma.c X-BeenThere: cvs-all@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: CVS commit messages for the entire tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 02 May 2007 15:24:50 -0000 bde 2007-05-02 15:24:49 UTC FreeBSD src repository Modified files: lib/msun/bsdsrc b_tgamma.c Log: Fix tgamma() on some special args: (1) tgamma(-Inf) returned +Inf and failed to raise any exception, but should always have raised an exception, and should behave like tgamma(negative integer). (2) tgamma(negative integer) returned +Inf and raised divide-by-zero, but should return NaN and raise "invalid" on any IEEEish system. (3) About half of the 2**52 negative intgers between -2**53 and -2**52 were misclassified as non-integers by using floor(x + 0.5) to round to nearest, so tgamma(x) was wrong (+-0 instead of +Inf and now NaN) on these args. The floor() expression is hard to use since rounding of (x + 0.5) may give x or x + 1, depending on |x| and the current rounding mode. The fixed version uses ceil(x) to classify x before operating on x and ends up being more efficient since ceil(x) is needed anyway. (4) On at least the problematic args in (3), tgamma() raised a spurious inexact. (5) tgamma(large positive) raised divide-by-zero but should raise overflow. (6) tgamma(+Inf) raised divide-by-zero but should not raise any exception. (7) Raise inexact for tiny |x| in a way that has some chance of not being optimized away. The fix for (5) and (6), and probably for (2), also prevents -O optimizing away the exception. PR: 112180 (2) Standards: Annex F in C99 (IEC 60559 binding) requires (1), (2) and (6). Revision Changes Path 1.9 +15 -14 src/lib/msun/bsdsrc/b_tgamma.c